/*
 * layout-fix.css - Fix for footer flashing issue
 * Implements proper sticky footer pattern
 */

/* Ensure full height layout */
html {
  height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
}

/* Main content should grow to push footer down */
#main-content,
main {
  flex: 1 0 auto;
  /* Ensure minimum height even without content */
  min-height: calc(100vh - var(--header-height, 60px) - var(--footer-height, 80px) - 100px);
}

/* Footer should shrink to fit content */
footer {
  flex-shrink: 0;
  /* Prevent footer from jumping during load */
  position: relative;
  margin-top: auto;
}

/* Prevent FOUC (Flash of Unstyled Content) for footer */
footer:empty {
  min-height: var(--footer-height, 80px);
  opacity: 0;
}

/* Smooth transition when footer content loads */
footer {
  transition: opacity 0.2s ease-in-out;
  opacity: 1;
}

/* Fix for admin pages that might have different structure */
.admin-layout {
  min-height: calc(100vh - var(--header-height, 60px) - var(--footer-height, 80px));
}

/* Ensure dashboard doesn't interfere with sticky footer */
.dashboard {
  min-height: auto;
}

/* Additional fix for content containers */
.container,
.container-max,
.container-fluid {
  /* Remove any conflicting height settings */
  height: auto;
  min-height: auto;
}

/* Fix for campaigns page specifically */
.campaigns-content,
.campaign-detail {
  min-height: 400px; /* Minimum content height */
}

/* Prevent content shift during HTMX updates */
[hx-swap] {
  min-height: inherit;
}

/* Loading state for HTMX content */
.htmx-request {
  min-height: 200px;
  position: relative;
}

/* Optional: Add loading indicator during transitions */
.htmx-request::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--color-primary, #3a3a7c);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}