/* ==========================================
   EXAMINEXUS - UNIFIED DESIGN SYSTEM
   Inspired by Google, Udemy & Coursera
   ========================================== */

:root {
  /* Brand Colors */
  --brand-violet: #655596;
  --brand-green: #34B34A;
  --brand-illusion: #CAD4DE;
  
  /* Light Mode Colors */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F8F9FA;
  --bg-tertiary: #F1F3F5;
  --surface: #FFFFFF;
  --surface-hover: #F8F9FA;
  
  --text-primary: #1A1A1A;
  --text-secondary: #4A5568;
  --text-tertiary: #718096;
  --text-inverse: #FFFFFF;
  
  --border-light: #E2E8F0;
  --border-medium: #CBD5E0;
  --border-dark: #A0AEC0;
  
  --accent-primary: var(--brand-violet);
  --accent-secondary: var(--brand-green);
  --accent-hover: #534778;
  --accent-light: rgba(101, 85, 150, 0.1);

  /* Backwards-compatible aliases used in some page styles */
  --primary-color: var(--accent-primary);
  --primary-color-hover: var(--accent-hover);
  --text-on-primary: var(--text-inverse);
  
  --success: #10B981;
  --success-light: #D1FAE5;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --error: #EF4444;
  --error-light: #FEE2E2;
  --info: #3B82F6;
  --info-light: #DBEAFE;
  
  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* Spacing Scale (8px base) */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  
  /* Border Radius */
  --radius-sm: 0.375rem;  /* 6px */
  --radius-md: 0.5rem;    /* 8px */
  --radius-lg: 0.75rem;   /* 12px */
  --radius-xl: 1rem;      /* 16px */
  --radius-2xl: 1.5rem;   /* 24px */
  --radius-full: 9999px;

  /* Site-level measurements */
  --site-header-height: 80px; /* matches .header-inner min-height */
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Z-index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* Dark Mode */
[data-theme="dark"] {
  --bg-primary: #0F172A;
  --bg-secondary: #1E293B;
  --bg-tertiary: #334155;
  --surface: #1E293B;
  --surface-hover: #334155;
  
  --text-primary: #F8FAFC;
  --text-secondary: #CBD5E0;
  --text-tertiary: #94A3B8;
  --text-inverse: #0F172A;
  
  --border-light: #334155;
  --border-medium: #475569;
  --border-dark: #64748B;
  
  --accent-primary: #8B7AB8;
  --accent-hover: #A294C9;
  --accent-light: rgba(139, 122, 184, 0.15);
  
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
}

/* Ensure html/body pick up dark background when theme set */
[data-theme="dark"] html,
[data-theme="dark"] body {
  background: var(--bg-primary) !important;
  color: var(--text-primary) !important;
}

/* ==========================================
   BASE RESET & TYPOGRAPHY
   ========================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-base), color var(--transition-base);
}

/* Typography Scale */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.25rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-hover);
}

/* ==========================================
   LAYOUT COMPONENTS
   ========================================== */

.container {
  width: 100%;
  margin: 0 auto;
}

.container-narrow {
  max-width: 960px;
}

.container-wide {
  max-width: 1440px;
}

main {
  flex: 1 0 auto;
  width: 100%;
}

/* Section */
.section {
  padding: var(--space-16);
}

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

.section-lg {
  padding: clamp(4rem, 10vw, 8rem);
}

/* Grid System */
.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .grid-cols-4,
  .grid-cols-3,
  .grid-cols-2 { grid-template-columns: 1fr; }
}

/* Flex Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* ==========================================
   HEADER & NAVIGATION
   ========================================== */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  transition: all var(--transition-base);
}

.site-header.scrolled {
  box-shadow: var(--shadow-md);
}
section[id] {
  /* Set the margin-top equal to the height of your fixed header/nav bar */
  scroll-margin-top: 80px; /* Adjust 80px to your navigation's actual height */
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  max-width: 1440px;
  margin: 0 auto;
  min-height: 70px;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--accent-primary);
  transition: transform var(--transition-fast);
}

.brand:hover {
  transform: scale(1.02);
}

.logo {
  height: 48px;
  width: auto;
}

.nav {
  display: flex;
  gap: var(--space-6);
  align-items: center;
  flex-wrap: nowrap;
  min-height: 48px; /* Fixed height for stability */
}

.nav .nav-link:last-of-type {
  margin-right: var(--space-2);
}

/* Auth UI Container */
.auth-ui {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: var(--space-4);
  min-width: 160px; /* Fixed width to prevent layout shifts */
}

/* Auth UI Skeleton Loader */
.auth-ui.skeleton {
  pointer-events: none;
}

.auth-ui.skeleton .user-menu-trigger {
  background: linear-gradient(90deg, var(--surface-hover) 25%, var(--bg-tertiary) 50%, var(--surface-hover) 75%);
  background-size: 200% 100%;
  animation: auth-skeleton-loading 1.5s ease-in-out infinite;
  border-color: transparent;
  cursor: default;
}

.auth-ui.skeleton .user-avatar,
.auth-ui.skeleton .user-avatar-initials,
.auth-ui.skeleton .user-name,
.auth-ui.skeleton svg {
  opacity: 0;
}

@keyframes auth-skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.nav-link {
  position: relative;
  font-weight: 500;
  color: var(--text-secondary);
  padding: var(--space-2) 0;
  transition: color var(--transition-fast);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent-primary);
  transition: width var(--transition-base);
}

.nav-link:hover,
.nav-link.active {
  color: var(--accent-primary);
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

/* Theme Toggle */
.theme-toggle {
  width: 40px;
  height: 40px;
  min-width: 40px; /* Fixed size */
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  margin-right: auto; /* Push auth UI to the right */
}

.theme-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--accent-primary);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  color: var(--text-primary);
}

/* Mobile Menu */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 28px;
  height: 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}

.hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition-base);
}

.hamburger[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(9px) rotate(45deg);
}

.hamburger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.hamburger[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-9px) rotate(-45deg);
}

@media (max-width: 768px) {
  .hamburger { display: flex; }
  
  .nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 80%;
    max-width: 320px;
    height: 100vh;
    background: var(--surface);
    flex-direction: column;
    align-items: flex-start;
    padding: 5rem var(--space-6) var(--space-6);
    box-shadow: var(--shadow-xl);
    transition: right var(--transition-base);
    z-index: var(--z-fixed);
    overflow-y: auto;
  }
  
  .nav.active {
    right: 0;
  }
  
  .nav-link {
    width: 100%;
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 1.1rem;
  }
  
  .nav-link:last-child {
    border-bottom: none;
  }
  
  .nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
     z-index: calc(var(--z-fixed) - 30);
  }
  
  .nav-overlay.active {
    opacity: 1;
    visibility: visible;
  }
}

/* ==========================================
   CARD COMPONENT
   ========================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
  border-color: var(--accent-light);
}

.card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.card-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: var(--space-4);
  flex: 1;
}

.card-footer {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: auto;
}

/* ==========================================
   BUTTONS
   ========================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: var(--text-inverse);
}

.btn-secondary {
  background: var(--accent-secondary);
  color: var(--text-inverse);
}

.btn-secondary:hover {
  background: #2a8f3d;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--accent-primary);
  color: var(--accent-primary);
}

.btn-outline:hover {
  background: var(--accent-primary);
  color: var(--text-inverse);
}

.btn-ghost {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: var(--accent-primary);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ==========================================
   BADGES
   ========================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-primary {
  background: var(--accent-light);
  color: var(--accent-primary);
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-error {
  background: var(--error-light);
  color: var(--error);
}

.badge-info {
  background: var(--info-light);
  color: var(--info);
}

/* ==========================================
   FORM ELEMENTS
   ========================================== */

.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  font-size: 0.95rem;
}

.form-input,
.form-select,
.form-textarea,
.form-control,
input.form-control,
select.form-control,
textarea.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
  transition: all var(--transition-fast);
  line-height: 1.5;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.form-control:focus,
input.form-control:focus,
select.form-control:focus,
textarea.form-control:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--bg-primary);
}

.form-input::placeholder,
.form-control::placeholder,
input.form-control::placeholder {
  color: var(--text-tertiary);
  opacity: 1;
}

.form-input:disabled,
.form-control:disabled {
  background: var(--bg-tertiary);
  cursor: not-allowed;
  opacity: 0.7;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
}

fieldset {
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

legend {
  font-weight: 700;
  color: var(--accent-primary);
  padding: 0 var(--space-2);
  font-size: 1.1rem;
}

/* Radio & Checkbox */
.radio-option,
.checkbox-option {
  display: flex;
  align-items: center;
  padding: var(--space-4);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--surface);
}

.radio-option:hover,
.checkbox-option:hover {
  border-color: var(--accent-primary);
  background: var(--accent-light);
}

.radio-option input[type="radio"],
.checkbox-option input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  margin-right: var(--space-3);
  accent-color: var(--accent-primary);
  cursor: pointer;
}

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

.site-footer {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  padding: var(--space-6) 0;
  margin-top: auto;
}

.footer-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  color: var(--text-secondary);
}

.footer-left,
.footer-center,
.footer-right {
  display: flex;
  align-items: center;
  justify-content: center;
}

.footer-left p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.footer-center {
  display: flex;
  gap: var(--space-4);
}

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  background: var(--bg-secondary);
  transition: all var(--transition-base);
  text-decoration: none;
}

.social-link:hover {
  color: var(--accent-primary);
  background: var(--accent-light);
  transform: translateY(-2px);
}

.footer-links {
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color var(--transition-base);
}

.footer-links a:hover {
  color: var(--accent-primary);
}

/* Desktop Layout: Left | Center | Right */
@media (min-width: 1024px) {
  .footer-content {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  
  .footer-left {
    flex: 1;
    justify-content: flex-start;
  }
  
  .footer-center {
    flex: 0 0 auto;
  }
  
  .footer-right {
    flex: 1;
    justify-content: flex-end;
  }
}

/* ==========================================
   MODAL
   ========================================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 1;
  transition: opacity var(--transition-base);
}

.modal.hidden {
  display: none;
  opacity: 0;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--surface-hover);
}

.modal-body {
  margin-bottom: var(--space-6);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }

/* Spacing */
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

/* Loading */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Hide/Show */
.hidden { display: none !important; }
.visible { display: block !important; }

@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}

/* ==========================================================================
   AUTHENTICATION UI
   ========================================== */

.auth-ui {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: var(--space-4);
  min-width: 180px; /* Fixed width to prevent layout shift */
  flex-shrink: 0;
  justify-content: flex-end;
}

/* Sign In Button in Auth UI */
.auth-ui .btn {
  white-space: nowrap;
  min-width: 90px;
}

/* User Menu */
.user-menu {
  position: relative;
  flex-shrink: 0;
  min-width: 160px; /* Fixed width to prevent shifts */
}

/* Auth UI Container - Smooth transitions */
.auth-ui {
  transition: opacity 0.2s ease-in-out;
  will-change: opacity;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
  will-change: background-color, border-color;
}

.user-menu-trigger:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-primary);
}

.user-avatar-initials {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  user-select: none;
}

/* Avatar Utility Styles */
.avatar-image {
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-color);
}

.avatar-initials {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  user-select: none;
  flex-shrink: 0;
}

/* Avatar skeleton shown while the avatar image is loading */
.avatar-skeleton {
  display: inline-block;
  background: linear-gradient(90deg, var(--surface-hover), var(--accent-light));
  animation: skeleton-pulse 1.2s ease-in-out infinite;
  border-radius: 50%;
  flex-shrink: 0;
}

.avatar-image {
  display: inline-block;
  vertical-align: middle;
  object-fit: cover;
}

.user-name {
  font-weight: 500;
  color: var(--text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-trigger svg {
  color: var(--text-tertiary);
  transition: transform var(--transition-fast);
}

.user-menu-trigger:hover svg {
  transform: translateY(2px);
}

/* Dropdown */
.user-menu-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-fast);
  z-index: var(--z-dropdown);
}

.user-menu-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.unverified-auth-ui {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.unverified-auth-text {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #1d4ed8;
}

.unverified-auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.unverified-auth-actions .btn {
  padding: 6px 14px;
}

.unverified-auth-actions .btn-link {
  color: #1f2937;
  padding-left: 0;
  padding-right: 0;
}

@media (max-width: 768px) {
  .unverified-auth-ui {
    flex-direction: column;
    align-items: flex-start;
    border-radius: 12px;
  }

  .unverified-auth-actions {
    width: 100%;
  }

  .unverified-auth-actions .btn {
    width: 100%;
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: var(--text-secondary);
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.dropdown-item svg {
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.dropdown-item:hover svg {
  color: var(--accent-primary);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--space-2) 0;
}

/* Mobile Auth UI */
@media (max-width: 768px) {
  .theme-toggle {
    margin-right: 0;
    order: -1;
  }

  .auth-ui {
    margin-left: 0;
    width: 100%;
    min-width: 100%;
    justify-content: stretch;
    flex-direction: column;
    padding: 0;
  }

  .auth-ui .btn {
    width: 100%;
  }

  .user-menu {
    width: 100%;
    min-width: 100%;
  }

  .user-menu-trigger {
    width: 100%;
    justify-content: space-between;
  }

  .user-name {
    max-width: none;
  }

  .user-menu-dropdown {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    margin-top: var(--space-2);
    display: none;
  }

  .user-menu-dropdown.active {
    display: block;
  }
}

/* ==========================================
   ALERTS & NOTIFICATIONS
   ========================================== */

.alert {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: 0.95rem;
  line-height: 1.5;
}

.alert-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success);
}

.alert-error {
  background: var(--error-light);
  color: var(--error);
  border: 1px solid var(--error);
}

.alert-warning {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.alert-info {
  background: var(--info-light);
  color: var(--info);
  border: 1px solid var(--info);
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  min-width: 300px;
  max-width: 500px;
  padding: var(--space-4);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-tooltip);
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}