/* =============================================================================
   CAP PSR Guide - Styles
   Design moderne, responsive, mobile-first
   ============================================================================= */

/* --- Variables CSS --- */
:root {
  --pole1: #e67e22;
  --pole1-light: #fdebd0;
  --pole1-dark: #a0560e;
  --pole2: #2980b9;
  --pole2-light: #d4e6f1;
  --pole2-dark: #1a5276;
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #dee2e6;
  --accent: #27ae60;
  --accent-light: #d5f5e3;
  --danger: #e74c3c;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
  --max-width: 1200px;
  --nav-height: 60px;
  --bottom-nav-height: 64px;
}

/* --- Dark Mode --- */
[data-theme="dark"] {
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --text: #e8e8e8;
  --text-light: #a0a0a0;
  --border: #2a2a4a;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.4);
  --pole1-light: #3d2a0f;
  --pole2-light: #0f2a3d;
  --accent-light: #0f3d1a;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: calc(var(--bottom-nav-height) + 16px);
}

a { color: var(--pole2); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--pole2-dark); }

/* --- Top Navigation --- */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.top-nav .logo {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text);
  white-space: nowrap;
}

.top-nav .logo span { color: var(--pole1); }

.nav-links {
  display: none;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-light);
  transition: all var(--transition);
}

.nav-links a:hover, .nav-links a.active {
  background: var(--pole1-light);
  color: var(--pole1);
}

.nav-links a[data-pole="2"]:hover, .nav-links a[data-pole="2"].active {
  background: var(--pole2-light);
  color: var(--pole2);
}

/* Search */
.search-container {
  position: relative;
  flex: 1;
  max-width: 400px;
  margin-left: auto;
}

.search-container input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}

.search-container input:focus { border-color: var(--pole1); }

.search-container .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.9rem;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 200;
}

.search-results.visible { display: block; }

.search-result-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.search-result-item:hover { background: var(--bg); }

.search-result-item .type {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 4px;
}

.search-result-item .type.competence { background: var(--pole1-light); color: var(--pole1); }
.search-result-item .type.savoir { background: var(--accent-light); color: var(--accent); }
.search-result-item .type.glossaire { background: var(--pole2-light); color: var(--pole2); }

.search-result-item .title { font-size: 0.85rem; font-weight: 500; }

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text);
  transition: all var(--transition);
  flex-shrink: 0;
}

.theme-toggle:hover { background: var(--bg); }

/* --- Bottom Navigation (Mobile) --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  height: var(--bottom-nav-height);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-light);
  transition: all var(--transition);
  text-align: center;
  min-width: 0;
}

.bottom-nav a .icon { font-size: 1.3rem; }

.bottom-nav a.active, .bottom-nav a:hover {
  color: var(--pole1);
}

/* --- Main Content --- */
.main { max-width: var(--max-width); margin: 0 auto; padding: 16px; }

/* --- Breadcrumbs --- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.breadcrumbs a { color: var(--text-light); }
.breadcrumbs a:hover { color: var(--pole1); }
.breadcrumbs .sep { color: var(--border); }

/* --- Page Header --- */
.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 4px;
}

.page-header .subtitle {
  color: var(--text-light);
  font-size: 0.9rem;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
  transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-hover); }

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.card-icon.pole1 { background: var(--pole1-light); }
.card-icon.pole2 { background: var(--pole2-light); }

.card-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}

.card-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  margin-top: 4px;
}

.card-badge.pole1 { background: var(--pole1-light); color: var(--pole1-dark); }
.card-badge.pole2 { background: var(--pole2-light); color: var(--pole2-dark); }
.card-badge.epreuve { background: var(--accent-light); color: var(--accent); }

.card-body { font-size: 0.85rem; color: var(--text-light); }

/* --- Grid --- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

/* --- Stats bar --- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}

.stat-number {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}

.stat-number.pole1 { color: var(--pole1); }
.stat-number.pole2 { color: var(--pole2); }
.stat-number.accent { color: var(--accent); }

.stat-label {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* --- Section --- */
.section { margin-bottom: 32px; }

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.section-title .dot.pole1 { background: var(--pole1); }
.section-title .dot.pole2 { background: var(--pole2); }
.section-title .dot.accent { background: var(--accent); }

/* --- Accordion --- */
.accordion { margin-bottom: 8px; }

.accordion-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.accordion-header:hover { background: var(--bg); }

.accordion-header .arrow {
  margin-left: auto;
  transition: transform var(--transition);
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-light);
}

.accordion.open .accordion-header .arrow { transform: rotate(90deg); }

.accordion.open .accordion-header {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.accordion-content {
  display: none;
  padding: 16px;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--bg-card);
}

.accordion.open .accordion-content { display: block; }

/* --- Tables --- */
.table-wrapper { overflow-x: auto; margin-bottom: 16px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-light);
}

/* --- Tags --- */
.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 500;
  margin: 2px 4px 2px 0;
  cursor: pointer;
  transition: all var(--transition);
}

.tag.pole1 { background: var(--pole1-light); color: var(--pole1-dark); }
.tag.pole2 { background: var(--pole2-light); color: var(--pole2-dark); }
.tag.accent { background: var(--accent-light); color: var(--accent); }

.tag:hover { opacity: 0.8; transform: translateY(-1px); }

/* --- Lists --- */
.list-styled { list-style: none; padding: 0; }

.list-styled li {
  padding: 8px 0 8px 20px;
  position: relative;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.list-styled li:last-child { border-bottom: none; }

.list-styled li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 14px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pole1);
}

.list-styled.pole2 li::before { background: var(--pole2); }

/* --- Checkbox progress --- */
.progress-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.progress-check:last-child { border-bottom: none; }

.progress-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.progress-check label {
  font-size: 0.85rem;
  cursor: pointer;
  flex: 1;
}

.progress-check.done label {
  text-decoration: line-through;
  color: var(--text-light);
}

/* --- Progress bar --- */
.progress-bar-container {
  background: var(--border);
  border-radius: 10px;
  height: 8px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent), #2ecc71);
  transition: width 0.4s ease;
}

.progress-text {
  font-size: 0.75rem;
  color: var(--text-light);
  text-align: right;
}

/* --- Indicateurs --- */
.indicateur-group { margin-bottom: 16px; }

.indicateur-group h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 8px;
}

.indicateur-item {
  padding: 6px 0 6px 16px;
  font-size: 0.85rem;
  position: relative;
  border-left: 2px solid var(--border);
  margin-bottom: 4px;
}

.indicateur-item.commun { border-left-color: var(--pole1); }
.indicateur-item.specifique { border-left-color: var(--accent); }

/* --- Quick links --- */
.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

/* --- Alert box --- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert .alert-icon { font-size: 1.1rem; flex-shrink: 0; }
.alert.info { background: var(--pole2-light); border: 1px solid var(--pole2); }
.alert.warning { background: #fef9e7; border: 1px solid #f1c40f; }
.alert.success { background: var(--accent-light); border: 1px solid var(--accent); }

/* --- Tables --- */
.table-styled {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.table-styled th,
.table-styled td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.table-styled th {
  background: var(--bg-card);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-light);
}

.table-styled tbody tr:hover {
  background: var(--accent-light);
}

/* --- Responsive --- */
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .stats-bar { grid-template-columns: repeat(4, 1fr); }
  .page-header h1 { font-size: 2rem; }

  .nav-links { display: flex; }
  .bottom-nav { display: none; }
  body { padding-bottom: 0; }
}

@media (min-width: 1024px) {
  .main { padding: 24px 32px; }
}

/* --- Print --- */
@media print {
  .top-nav, .bottom-nav, .theme-toggle, .search-container { display: none !important; }
  body { padding: 0; background: white; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .accordion-content { display: block !important; }
  a { color: inherit !important; }
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s ease forwards; }

/* --- Back to top --- */
.back-to-top {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--pole1);
  color: white;
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: var(--shadow-hover);
  z-index: 50;
  transition: all var(--transition);
}

.back-to-top.visible { display: flex; }
.back-to-top:hover { transform: scale(1.1); }

@media (min-width: 768px) {
  .back-to-top { bottom: 24px; }
}

/* --- Modules : Navigation dropdown --- */
.nav-dropdown { position: relative; }
.nav-dropdown-trigger { cursor: pointer; }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-hover);
  min-width: 200px;
  z-index: 200;
  padding: 6px 0;
  list-style: none;
  margin: 0;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu li a {
  display: block;
  padding: 8px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  transition: background var(--transition);
}
.nav-dropdown-menu li a:hover,
.nav-dropdown-menu li a.active { background: var(--accent-light); color: var(--accent); }

/* --- Modules : Overlay mobile --- */
.modules-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modules-overlay-content {
  background: var(--bg-card);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 16px;
}
.modules-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 1.1rem;
}
.modules-overlay-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-light);
  padding: 4px 8px;
}
.modules-overlay-list { display: flex; flex-direction: column; gap: 4px; }
.modules-overlay-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background var(--transition);
}
.modules-overlay-item:hover { background: var(--accent-light); }
.modules-overlay-icon { font-size: 1.2rem; width: 28px; text-align: center; }
.bottom-nav-more { }

/* --- Modules : Badge recherche --- */
.search-badge--module {
  background: #8e44ad;
  color: #fff;
}

/* --- Modules : Page module --- */
.module-header {
  border-top: 4px solid var(--accent);
  padding-top: 8px;
}
.module-section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.module-section-nav a {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: all var(--transition);
}
.module-section-nav a:hover { background: var(--accent-light); border-color: var(--accent); }
