/**
 * BuzzersFit Layouts 2025
 * 
 * Page layouts and structural components
 * Requires: design-system.css
 */

/* ============================================
   PAGE LAYOUTS
   ============================================ */

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-content {
  flex: 1;
  padding: var(--space-6) 0;
}

/* ============================================
   HEADER / NAVBAR
   ============================================ */

.navbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background-color: var(--surface-base);
  border-bottom: 1px solid var(--color-border-light);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.navbar-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
  padding: 0 var(--space-6);
  max-width: var(--container-xl);
  margin: 0 auto;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
  text-decoration: none;
}

.navbar-brand img {
  height: 2rem;
  width: auto;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.navbar-link {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.navbar-link:hover {
  color: var(--color-text);
  background-color: var(--color-gray-100);
}

.navbar-link.active {
  color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Mobile menu toggle */
.navbar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  width: 2.5rem;
  height: 2.5rem;
  color: var(--color-text);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.navbar-toggle:hover {
  background-color: var(--color-gray-100);
}

/* Hamburger icon animation */
.navbar-toggle .fa-bars,
.navbar-toggle .fa-xmark {
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

/* ─── Tablet: compact nav (769px – 1024px) ─── */
@media (max-width: 1024px) and (min-width: 769px) {
  .navbar-container {
    padding: 0 var(--space-4);
  }

  .navbar-nav {
    gap: 0;
  }

  .navbar-link {
    padding: var(--space-2);
    font-size: var(--text-xs);
  }

  .navbar-actions {
    gap: var(--space-2);
  }

  .navbar-actions .btn:not(.btn-icon) {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
  }
}

/* ─── Mobile: collapsed nav (≤768px) ─── */
@media (max-width: 768px) {
  .navbar-container {
    flex-wrap: wrap;
    height: auto;
    min-height: 3.5rem;
    padding: var(--space-2) var(--space-4);
    gap: 0;
  }

  .navbar-brand {
    order: 1;
    flex: 1;
  }

  .navbar-actions {
    order: 2;
    gap: var(--space-1);
  }

  /* On mobile, hide button text and show icons only */
  .navbar-actions .btn:not(.btn-icon) {
    font-size: 0;
    gap: 0;
    padding: var(--space-2);
    border-radius: var(--radius-md);
  }

  .navbar-actions .btn:not(.btn-icon) i {
    font-size: var(--text-base);
    margin: 0 !important;
  }

  .navbar-toggle {
    display: flex;
    order: 3;
  }

  .navbar-nav {
    order: 4;
    display: flex;
    width: 100%;
    flex-direction: column;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding: 0;
    border-top: 1px solid transparent;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
      opacity 0.25s ease,
      padding 0.3s ease,
      border-color 0.3s ease;
  }

  .navbar-nav.open {
    max-height: 70vh;
    overflow-y: auto;
    opacity: 1;
    padding: var(--space-3) 0;
    border-top-color: var(--color-border-light);
    -webkit-overflow-scrolling: touch;
  }

  .navbar-link {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
  }

  .navbar-link:active {
    background-color: var(--color-gray-200);
  }

  /* Dropdown inside mobile nav */
  .navbar-nav .dropdown {
    width: 100%;
  }

  .navbar-nav .dropdown>.navbar-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .navbar-nav .dropdown>.navbar-link i.fa-chevron-down {
    transition: transform 0.2s ease;
  }

  .navbar-nav .dropdown.open>.navbar-link i.fa-chevron-down {
    transform: rotate(180deg);
  }

  .navbar-nav .dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: none;
    visibility: hidden;
    transition: max-height 0.3s ease,
      opacity 0.2s ease,
      padding 0.3s ease,
      visibility 0s 0.3s;
  }

  .navbar-nav .dropdown.open .dropdown-menu {
    max-height: 40vh;
    overflow-y: auto;
    opacity: 1;
    visibility: visible;
    padding: var(--space-1) 0 var(--space-1) var(--space-4);
    -webkit-overflow-scrolling: touch;
    transition: max-height 0.3s ease,
      opacity 0.2s ease,
      padding 0.3s ease,
      visibility 0s;
  }

  .navbar-nav .dropdown-item {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
  }
}

/* ============================================
   SIDEBAR LAYOUT
   ============================================ */

.layout-sidebar {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 280px;
  background-color: var(--color-background-alt);
  border-right: 1px solid var(--color-border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border-light);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border-light);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
}

.sidebar-link:hover {
  color: var(--color-text);
  background-color: var(--color-gray-200);
}

.sidebar-link.active {
  color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.sidebar-link i,
.sidebar-link svg {
  width: 1.25rem;
  flex-shrink: 0;
}

.sidebar-section {
  margin-top: var(--space-6);
}

.sidebar-section-title {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.main-content {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Container inside sidebar layout should use full available width */
.layout-sidebar .main-content .container {
  max-width: 100%;
}

/* Sidebar toggle button: always visible on mobile/tablet, hidden on desktop */
.layout-sidebar .sidebar-toggle {
  display: none;
}

@media (max-width: 1024px) {
  .layout-sidebar .sidebar-toggle {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: var(--z-fixed);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-2xl);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--surface-backdrop);
    z-index: calc(var(--z-fixed) - 1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
  }

  .sidebar-overlay.open {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s;
  }

  /* Top navbar inside sidebar layout: adjust for mobile */
  .layout-sidebar>.main-content>.navbar .navbar-container {
    padding: 0 var(--space-4);
  }
}

/* ─── Sidebar tablet: slightly narrower ─── */
@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar {
    width: 260px;
  }
}

/* ============================================
   HERO SECTION
   ============================================ */

.hero {
  padding: var(--space-16) 0;
  text-align: center;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: var(--color-text-inverse);
}

.hero-title {
  font-size: var(--text-5xl);
  font-weight: var(--font-extrabold);
  margin-bottom: var(--space-4);
  color: var(--color-text-inverse);
}

.hero-subtitle {
  font-size: var(--text-xl);
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto var(--space-8);
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* Compact hero */
.hero-compact {
  padding: var(--space-8) 0;
}

.hero-compact .hero-title {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-2);
}

/* ============================================
   PAGE HEADER
   ============================================ */

.page-header {
  padding: var(--space-6) 0;
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border-light);
}

.page-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  margin: 0;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
}

.breadcrumb-item {
  color: var(--color-text-secondary);
}

.breadcrumb-item a {
  color: var(--color-text-secondary);
  text-decoration: none;
}

.breadcrumb-item a:hover {
  color: var(--color-primary);
}

.breadcrumb-item:last-child {
  color: var(--color-text);
}

.breadcrumb-separator {
  color: var(--color-text-muted);
}

/* ============================================
   SECTION
   ============================================ */

.section {
  padding: var(--space-12) 0;
}

.section-header {
  text-align: center;
  margin-bottom: var(--space-10);
}

.section-title {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-3);
}

.section-description {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
  padding: var(--space-8) 0;
  background-color: var(--color-gray-900);
  color: var(--color-gray-300);
}

.footer a {
  color: var(--color-gray-300);
}

.footer a:hover {
  color: var(--color-text-inverse);
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-8);
}

.footer-section-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-text-inverse);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-4);
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.footer-bottom {
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-gray-700);
  text-align: center;
  font-size: var(--text-sm);
}

/* Minimal footer */
.footer-minimal {
  padding: var(--space-4) 0;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  border-top: 1px solid var(--color-border-light);
  background-color: var(--color-background);
}

/* Footer responsive */
@media (max-width: 768px) {
  .footer-content {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .footer-minimal .d-flex.justify-between {
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    text-align: center;
  }
}

@media (max-width: 480px) {
  .footer {
    padding: var(--space-6) 0;
  }

  .footer-minimal {
    padding: var(--space-3) 0;
  }
}

/* ============================================
   GRID LAYOUTS
   Bootstrap 4 grid is used — no custom re-declarations needed.
   ============================================ */

/* ============================================
   STATS / METRICS
   ============================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.stat-card {
  padding: var(--space-5);
  background-color: var(--surface-base);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
}

.stat-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-1);
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  margin-top: var(--space-2);
}

.stat-change.positive {
  color: var(--color-success);
}

.stat-change.negative {
  color: var(--color-danger);
}

/* ============================================
   AUTH LAYOUT
   ============================================ */

.auth-layout {
  display: flex;
  min-height: 100vh;
}

.auth-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.auth-logo {
  height: 3rem;
  margin-bottom: var(--space-4);
}

.auth-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-2);
}

.auth-subtitle {
  color: var(--color-text-secondary);
}

.auth-side {
  display: none;
  flex: 1;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  padding: var(--space-8);
  color: var(--color-text-inverse);
}

@media (min-width: 1024px) {
  .auth-side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
}

/* ============================================
   CENTERED CONTENT
   ============================================ */

.center-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-6);
  text-align: center;
}

/* ============================================
   RESPONSIVE — PAGE HEADER
   ============================================ */

@media (max-width: 768px) {
  .page-header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .hero {
    padding: var(--space-10) 0;
  }

  .hero-title {
    font-size: var(--text-3xl);
  }

  .hero-subtitle {
    font-size: var(--text-base);
  }

  .hero-actions {
    flex-direction: column;
    width: 100%;
  }

  .hero-compact {
    padding: var(--space-6) 0;
  }

  .hero-compact .hero-title {
    font-size: var(--text-2xl);
  }

  .section {
    padding: var(--space-8) 0;
  }

  .section-title {
    font-size: var(--text-2xl);
  }

  .section-description {
    font-size: var(--text-base);
  }
}

@media (max-width: 480px) {
  .hero {
    padding: var(--space-8) 0;
  }

  .hero-title {
    font-size: var(--text-2xl);
  }

  .section {
    padding: var(--space-6) 0;
  }

  .section-title {
    font-size: var(--text-xl);
  }
}

