@font-face {
  font-family: 'Atacama';
  src: url('/public/fonts/AtacamaTrial-VF.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Hellix';
  src: url('/public/fonts/Hellix.woff') format('woff'),
       url('/public/fonts/Hellix.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Global font defaults */
* {
  font-family: 'Hellix', sans-serif;
}

/* Atacama for headings, Hellix for body */
h1, h2, h3, .page-title, .section-title, .stat-value, .card-title {
  font-family: 'Atacama', serif !important;
  font-weight: 400;
}

/**
 * Admin Sidebar Styles
 * Shared CSS for consistent sidebar across all admin pages
 */

/* Hide menu items by default until JS filters them - prevents flash */
.sidebar:not(.filtered) .menu-item[data-page]:not([data-page="home"]) {
  display: none;
}
.sidebar:not(.filtered) .menu-section {
  display: none;
}

/* Mobile menu button - hidden by default, shown on mobile */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 1001;
}

.mobile-menu-btn span {
  display: block;
  width: 24px;
  height: 2px;
  background: #333;
  margin: 5px 0;
}

/* Sidebar Layout - Fixed dimensions */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: 260px;
  background: #fff;
  border-right: 1px solid #e5e5e5;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
  z-index: 100;
  font-family: 'Hellix', sans-serif;
}

.sidebar.collapsed {
  width: 72px;
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  padding: 20px 16px;
  border-bottom: 1px solid #e5e5e5;
  gap: 12px;
  position: relative;
  min-height: 72px;
}

.sidebar-logo {
  height: 40px;
  width: auto;
  flex-shrink: 0;
  object-fit: contain;
  flex: 1;
}

.sidebar-title {
  display: none;
}

/* Mobile close button - hidden on desktop */
.sidebar-close-mobile {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: #999;
  border-radius: 6px;
  flex-shrink: 0;
}

.sidebar-close-mobile:hover {
  background: #f5f5f5;
  color: #333;
}

.sidebar.collapsed .sidebar-logo {
  height: 22px;
}

.sidebar-toggle {
  position: absolute;
  right: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: all 0.2s;
  z-index: 1001;
}

.sidebar-toggle:hover {
  background: #f5f5f5;
  border-color: #CD9668;
  color: #CD9668;
}

.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

/* Sidebar Menu */
.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

/* ===== Accordion Section Toggle ===== */
.menu-section {
  margin-bottom: 2px;
}

.section-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 11px 14px;
  gap: 12px;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: #555;
  font-size: 14px;
  font-weight: 500;
  text-align: start;
  transition: all 0.2s;
  position: relative;
}

.section-toggle:hover {
  background: #f5f5f5;
  color: #333;
}

.section-toggle .menu-icon {
  width: 20px;
  height: 20px;
  min-width: 20px;
}

.section-toggle .menu-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
}

/* Chevron arrow */
.section-chevron {
  width: 16px;
  height: 16px;
  min-width: 16px;
  flex-shrink: 0;
  stroke: #999;
  transition: transform 0.25s ease;
}

.menu-section.open .section-chevron {
  transform: rotate(180deg);
}

/* Section items container */
.section-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  background: #f9f9f9;
  border-radius: 8px;
  margin: 0 4px 2px 4px;
}

.menu-section.open .section-items {
  max-height: 500px;
}

/* Items inside sections - no icon, indented */
.section-items .menu-item {
  display: flex;
  align-items: center;
  padding: 10px 16px 10px 48px;
  gap: 0;
  text-decoration: none;
  color: #555;
  border-radius: 0;
  margin-bottom: 0;
  transition: all 0.2s;
  position: relative;
  font-size: 13.5px;
}

.section-items .menu-item:first-child {
  border-radius: 8px 8px 0 0;
  padding-top: 12px;
}

.section-items .menu-item:last-child {
  border-radius: 0 0 8px 8px;
  padding-bottom: 12px;
}

.section-items .menu-item:only-child {
  border-radius: 8px;
}

.section-items .menu-item:hover {
  background: #f0f0f0;
  color: #333;
}

.section-items .menu-item.active {
  background: #F4EDE1;
  color: #CD9668;
  font-weight: 500;
}

/* Section toggle active state (when a child is active) */
.menu-section.has-active > .section-toggle {
  color: #CD9668;
}

.menu-section.has-active > .section-toggle .menu-icon {
  stroke: #CD9668;
}

/* ===== Top-level Menu Item (Home, Guide) ===== */
.menu-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  gap: 12px;
  text-decoration: none;
  color: #555;
  border-radius: 8px;
  margin-bottom: 2px;
  transition: all 0.2s;
  position: relative;
}

.menu-item:hover {
  background: #f5f5f5;
  color: #333;
}

.menu-item.active {
  background: #F4EDE1;
  color: #CD9668;
  border: 1.5px solid #CD9668;
}

.menu-item.active .menu-icon {
  stroke: #CD9668;
}

/* Menu Icon */
.menu-icon {
  width: 22px;
  height: 22px;
  min-width: 22px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* Menu Text */
.menu-text {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  flex: 1;
}

/* Collapsed sidebar */
.sidebar.collapsed .menu-text {
  display: none;
}

.sidebar.collapsed .section-chevron {
  display: none;
}

.sidebar.collapsed .menu-item {
  justify-content: center;
  padding: 12px;
}

.sidebar.collapsed .section-toggle {
  justify-content: center;
  padding: 12px;
}

.sidebar.collapsed .section-items {
  display: none;
}

/* Super Badge */
.super-badge, .super-admin-badge {
  background: #CD9668;
  color: #fff;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar.collapsed .super-badge {
  display: none;
}

[dir="rtl"] .super-badge, [dir="rtl"] .super-admin-badge {
  /* no position override needed, flows naturally */
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid #e5e5e5;
}

.footer-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  height: 44px;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  gap: 12px;
  color: #666;
  transition: all 0.2s;
}

.footer-btn:hover {
  background: #f5f5f5;
}

.sidebar.collapsed .footer-btn {
  justify-content: center;
  padding: 12px;
}

.sidebar.collapsed .footer-btn .menu-text {
  display: none;
}

/* Main content offset */
.main-wrapper {
  margin-left: 260px;
  min-height: 100vh;
  transition: margin-left 0.3s ease, margin-right 0.3s ease, width 0.3s ease;
  width: calc(100% - 260px);
  box-sizing: border-box;
  overflow-x: hidden;
}

.sidebar.collapsed ~ .main-wrapper,
.main-wrapper.sidebar-collapsed {
  margin-left: 72px;
  width: calc(100% - 72px);
}

/* Main header - shared styles */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid #eee;
  min-height: 56px;
  box-sizing: border-box;
  width: 100%;
}

.main-header-title {
  font-size: 20px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar overlay - hidden by default */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

.sidebar-overlay.active {
  display: block;
}

/* Mobile Styles */
@media (max-width: 1024px) {
  .sidebar,
  .sidebar.collapsed {
    display: none !important;
    position: fixed !important;
    width: 280px !important;
    z-index: 1000 !important;
  }

  .sidebar.mobile-open,
  .sidebar.collapsed.mobile-open {
    display: flex !important;
    width: 280px !important;
    left: 0 !important;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  }

  .main-wrapper {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  .sidebar.collapsed ~ .main-wrapper {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
  }

  .main-wrapper .main {
    box-sizing: border-box;
    max-width: 100% !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .sidebar-toggle {
    display: none !important;
  }

  .mobile-menu-btn {
    display: block !important;
  }

  .sidebar-close-mobile {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  .sidebar.collapsed .menu-text,
  .sidebar.collapsed .super-badge {
    display: block !important;
  }

  .sidebar.collapsed .section-chevron {
    display: block !important;
  }

  .sidebar.collapsed .section-items {
    display: block !important;
  }

  .sidebar.collapsed .sidebar-logo {
    height: 28px !important;
  }

  .sidebar.collapsed .menu-item {
    justify-content: flex-start !important;
    padding: 12px 14px !important;
  }

  .sidebar.collapsed .section-toggle {
    justify-content: flex-start !important;
    padding: 11px 14px !important;
  }

  .sidebar.collapsed .footer-btn {
    justify-content: flex-start !important;
    padding: 10px 14px !important;
  }

  .sidebar.collapsed .footer-btn .menu-text {
    display: block !important;
  }
}

/* RTL Support */
[dir="rtl"] .sidebar {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid #e5e5e5;
}

[dir="rtl"] .sidebar-toggle {
  right: auto;
  left: -14px;
}

[dir="rtl"] .sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(0deg);
}

[dir="rtl"] .sidebar-toggle svg {
  transform: rotate(180deg);
}

[dir="rtl"] .main-wrapper {
  margin-left: 0;
  margin-right: 260px;
  width: calc(100% - 260px);
}

[dir="rtl"] .sidebar.collapsed ~ .main-wrapper,
[dir="rtl"] .main-wrapper.sidebar-collapsed {
  margin-right: 72px;
  width: calc(100% - 72px);
}

[dir="rtl"] .section-items .menu-item {
  padding-left: 16px;
  padding-right: 48px;
}

@media (max-width: 1024px) {
  [dir="rtl"] .sidebar.mobile-open,
  [dir="rtl"] .sidebar.collapsed.mobile-open {
    left: auto !important;
    right: 0 !important;
  }

  [dir="rtl"] .main-wrapper {
    margin-right: 0 !important;
    margin-left: 0 !important;
    width: 100% !important;
  }

  [dir="rtl"] .sidebar.collapsed ~ .main-wrapper {
    margin-right: 0 !important;
    margin-left: 0 !important;
    width: 100% !important;
  }

  [dir="rtl"] .mobile-menu-btn {
    left: auto;
    right: 16px;
  }

  [dir="rtl"] .sidebar-close-mobile {
    margin-left: 0;
    margin-right: auto;
  }
}
