/**
 * CampusQCM Design System
 * Composants UI réutilisables - Premium SaaS Style
 * 
 * @package CampusQCM
 * @version 2.0.0
 */

/* ========================================
   MOBILE-FIRST CRITICAL RULES
   Touch targets, overflow prevention, accessibility
======================================== */

/* Prevent horizontal overflow globally */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Prevent text size adjustment on orientation change */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Account for sticky header when using scrollIntoView / anchor links */
  scroll-padding-top: calc(var(--cq-header-height, 72px) + 16px);
}

/* Ensure images don't overflow */
img, video, iframe, embed, object {
  max-width: 100%;
  height: auto;
}

/* Minimum touch target 48px (Google recommendation) */
a:not(.inline-link), 
button, 
.btn, 
input[type="submit"], 
input[type="button"],
.qcm-option, 
.qcm-mode-card, 
.correction-filter,
.nav-link, 
.auth-link, 
.cta-btn,
[role="button"] {
  min-height: 44px;
}

/* Improve tap highlight for mobile */
a, button, input, select, textarea {
  -webkit-tap-highlight-color: rgba(99, 102, 241, 0.15);
}

/* Focus visible for keyboard navigation (accessibility) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--cq-primary, #6366f1);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ========================================
   GLOBAL FIXES
======================================== */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 120px; /* Header (88px) + admin bar (32px) + margin */
}

/* ========================================
   DESIGN TOKENS
======================================== */
:root {
  /* Couleurs principales */
  --cq-primary: #6366f1;
  --cq-primary-light: #818cf8;
  --cq-primary-dark: #4f46e5;
  --cq-primary-subtle: #eef2ff;
  
  /* Couleurs sémantiques */
  --cq-success: #10b981;
  --cq-success-light: #d1fae5;
  --cq-success-dark: #059669;
  --cq-warning: #f59e0b;
  --cq-warning-light: #fef3c7;
  --cq-warning-dark: #d97706;
  --cq-error: #ef4444;
  --cq-error-light: #fee2e2;
  --cq-info: #3b82f6;
  --cq-info-light: #dbeafe;
  --cq-rose: #f43f5e;
  --cq-rose-dark: #e11d48;
  --cq-rose-light: #ffe4e6;
  
  /* Neutres (mode clair) */
  --cq-bg: #f8fafc;
  --cq-surface: #ffffff;
  --cq-border: #e2e8f0;
  --cq-text: #1e293b;
  --cq-text-secondary: #64748b;
  --cq-text-muted: #94a3b8;
  
  /* Typographie */
  --cq-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --cq-font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  /* Tailles de police */
  --cq-text-xs: 0.75rem;    /* 12px */
  --cq-text-sm: 0.875rem;   /* 14px */
  --cq-text-base: 1rem;     /* 16px */
  --cq-text-lg: 1.125rem;   /* 18px */
  --cq-text-xl: 1.25rem;    /* 20px */
  --cq-text-2xl: 1.5rem;    /* 24px */
  --cq-text-3xl: 1.875rem;  /* 30px */
  --cq-text-4xl: 2.25rem;   /* 36px */
  
  /* Espacements */
  --cq-space-1: 0.25rem;
  --cq-space-2: 0.5rem;
  --cq-space-3: 0.75rem;
  --cq-space-4: 1rem;
  --cq-space-5: 1.25rem;
  --cq-space-6: 1.5rem;
  --cq-space-8: 2rem;
  --cq-space-10: 2.5rem;
  --cq-space-12: 3rem;
  --cq-space-16: 4rem;
  
  /* Rayons */
  --cq-radius-sm: 4px;
  --cq-radius-md: 8px;
  --cq-radius-lg: 12px;
  --cq-radius-xl: 16px;
  --cq-radius-full: 9999px;
  
  /* Ombres */
  --cq-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --cq-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --cq-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --cq-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  
  /* Transitions */
  --cq-transition-fast: 150ms ease;
  --cq-transition-base: 200ms ease;
  --cq-transition-slow: 300ms ease;
}

/* Mode sombre — Palette harmonisée avec global-typography.css */
body.qcm-dark,
[data-theme="dark"], 
.dark-mode {
  --cq-bg: #0f172a;
  --cq-surface: #1e293b;
  --cq-card-bg: #1f2937;
  --cq-border: #374151;
  --cq-border-light: #475569;
  --cq-text: #f1f5f9;
  --cq-text-secondary: #94a3b8;
  --cq-text-muted: #64748b;
  --cq-primary-subtle: rgba(99, 102, 241, 0.15);
  
  /* Ombres pour mode sombre */
  --cq-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --cq-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --cq-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --cq-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

/* ========================================
   LAYOUT
======================================== */
.cq-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--cq-space-4);
}

.cq-container--sm { max-width: 640px; }
.cq-container--md { max-width: 768px; }
.cq-container--lg { max-width: 1024px; }
.cq-container--xl { max-width: 1280px; }

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

.cq-grid {
  display: grid;
  gap: var(--cq-space-6);
}

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

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

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

.cq-flex--center { align-items: center; justify-content: center; }
.cq-flex--between { justify-content: space-between; }
.cq-flex--wrap { flex-wrap: wrap; }

/* ========================================
   TYPOGRAPHY
======================================== */
.cq-h1 {
  font-size: var(--cq-text-4xl);
  font-weight: 800;
  line-height: 1.2;
  color: var(--cq-text);
  margin: 0 0 var(--cq-space-4);
}

.cq-h2 {
  font-size: var(--cq-text-2xl);
  font-weight: 700;
  line-height: 1.3;
  color: var(--cq-text);
  margin: 0 0 var(--cq-space-3);
}

.cq-h3 {
  font-size: var(--cq-text-xl);
  font-weight: 600;
  line-height: 1.4;
  color: var(--cq-text);
  margin: 0 0 var(--cq-space-2);
}

.cq-h4 {
  font-size: var(--cq-text-lg);
  font-weight: 600;
  line-height: 1.4;
  color: var(--cq-text);
  margin: 0 0 var(--cq-space-2);
}

.cq-text-muted { color: var(--cq-text-muted); }
.cq-text-secondary { color: var(--cq-text-secondary); }
.cq-text-primary { color: var(--cq-primary); }
.cq-text-success { color: var(--cq-success); }
.cq-text-warning { color: var(--cq-warning); }
.cq-text-error { color: var(--cq-error); }

.cq-lead {
  font-size: var(--cq-text-lg);
  color: var(--cq-text-secondary);
  line-height: 1.6;
}

/* ========================================
   BUTTONS
======================================== */
.cq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--cq-space-2);
  padding: var(--cq-space-3) var(--cq-space-5);
  font-size: var(--cq-text-sm);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  border: none;
  border-radius: var(--cq-radius-md);
  cursor: pointer;
  transition: all var(--cq-transition-fast);
  white-space: nowrap;
}

.cq-btn:focus {
  outline: 2px solid var(--cq-primary);
  outline-offset: 2px;
}

.cq-btn--primary {
  background: var(--cq-primary);
  color: white;
}

.cq-btn--primary:hover {
  background: var(--cq-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--cq-shadow-md);
}

.cq-btn--secondary {
  background: var(--cq-surface);
  color: var(--cq-text);
  border: 1px solid var(--cq-border);
}

.cq-btn--secondary:hover {
  background: var(--cq-bg);
  border-color: var(--cq-primary);
}

.cq-btn--ghost {
  background: transparent;
  color: var(--cq-text-secondary);
}

.cq-btn--ghost:hover {
  background: var(--cq-primary-subtle);
  color: var(--cq-primary);
}

.cq-btn--success {
  background: var(--cq-success);
  color: white;
}

.cq-btn--danger {
  background: var(--cq-error);
  color: white;
}

.cq-btn--sm {
  padding: var(--cq-space-2) var(--cq-space-3);
  font-size: var(--cq-text-xs);
}

.cq-btn--lg {
  padding: var(--cq-space-4) var(--cq-space-8);
  font-size: var(--cq-text-base);
}

.cq-btn--block {
  width: 100%;
}

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

/* ========================================
   CARDS
======================================== */
.cq-card {
  background: var(--cq-surface);
  border: 1px solid var(--cq-border);
  border-radius: var(--cq-radius-lg);
  padding: var(--cq-space-6);
  transition: all var(--cq-transition-base);
}

.cq-card--hover:hover {
  border-color: var(--cq-primary);
  box-shadow: var(--cq-shadow-lg);
  transform: translateY(-2px);
}

.cq-card--clickable {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.cq-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--cq-space-4);
}

.cq-card__title {
  font-size: var(--cq-text-lg);
  font-weight: 600;
  margin: 0;
}

.cq-card__body {
  color: var(--cq-text-secondary);
}

.cq-card__footer {
  margin-top: var(--cq-space-4);
  padding-top: var(--cq-space-4);
  border-top: 1px solid var(--cq-border);
}

.cq-card__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--cq-radius-lg);
  background: var(--cq-primary-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--cq-text-2xl);
  color: var(--cq-primary);
  flex-shrink: 0;
}

/* ========================================
   BADGES
======================================== */
.cq-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--cq-space-1);
  padding: var(--cq-space-1) var(--cq-space-2);
  font-size: var(--cq-text-xs);
  font-weight: 600;
  border-radius: var(--cq-radius-full);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.cq-badge--primary {
  background: var(--cq-primary-subtle);
  color: var(--cq-primary);
}

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

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

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

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

.cq-badge--neutral {
  background: var(--cq-bg);
  color: var(--cq-text-secondary);
}

/* ========================================
   ALERTS
======================================== */
.cq-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--cq-space-3);
  padding: var(--cq-space-4);
  border-radius: var(--cq-radius-lg);
  border: 1px solid;
}

.cq-alert__icon {
  font-size: var(--cq-text-xl);
  flex-shrink: 0;
}

.cq-alert__content {
  flex: 1;
}

.cq-alert__title {
  font-weight: 600;
  margin-bottom: var(--cq-space-1);
}

.cq-alert--info {
  background: var(--cq-info-light);
  border-color: var(--cq-info);
  color: var(--cq-info);
}

.cq-alert--success {
  background: var(--cq-success-light);
  border-color: var(--cq-success);
  color: var(--cq-success);
}

.cq-alert--warning {
  background: var(--cq-warning-light);
  border-color: var(--cq-warning);
  color: #92400e;
}

.cq-alert--error {
  background: var(--cq-error-light);
  border-color: var(--cq-error);
  color: var(--cq-error);
}

/* ========================================
   EMPTY STATES
======================================== */
.cq-empty {
  text-align: center;
  padding: var(--cq-space-12) var(--cq-space-6);
  background: var(--cq-surface);
  border: 2px dashed var(--cq-border);
  border-radius: var(--cq-radius-xl);
}

.cq-empty__icon {
  font-size: 3rem;
  margin-bottom: var(--cq-space-4);
  opacity: 0.5;
}

.cq-empty__title {
  font-size: var(--cq-text-xl);
  font-weight: 600;
  margin-bottom: var(--cq-space-2);
  color: var(--cq-text);
}

.cq-empty__text {
  color: var(--cq-text-secondary);
  max-width: 400px;
  margin: 0 auto var(--cq-space-6);
}

/* ========================================
   TABLES
======================================== */
.cq-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--cq-surface);
  border-radius: var(--cq-radius-lg);
  overflow: hidden;
  border: 1px solid var(--cq-border);
}

.cq-table th,
.cq-table td {
  padding: var(--cq-space-4);
  text-align: left;
  border-bottom: 1px solid var(--cq-border);
}

.cq-table th {
  background: var(--cq-bg);
  font-weight: 600;
  font-size: var(--cq-text-sm);
  color: var(--cq-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cq-table tbody tr:hover {
  background: var(--cq-bg);
}

.cq-table tbody tr:last-child td {
  border-bottom: none;
}

/* ========================================
   FORMS
======================================== */
.cq-form-group {
  margin-bottom: var(--cq-space-5);
}

.cq-label {
  display: block;
  font-weight: 500;
  margin-bottom: var(--cq-space-2);
  color: var(--cq-text);
}

.cq-input,
.cq-select,
.cq-textarea {
  width: 100%;
  padding: var(--cq-space-3) var(--cq-space-4);
  font-size: var(--cq-text-base);
  border: 1px solid var(--cq-border);
  border-radius: var(--cq-radius-md);
  background: var(--cq-surface);
  color: var(--cq-text);
  transition: all var(--cq-transition-fast);
}

.cq-input:focus,
.cq-select:focus,
.cq-textarea:focus {
  outline: none;
  border-color: var(--cq-primary);
  box-shadow: 0 0 0 3px var(--cq-primary-subtle);
}

.cq-input::placeholder {
  color: var(--cq-text-muted);
}

.cq-hint {
  font-size: var(--cq-text-sm);
  color: var(--cq-text-muted);
  margin-top: var(--cq-space-2);
}

/* ========================================
   PROGRESS BARS
======================================== */
.cq-progress {
  height: 8px;
  background: var(--cq-bg);
  border-radius: var(--cq-radius-full);
  overflow: hidden;
}

.cq-progress__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--cq-primary), var(--cq-primary-light));
  border-radius: var(--cq-radius-full);
  transition: width var(--cq-transition-slow);
}

.cq-progress--lg {
  height: 12px;
}

.cq-progress--success .cq-progress__bar {
  background: linear-gradient(90deg, var(--cq-success), #34d399);
}

/* ========================================
   TABS
======================================== */
.cq-tabs {
  display: flex;
  gap: var(--cq-space-1);
  border-bottom: 1px solid var(--cq-border);
  margin-bottom: var(--cq-space-6);
}

.cq-tab {
  padding: var(--cq-space-3) var(--cq-space-4);
  font-weight: 500;
  color: var(--cq-text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--cq-transition-fast);
  margin-bottom: -1px;
}

.cq-tab:hover {
  color: var(--cq-text);
}

.cq-tab.active {
  color: var(--cq-primary);
  border-bottom-color: var(--cq-primary);
}

/* ========================================
   AVATARS
======================================== */
.cq-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--cq-primary-subtle);
  color: var(--cq-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--cq-text-sm);
  flex-shrink: 0;
}

.cq-avatar--sm { width: 32px; height: 32px; font-size: var(--cq-text-xs); }
.cq-avatar--lg { width: 56px; height: 56px; font-size: var(--cq-text-lg); }
.cq-avatar--xl { width: 80px; height: 80px; font-size: var(--cq-text-2xl); }

/* ========================================
   STATS
======================================== */
.cq-stat {
  text-align: center;
}

.cq-stat__value {
  font-size: var(--cq-text-3xl);
  font-weight: 800;
  color: var(--cq-text);
  line-height: 1;
  margin-bottom: var(--cq-space-1);
}

.cq-stat__label {
  font-size: var(--cq-text-sm);
  color: var(--cq-text-secondary);
}

.cq-stat__trend {
  font-size: var(--cq-text-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--cq-space-1);
  margin-top: var(--cq-space-1);
}

.cq-stat__trend--up { color: var(--cq-success); }
.cq-stat__trend--down { color: var(--cq-error); }

/* ========================================
   LINKS (MAILLAGE INTERNE)
======================================== */
.cq-link-card {
  display: flex;
  align-items: center;
  gap: var(--cq-space-3);
  padding: var(--cq-space-3) var(--cq-space-4);
  background: var(--cq-surface);
  border: 1px solid var(--cq-border);
  border-radius: var(--cq-radius-md);
  text-decoration: none;
  color: inherit;
  transition: all var(--cq-transition-fast);
}

.cq-link-card:hover {
  border-color: var(--cq-primary);
  background: var(--cq-primary-subtle);
}

.cq-link-card__icon {
  font-size: var(--cq-text-xl);
}

.cq-link-card__text {
  flex: 1;
}

.cq-link-card__title {
  font-weight: 600;
  color: var(--cq-text);
}

.cq-link-card__desc {
  font-size: var(--cq-text-sm);
  color: var(--cq-text-secondary);
}

.cq-link-card__arrow {
  color: var(--cq-text-muted);
  transition: transform var(--cq-transition-fast);
}

.cq-link-card:hover .cq-link-card__arrow {
  transform: translateX(4px);
  color: var(--cq-primary);
}

/* ========================================
   NAV HUB — NAVIGATION STRUCTURÉE SEO
   Refonte pilier : 3 sections distinctes
======================================== */
.cq-nav-hub {
  position: relative;
  background: var(--cq-bg-alt, #f8fafc);
  border: 1px solid var(--cq-border, #e2e8f0);
  border-radius: 24px;
  padding: 2.5rem;
  margin-top: 3rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

body.qcm-dark .cq-nav-hub {
  background: var(--cq-bg-alt, #0f172a);
  border-color: var(--cq-border, #334155);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Decorative orbs */
.cq-nav-hub::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.cq-nav-hub::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

/* Section individuelle */
.cq-nav-hub__section {
  position: relative;
  z-index: 1;
}

.cq-nav-hub__section--primary {
  padding-bottom: 2rem;
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.cq-nav-hub__section--user,
.cq-nav-hub__section--cta {
  padding-top: 0.5rem;
  border-top: 1px solid rgba(99, 102, 241, 0.1);
}

/* Titres et descriptions */
.cq-nav-hub__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--cq-text, #1e293b);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cq-nav-hub__title::before {
  content: '';
  width: 4px;
  height: 1.2em;
  background: linear-gradient(180deg, var(--cq-accent, #6366f1) 0%, var(--cq-accent-alt, #8b5cf6) 100%);
  border-radius: 4px;
  flex-shrink: 0;
}

.cq-nav-hub__desc {
  font-size: 0.9375rem;
  color: var(--cq-text-muted, #64748b);
  line-height: 1.6;
  margin-bottom: 1.5rem;
  max-width: 700px;
}

/* Grilles */
.cq-nav-hub__grid {
  display: grid;
  gap: 0.75rem;
}

.cq-nav-hub__grid--4cols {
  grid-template-columns: repeat(4, 1fr);
}

.cq-nav-hub__grid--3cols {
  grid-template-columns: repeat(3, 1fr);
}

.cq-nav-hub__grid--2cols {
  grid-template-columns: repeat(2, 1fr);
  max-width: 400px;
}

.cq-nav-hub__grid--matieres {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

/* Liens */
.cq-nav-hub__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--cq-card-bg, #ffffff);
  border: 1.5px solid var(--cq-border, #e2e8f0);
  color: var(--cq-text, #334155);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9375rem;
  border-radius: 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  position: relative;
  overflow: hidden;
}

.cq-nav-hub__link::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cq-accent, #6366f1) 0%, var(--cq-accent-alt, #8b5cf6) 100%);
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cq-nav-hub__link:hover {
  background: var(--cq-card-bg, #ffffff);
  border-color: rgba(99, 102, 241, 0.4);
  color: var(--cq-accent, #6366f1);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px -4px rgba(99, 102, 241, 0.2), 0 4px 12px rgba(0, 0, 0, 0.08);
}

.cq-nav-hub__link:hover::before {
  opacity: 1;
}

.cq-nav-hub__link:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.cq-nav-hub__link:active {
  transform: translateY(0);
}

/* Variantes de liens */
.cq-nav-hub__link--accent {
  background: linear-gradient(135deg, var(--cq-accent, #6366f1) 0%, var(--cq-accent-alt, #8b5cf6) 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.cq-nav-hub__link--accent::before {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.2) 100%);
}

.cq-nav-hub__link--accent:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  box-shadow: 0 8px 28px -4px rgba(99, 102, 241, 0.4), 0 4px 16px rgba(99, 102, 241, 0.3);
  transform: translateY(-4px);
}

.cq-nav-hub__link--featured {
  border-color: rgba(99, 102, 241, 0.4);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.08) 100%);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.12);
}

.cq-nav-hub__link--ghost {
  background: transparent;
  border: 1px solid rgba(100, 116, 139, 0.2);
}

.cq-nav-hub__link--ghost:hover {
  background: rgba(255, 255, 255, 0.5);
}

.cq-nav-hub__link--app {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.2);
}

.cq-nav-hub__link--app:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #059669;
}

/* Éléments internes */
.cq-nav-hub__icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  line-height: 1;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cq-nav-hub__link:hover .cq-nav-hub__icon {
  transform: scale(1.1);
}

.cq-nav-hub__label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cq-nav-hub__badge {
  font-size: 0.6875rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--cq-accent, #6366f1) 0%, var(--cq-accent-alt, #8b5cf6) 100%);
  color: #ffffff;
  padding: 0.25rem 0.625rem;
  border-radius: 8px;
  position: absolute;
  top: -10px;
  right: 10px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
  z-index: 2;
  letter-spacing: 0.02em;
}

/* Dark mode */
/* Dark mode - déjà défini plus haut */

body.qcm-dark .cq-nav-hub::before {
  background: radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.12) 0%, transparent 60%);
}

body.qcm-dark .cq-nav-hub::after {
  background: radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.08) 0%, transparent 60%);
}

body.qcm-dark .cq-nav-hub__title {
  color: var(--cq-text, #e5e7eb);
}

body.qcm-dark .cq-nav-hub__desc {
  color: #9ca3af;
}

body.qcm-dark .cq-nav-hub__section--primary {
  border-color: rgba(255, 255, 255, 0.08);
}

body.qcm-dark .cq-nav-hub__section--user,
body.qcm-dark .cq-nav-hub__section--cta {
  border-color: rgba(255, 255, 255, 0.08);
}

body.qcm-dark .cq-nav-hub__link {
  background: rgba(26, 29, 38, 0.8);
  border-color: rgba(255, 255, 255, 0.1);
  color: #d1d5db;
}

body.qcm-dark .cq-nav-hub__link:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #818cf8;
}

body.qcm-dark .cq-nav-hub__link--accent {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #ffffff;
}

body.qcm-dark .cq-nav-hub__link--featured {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.3);
}

body.qcm-dark .cq-nav-hub__link--app {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
}

body.qcm-dark .cq-nav-hub__link--app:hover {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

body.qcm-dark .cq-nav-hub__badge {
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
}

/* Responsive */
@media (max-width: 900px) {
  .cq-nav-hub__grid--4cols {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .cq-nav-hub__grid--3cols {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .cq-nav-hub {
    padding: 1.5rem;
    border-radius: 16px;
    gap: 2rem;
  }
  
  .cq-nav-hub__section--primary {
    padding-bottom: 1.5rem;
  }
  
  .cq-nav-hub__grid--4cols {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .cq-nav-hub__grid--3cols {
    grid-template-columns: 1fr 1fr 1fr;
  }
  
  .cq-nav-hub__grid--matieres {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .cq-nav-hub__link {
    padding: 0.75rem 0.875rem;
    font-size: 0.85rem;
  }
  
  .cq-nav-hub__desc {
    font-size: 0.8125rem;
  }
}

@media (max-width: 480px) {
  .cq-nav-hub__grid--4cols {
    grid-template-columns: 1fr 1fr;
  }
  
  .cq-nav-hub__grid--3cols {
    grid-template-columns: 1fr;
  }
  
  .cq-nav-hub__grid--2cols {
    grid-template-columns: 1fr;
    max-width: none;
  }
  
  .cq-nav-hub__grid--matieres {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   INTERNAL LINKS SECTION - PREMIUM DESIGN
   (Legacy - conservé pour compatibilité)
======================================== */
.cq-internal-links {
  position: relative;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--cq-accent, #6366f1) 8%, #f8fafc) 0%,
    color-mix(in srgb, var(--cq-accent-alt, #8b5cf6) 10%, #eef2ff) 100%
  );
  border-radius: 24px;
  padding: 2.5rem;
  margin-top: 3rem;
  overflow: hidden;
}

/* Full width variant - sort de son container */
.cq-internal-links--fullwidth {
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  width: 100vw;
  border-radius: 0;
  padding: 3rem calc(50vw - 50%);
}

/* Subtle decorative gradient orbs */
.cq-internal-links::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, color-mix(in srgb, var(--cq-accent, #6366f1) 8%, transparent) 0%, transparent 70%);
  pointer-events: none;
}

.cq-internal-links::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, color-mix(in srgb, var(--cq-accent-alt, #8b5cf6) 6%, transparent) 0%, transparent 70%);
  pointer-events: none;
}

.cq-internal-links__title {
  position: relative;
  z-index: 1;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: #1e293b;
  text-align: center;
  letter-spacing: -0.02em;
}

.cq-internal-links__title::after {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: linear-gradient(90deg, var(--cq-accent, #6366f1), var(--cq-accent-alt, #8b5cf6));
  border-radius: 2px;
  margin: 0.75rem auto 0;
}

.cq-internal-links__grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.cq-internal-links a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  color: #334155;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: 14px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.cq-internal-links a:hover {
  background: #ffffff;
  border-color: color-mix(in srgb, var(--cq-accent, #6366f1) 30%, transparent);
  color: var(--cq-accent, #6366f1);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--cq-accent, #6366f1) 15%, transparent);
}

.cq-internal-links a:active {
  transform: translateY(-1px);
}

/* Dark mode */
body.qcm-dark .cq-internal-links {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--cq-accent, #6366f1) 12%, #1a1d26) 0%,
    color-mix(in srgb, var(--cq-accent-alt, #8b5cf6) 10%, #161922) 100%
  );
}

body.qcm-dark .cq-internal-links::before {
  background: radial-gradient(circle, color-mix(in srgb, var(--cq-accent, #6366f1) 15%, transparent) 0%, transparent 70%);
}

body.qcm-dark .cq-internal-links::after {
  background: radial-gradient(circle, color-mix(in srgb, var(--cq-accent-alt, #8b5cf6) 10%, transparent) 0%, transparent 70%);
}

body.qcm-dark .cq-internal-links__title {
  color: #e5e7eb;
}

body.qcm-dark .cq-internal-links a {
  background: rgba(26, 29, 38, 0.8);
  border-color: rgba(255, 255, 255, 0.1);
  color: #d1d5db;
}

body.qcm-dark .cq-internal-links a:hover {
  background: color-mix(in srgb, var(--cq-accent, #6366f1) 15%, transparent);
  border-color: color-mix(in srgb, var(--cq-accent, #6366f1) 40%, transparent);
  color: color-mix(in srgb, var(--cq-accent, #6366f1) 70%, #fff);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--cq-accent, #6366f1) 20%, transparent);
}

/* Responsive */
@media (max-width: 768px) {
  .cq-internal-links {
    padding: 1.25rem;
    border-radius: 14px;
    margin-top: 1.25rem;
  }
  
  .cq-internal-links__grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  
  .cq-internal-links a {
    padding: 0.75rem 0.875rem;
    font-size: 0.8125rem;
  }
}

@media (max-width: 480px) {
  .cq-internal-links__grid {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   LOADING STATES
======================================== */
.cq-skeleton {
  background: linear-gradient(90deg, var(--cq-bg) 25%, var(--cq-border) 50%, var(--cq-bg) 75%);
  background-size: 200% 100%;
  animation: cq-skeleton-pulse 1.5s infinite;
  border-radius: var(--cq-radius-md);
}

@keyframes cq-skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.cq-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--cq-border);
  border-top-color: var(--cq-primary);
  border-radius: 50%;
  animation: cq-spin 0.8s linear infinite;
}

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

/* ========================================
   UTILITIES
======================================== */
.cq-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

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

.cq-hidden { display: none !important; }

/* ========================================
   MOBILE FULL-WIDTH BLOCKS
   Force all main blocks (hero, text, cards, etc.) 
   to take full width on mobile devices
======================================== */
@media (max-width: 768px) {
  /* Remove all horizontal padding/margin from main containers */
  body > main,
  body > section,
  body > .campus-page,
  body > .qcm-catalog,
  .campus-container,
  .cq-container,
  .cq-section,
  main,
  .site-content,
  .page-content,
  .entry-content {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  
  /* Hero sections - full width with internal padding */
  .hero,
  .hero-section,
  .hero-with-h1,
  .page-hero,
  .qcm-hero,
  .landing-hero,
  .blog-hero,
  .hub-hero,
  [class*="hero"] {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
  }
  
  /* Cards and content blocks - full width */
  .cq-card,
  .card,
  .content-card,
  .qcm-card,
  .stats-card,
  .feature-card,
  .info-card,
  .dashboard-card,
  .hub-card,
  [class*="card"] {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    border-radius: 12px !important;
  }
  
  /* Full-width sections */
  .cq-section,
  .section,
  .content-section,
  .page-section,
  .qcm-section,
  [class*="section"]:not(button):not(input) {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
  }
  
  /* Text blocks and paragraphs */
  .text-block,
  .content-block,
  .intro-text,
  .description-block,
  article,
  .entry-content p,
  .page-content p {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box !important;
  }
  
  /* Grids - stack vertically */
  .cq-grid,
  .grid,
  .cards-grid,
  .features-grid,
  .qcm-grid,
  [class*="grid"] {
    grid-template-columns: 1fr !important;
    width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box !important;
  }
  
  /* Banners and alerts - full width */
  .banner,
  .alert,
  .notice,
  .cq-alert,
  [class*="banner"],
  [class*="alert"] {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    border-radius: 0 !important;
  }
  
  /* CTA sections */
  .cta,
  .cta-section,
  .cta-block,
  [class*="cta"]:not(button) {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box !important;
  }
  
  /* Stats and features */
  .stats,
  .stats-section,
  .features,
  .features-section,
  .benefits,
  [class*="stats"],
  [class*="features"] {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box !important;
  }
  
  /* QCM specific elements */
  .qcm-catalog,
  .qcm-list,
  .qcm-options,
  .qcm-content,
  .qcm-container,
  .qcm-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
  }
  
  /* Blog elements */
  .blog-content,
  .blog-grid,
  .blog-list,
  .article-content,
  .post-content {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box !important;
  }
  
  /* Hub pages */
  .hub-content,
  .hub-grid,
  .hub-list,
  .parcours-grid,
  .niveau-grid,
  .matiere-grid {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box !important;
  }
  
  /* Footer sections */
  .footer-content,
  .footer-grid,
  footer .container,
  footer .cq-container {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box !important;
  }
  
  /* Dashboard elements */
  .dashboard-content,
  .dashboard-grid,
  .dashboard-wrapper,
  .dashboard-section {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box !important;
  }
  
  /* Forms */
  .form-container,
  .form-wrapper,
  .auth-form,
  .contact-form,
  form {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box !important;
  }
}
