/* ============================================
   CoCo Dakar 2026 — Admin Dashboard CSS
   Mobile-first · Ultra Premium
   ============================================ */

:root {
  --gold:         #c8a96e;
  --gold-dark:    #a8894e;
  --gold-light:   #e8c98e;
  --navy:         #1a2744;
  --navy-light:   #253561;
  --navy-deep:    #111b33;
  --green:        #2d7a4f;
  --blue:         #2563eb;
  --red:          #dc2626;
  --gray-50:      #f9fafb;
  --gray-100:     #f3f4f6;
  --gray-200:     #e5e7eb;
  --gray-300:     #d1d5db;
  --gray-400:     #9ca3af;
  --gray-600:     #4b5563;
  --gray-700:     #374151;
  --gray-800:     #1f2937;
  --white:        #ffffff;
  --sidebar-w:    252px;
  --topbar-h:     60px;
  --radius:       14px;
  --radius-sm:    10px;
  --shadow-xs:    0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:    0 1px 4px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
  --shadow-md:    0 4px 16px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  --transition:   .22s cubic-bezier(.4,0,.2,1);

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ══════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy-deep) 0%, var(--navy) 100%);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 300;
  transition: transform var(--transition);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 4px 0 24px rgba(0,0,0,.15);
}

/* Mobile : sidebar hors écran par défaut */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: min(var(--sidebar-w), 85vw);
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
  }
  .sidebar.open { transform: translateX(0); }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.3rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  background: rgba(0,0,0,.15);
}
.brand-logo {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: var(--white);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(200,169,110,.4);
}
.brand-title { font-size: .88rem; font-weight: 800; line-height: 1.2; letter-spacing: -.01em; }
.brand-sub   { font-size: .7rem; color: rgba(255,255,255,.45); margin-top: .1rem; }

.sidebar-nav { flex: 1; padding: .8rem 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .72rem 1.2rem;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: .86rem;
  font-weight: 600;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  cursor: pointer;
  min-height: 46px;
  touch-action: manipulation;
}
.nav-item i {
  width: 18px; text-align: center;
  color: rgba(255,255,255,.35);
  transition: color var(--transition);
  font-size: .9rem;
  flex-shrink: 0;
}
.nav-item:hover  { color: var(--white); background: rgba(255,255,255,.06); }
.nav-item:hover i { color: var(--gold); }
.nav-item.active {
  color: var(--white);
  background: rgba(200,169,110,.1);
  border-left-color: var(--gold);
}
.nav-item.active i { color: var(--gold); }

.sidebar-footer {
  padding: 1rem 1.2rem;
  border-top: 1px solid rgba(255,255,255,.07);
}
.btn-form-link {
  display: flex; align-items: center; gap: .5rem;
  color: var(--gold); text-decoration: none;
  font-size: .8rem; font-weight: 700;
  padding: .55rem .9rem;
  border: 1px solid rgba(200,169,110,.25);
  border-radius: 50px;
  transition: all var(--transition);
  touch-action: manipulation;
  min-height: 42px;
}
.btn-form-link:hover { background: rgba(200,169,110,.1); border-color: rgba(200,169,110,.5); }

.btn-logout {
  display: flex; align-items: center; gap: .5rem;
  margin-top: .55rem;
  width: 100%;
  padding: .55rem .9rem;
  background: none;
  border: 1px solid rgba(220,38,38,.25);
  border-radius: 50px;
  color: rgba(255,110,110,.75);
  font-family: inherit; font-size: .8rem; font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  touch-action: manipulation;
  min-height: 42px;
}
.btn-logout:hover  { background: rgba(220,38,38,.1); color: #ff7070; border-color: rgba(220,38,38,.5); }
.btn-logout:active { background: rgba(220,38,38,.18); }

/* Overlay mobile pour fermer sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 299;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ══════════════════════════════════════════
   MAIN WRAPPER
══════════════════════════════════════════ */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
}
@media (max-width: 768px) {
  .main-wrapper { margin-left: 0; }
}

/* ══════════════════════════════════════════
   TOPBAR
══════════════════════════════════════════ */
.topbar {
  height: var(--topbar-h);
  background: rgba(255,255,255,.96);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 0 1.25rem;
  padding-top: var(--safe-top);
  height: calc(var(--topbar-h) + var(--safe-top));
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-xs);
}
.menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  font-size: 1.15rem; color: var(--gray-600);
  padding: .5rem;
  border-radius: 8px;
  transition: all var(--transition);
  touch-action: manipulation;
  min-width: 40px; min-height: 40px;
  align-items: center; justify-content: center;
}
.menu-toggle:hover  { background: var(--gray-100); color: var(--navy); }
.menu-toggle:active { background: var(--gray-200); }
@media (max-width: 768px) { .menu-toggle { display: flex; } }

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -.01em;
}
.topbar-title span { font-size: .7rem; color: var(--gray-400); font-weight: 500; }
.topbar-actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; flex-shrink: 0; }

.btn-refresh {
  width: 38px; height: 38px;
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  border-radius: 10px;
  cursor: pointer;
  color: var(--gray-600);
  font-size: .9rem;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation;
  flex-shrink: 0;
}
.btn-refresh:hover  { border-color: var(--gold); color: var(--gold); background: rgba(200,169,110,.06); }
.btn-refresh:active { background: rgba(200,169,110,.12); }
.btn-refresh.spinning i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-export {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem .95rem;
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: var(--white);
  border: none; border-radius: 10px;
  cursor: pointer; font-size: .78rem; font-weight: 700;
  font-family: inherit; transition: all var(--transition);
  touch-action: manipulation;
  white-space: nowrap;
  min-height: 38px;
  box-shadow: 0 2px 8px rgba(26,39,68,.25);
}
.btn-export:hover  { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,39,68,.3); }
.btn-export:active { transform: translateY(0); }
@media (max-width: 480px) {
  .btn-export span { display: none; }
  .btn-export { padding: .5rem .7rem; }
}

/* ══════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════ */
.main-content {
  flex: 1;
  padding: 1.1rem 1rem;
  padding-bottom: calc(1.5rem + var(--safe-bottom));
  position: relative;
}
@media (min-width: 640px) { .main-content { padding: 1.5rem; } }

/* ══════════════════════════════════════════
   LOADER
══════════════════════════════════════════ */
.loader-overlay {
  position: absolute; inset: 0;
  background: rgba(249,250,251,.88);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; border-radius: var(--radius);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.loader-box { text-align: center; color: var(--navy); }
.loader-box i {
  font-size: 2.2rem; color: var(--gold);
  margin-bottom: .7rem; display: block;
  filter: drop-shadow(0 2px 8px rgba(200,169,110,.4));
}
.loader-box p { font-weight: 600; font-size: .9rem; color: var(--gray-600); }

/* ══════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--gray-600);
}
.empty-state i {
  font-size: 3.5rem; color: var(--gray-300);
  margin-bottom: 1rem; display: block;
}
.empty-state h2 { font-size: 1.25rem; color: var(--navy); margin-bottom: .5rem; font-weight: 800; }
.empty-state p  { font-size: .9rem; line-height: 1.5; }
.btn-primary-link {
  display: inline-flex; align-items: center; gap: .5rem;
  margin-top: 1.2rem;
  padding: .75rem 1.6rem;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  color: var(--white);
  border-radius: 50px; text-decoration: none;
  font-weight: 700; font-size: .9rem;
  box-shadow: 0 4px 14px rgba(200,169,110,.4);
  touch-action: manipulation;
}

/* ══════════════════════════════════════════
   SECTIONS
══════════════════════════════════════════ */
.dash-section { display: none; }
.dash-section.active {
  display: block;
  animation: fadeInUp .3s cubic-bezier(.4,0,.2,1);
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.section-title-bar {
  display: flex; align-items: center; gap: .55rem;
  font-size: 1rem; font-weight: 800; color: var(--navy);
  margin-bottom: 1.1rem;
  padding-bottom: .65rem;
  border-bottom: 2px solid var(--gold);
  letter-spacing: -.01em;
}
.section-title-bar i { color: var(--gold); }

/* ══════════════════════════════════════════
   KPI CARDS
══════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-bottom: 1rem;
}
@media (min-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 1rem; }
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex; align-items: center; gap: .85rem;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
  overflow: hidden;
  position: relative;
}
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 60px; height: 60px;
  border-radius: 50%;
  opacity: .06;
  transform: translate(15px, -15px);
}
.kpi-card.gold::after  { background: var(--gold); }
.kpi-card.navy::after  { background: var(--navy); }
.kpi-card.green::after { background: var(--green); }
.kpi-card.blue::after  { background: var(--blue); }
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.kpi-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: var(--white); flex-shrink: 0;
}
.kpi-card.gold  .kpi-icon { background: linear-gradient(135deg, var(--gold-light), var(--gold-dark)); }
.kpi-card.navy  .kpi-icon { background: linear-gradient(135deg, var(--navy), var(--navy-light)); }
.kpi-card.green .kpi-icon { background: linear-gradient(135deg, #38a169, var(--green)); }
.kpi-card.blue  .kpi-icon { background: linear-gradient(135deg, #3b82f6, var(--blue)); }

.kpi-value {
  font-size: 1.55rem; font-weight: 800; line-height: 1;
  color: var(--gray-800); margin-bottom: .18rem;
  letter-spacing: -.02em;
}
.kpi-label { font-size: .72rem; color: var(--gray-400); font-weight: 600; line-height: 1.3; }

/* ══════════════════════════════════════════
   CHART CARDS
══════════════════════════════════════════ */
.charts-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: .85rem;
  margin-bottom: .85rem;
}
@media (min-width: 768px) {
  .charts-row { grid-template-columns: 1fr 1fr; gap: 1rem; }
}

.chart-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: .85rem;
  overflow: hidden;
}
.chart-card.full { width: 100%; }
.chart-title {
  font-size: .85rem; font-weight: 800; color: var(--navy);
  margin-bottom: .9rem;
  display: flex; align-items: center; gap: .4rem;
  letter-spacing: -.01em;
}
.chart-title i { color: var(--gold); }

/* ══════════════════════════════════════════
   DETAIL TILES
══════════════════════════════════════════ */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem;
  margin-top: .85rem;
}
@media (min-width: 640px) {
  .detail-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; }
}

.detail-tile {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: .9rem;
  box-shadow: var(--shadow-xs);
  display: flex; flex-direction: column; gap: .4rem;
}
.detail-tile-label {
  font-size: .76rem; color: var(--gray-600); font-weight: 600; line-height: 1.35;
}
.detail-tile-score {
  font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em;
}
.score-5 { color: #16a34a; }
.score-4 { color: #65a30d; }
.score-3 { color: #ca8a04; }
.score-2 { color: #ea580c; }
.score-1 { color: var(--red); }
.score-na { color: var(--gray-300); }
.score-bar {
  height: 4px; border-radius: 2px; background: var(--gray-100); overflow: hidden;
}
.score-bar-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--gold-light), var(--gold-dark));
  transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* ══════════════════════════════════════════
   VERBATIMS
══════════════════════════════════════════ */
.verbatim-tabs {
  display: flex; flex-wrap: wrap; gap: .45rem;
  margin-bottom: 1.1rem;
}
.vtab {
  padding: .45rem .9rem;
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  border-radius: 50px;
  font-size: .78rem; font-weight: 700; font-family: inherit;
  cursor: pointer; color: var(--gray-600);
  transition: all var(--transition);
  touch-action: manipulation;
  min-height: 36px;
  display: flex; align-items: center;
}
.vtab:hover  { border-color: var(--gold); color: var(--gold-dark); }
.vtab.active { background: var(--navy); border-color: var(--navy); color: var(--white); }

.verbatim-list {
  display: flex; flex-direction: column; gap: .7rem;
  max-height: 550px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.verbatim-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  box-shadow: var(--shadow-xs);
}
.verbatim-meta {
  font-size: .72rem; color: var(--gray-400);
  margin-bottom: .32rem;
  display: flex; flex-wrap: wrap; gap: .6rem;
}
.verbatim-text {
  font-size: .88rem; color: var(--gray-700); line-height: 1.6;
}
.verbatim-empty {
  text-align: center; padding: 2.5rem 1.5rem; color: var(--gray-400);
}
.verbatim-empty i { font-size: 2rem; display: block; margin-bottom: .5rem; }

/* ══════════════════════════════════════════
   TABLE DES RÉPONSES
══════════════════════════════════════════ */
.table-toolbar {
  display: flex; align-items: center; gap: .8rem;
  margin-bottom: .9rem; flex-wrap: wrap;
}
.table-toolbar input {
  flex: 1;
  min-width: 160px;
  padding: .6rem 1rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px; font-family: inherit;
  font-size: .92rem; /* 16px+ évite zoom iOS */
  color: var(--gray-800); background: var(--white);
  transition: border-color var(--transition);
  -webkit-appearance: none;
}
.table-toolbar input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200,169,110,.15); }
.table-count { font-size: .78rem; color: var(--gray-400); font-weight: 600; white-space: nowrap; }

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--gray-200);
}
.responses-table {
  width: 100%; border-collapse: collapse;
  background: var(--white);
  font-size: .8rem;
  min-width: 600px; /* scroll horizontal sur mobile */
}
.responses-table thead th {
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: var(--white);
  padding: .7rem .85rem; text-align: left;
  font-size: .74rem; font-weight: 700; letter-spacing: .04em;
  white-space: nowrap;
}
.responses-table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
}
.responses-table tbody tr:hover { background: var(--gray-50); }
.responses-table td { padding: .6rem .85rem; color: var(--gray-700); vertical-align: middle; }

.badge-score {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  font-weight: 800; font-size: .78rem; color: var(--white);
  flex-shrink: 0;
}
.bs-5 { background: #16a34a; }
.bs-4 { background: #65a30d; }
.bs-3 { background: #ca8a04; }
.bs-2 { background: #ea580c; }
.bs-1 { background: var(--red); }
.bs-na{ background: var(--gray-300); }

.badge-recommand {
  padding: .22rem .6rem; border-radius: 50px;
  font-size: .7rem; font-weight: 700;
  white-space: nowrap;
}
.br-yes  { background: #dcfce7; color: #16a34a; }
.br-prob { background: #fef9c3; color: #ca8a04; }
.br-no   { background: #fee2e2; color: var(--red); }

/* ══════════════════════════════════════════
   PAGINATION
══════════════════════════════════════════ */
.pagination {
  display: flex; justify-content: center; gap: .4rem;
  margin-top: 1rem; flex-wrap: wrap;
  padding-bottom: var(--safe-bottom);
}
.page-btn {
  width: 34px; height: 34px;
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  border-radius: 8px;
  cursor: pointer; font-size: .82rem; font-weight: 700;
  font-family: inherit; color: var(--gray-600);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  touch-action: manipulation;
}
.page-btn:hover  { border-color: var(--gold); color: var(--gold); }
.page-btn:active { background: rgba(200,169,110,.1); }
.page-btn.active { background: var(--navy); border-color: var(--navy); color: var(--white); }
