@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 35px -10px rgba(79, 70, 229, 0.18);
  --radius-md: 14px;
  --radius-lg: 22px;
}

body.dark-mode {
  --bg-main: #0b1120;
  --bg-card: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --border: #334155;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Navbar Glassmorphism */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 5%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

body.dark-mode .navbar {
  background: rgba(15, 23, 42, 0.88);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.35rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge-501 {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-text-fill-color: white;
  color: white;
  letter-spacing: 0.5px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
  -webkit-text-fill-color: white;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Role Switcher */
.role-switcher {
  display: flex;
  background: var(--bg-main);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.role-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.role-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: transform 0.2s, border-color 0.2s;
}

.icon-btn:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.install-btn {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 0.4rem;
  box-shadow: var(--shadow-lg);
}

/* Hero Section */
.hero {
  padding: 2.5rem 5% 1.8rem;
  max-width: 1320px;
  margin: 0 auto;
}

.hero-banner {
  background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 55%, #0891b2 100%);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  color: white;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 2rem;
  align-items: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.9rem;
}

.hero p {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.02rem;
  margin-bottom: 1.5rem;
}

.search-bar {
  display: flex;
  background: white;
  border-radius: 14px;
  padding: 0.4rem;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.search-bar input {
  flex: 1;
  border: none;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  outline: none;
  color: #0f172a;
  border-radius: 10px;
}

.search-bar button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.7rem 1.3rem;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.stat-card {
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 1.2rem;
  border-radius: 16px;
}

.stat-card h3 {
  font-size: 1.55rem;
  font-weight: 800;
}

.stat-card span {
  font-size: 0.85rem;
  opacity: 0.92;
}

/* Main Container */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 5% 3rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 1.8rem 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Cycle Cards */
.cycles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
}

.cycle-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.cycle-card:hover, .cycle-card.active {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.cycle-icon {
  font-size: 2rem;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(79, 70, 229, 0.1);
}

/* Level Pills & Subject Filter */
.filter-row {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-top: 1rem;
}

.pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.pill.active, .pill:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Resources Cards */
.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.4rem;
  margin-top: 1.2rem;
}

.resource-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s ease;
}

.resource-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.card-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
}

.tag.level {
  background: rgba(6, 182, 212, 0.12);
  color: #0891b2;
}

.resource-card h3 {
  font-size: 1.12rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.resource-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.2rem;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.action-btn {
  border: 1px solid var(--border);
  background: var(--bg-main);
  color: var(--text-primary);
  padding: 0.55rem 0.4rem;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.action-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Modal Workspace */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
}

.modal-header {
  padding: 1.3rem 1.8rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.8rem 1.8rem;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 700;
  cursor: pointer;
}

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

.modal-body {
  padding: 1.8rem;
  overflow-y: auto;
  flex: 1;
}

.formula-box {
  background: rgba(79, 70, 229, 0.08);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.2rem;
  border-radius: 10px;
  margin: 1rem 0;
  font-size: 1rem;
}

.exercise-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.2rem;
  margin-bottom: 1rem;
}

.solution-box {
  margin-top: 0.9rem;
  padding: 0.9rem;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  display: none;
}

.solution-box.visible {
  display: block;
}

.quiz-question {
  margin-bottom: 1.4rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}

.quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.8rem 1rem;
  margin-top: 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-main);
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 500;
}

.quiz-option.selected {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.12);
}

.quiz-option.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.18);
}

.quiz-option.wrong {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.18);
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.4rem;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 0.6rem;
}

.role-context-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.4rem;
  margin-top: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Pied de page institutionnel et crédits auteur */
.app-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 2.5rem 5%;
  margin-top: 2rem;
}

.footer-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 2rem;
  align-items: center;
}

.author-card {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.06), rgba(6, 182, 212, 0.06));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.3rem 1.5rem;
}

.author-card h4 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.4rem;
}

.author-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.inst-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.inst-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

@media (max-width: 820px) {
  .hero-banner, .footer-inner {
    grid-template-columns: 1fr;
  }
  .hero h1 {
    font-size: 1.7rem;
  }
}
