/* =========================================================
   ADMIN SIP SCAN CONTROL — DARK UI (STABLE & FIXED)
========================================================= */

/* =========================
   VARIABLES
========================= */
:root {
  --bg-main: #020617;
  --bg-gradient: radial-gradient(1200px 600px at 10% -10%, #111827 0%, #020617 60%);
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --border-soft: rgba(255,255,255,0.10);

  --text-main: #e5e7eb;
  --text-muted: #9ca3af;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
}

/* =========================
   BASE
========================= */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-gradient);
  color: var(--text-main);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 {
  margin: 0 0 .6rem 0;
  font-weight: 600;
}

.small { font-size: .85rem; color: var(--text-muted); }

/* =========================
   LAYOUT
========================= */
.container {
  max-width: 1200px;
  margin: auto;
  padding: 1.5rem;
}

.row { display: flex; gap: .75rem; }
.align-center { align-items: center; }
.grow { flex: 1; }

/* =========================
   CARDS
========================= */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 1.25rem;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

/* =========================
   BOUTONS
========================= */
.btn {
  border-radius: 999px;
  padding: .45rem .9rem;
  font-size: .85rem;
  border: 1px solid var(--border-soft);
  background: rgba(255,255,255,0.05);
  color: var(--text-main);
  cursor: pointer;
  transition: all .15s ease;
}
.btn:hover { background: rgba(255,255,255,0.10); }

.btn.primary {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border: none;
  color: #04130a;
  font-weight: 600;
}

.btn.danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: none;
  color: #fff;
}

.btn.small {
  font-size: .75rem;
  padding: .35rem .7rem;
}

/* =========================================================
   🔒 ADMIN TABS — NE PAS TOUCHER
========================================================= */
.admin-tabs {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin: 1.2rem 0 1.6rem 0;
}

.admin-tabs a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .5rem 1.1rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: #9ca3af;
  font-size: .85rem;
  font-weight: 500;
  border: 1px solid rgba(255,255,255,0.10);
  transition: all .18s ease;
}

.admin-tabs a:hover {
  background: rgba(255,255,255,0.12);
  color: #e5e7eb;
}

.admin-tabs a.active {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  border: none;
  box-shadow: 0 6px 18px rgba(59,130,246,.45);
}

/* Sticky mobile tabs */
@media (max-width: 900px) {
  .admin-tabs {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(2,6,23,.95);
    padding: .6rem;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,.08);
  }
}

/* =========================================================
   MODALES — FIX DÉFINITIF
========================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(2,6,23,.75);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-box {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  width: 95%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  backdrop-filter: blur(18px);
  box-shadow: 0 30px 80px rgba(0,0,0,.7);
}

/* croix fermeture */
.modal-close {
  position: absolute;
  top: .7rem;
  right: .9rem;
  font-size: 1.3rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
.modal-close:hover { color: var(--text-main); }

/* =========================================================
   TABLE VISUALIZER — DESKTOP
========================================================= */

.table-wrap { overflow-x: auto; }

#vizTable {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: .85rem;
}

#vizTable th,
#vizTable td {
  padding: .6rem .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#vizTable thead th {
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-soft);
}

/* Lignes */
#vizTable tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.04);
}
#vizTable tbody tr:hover {
  background: rgba(59,130,246,0.15);
}

/* =========================================================
   🔒 PK + ACTIONS STICKY (ALIGNÉES)
========================================================= */

#vizTable th.pk,
#vizTable td.pk {
  position: sticky;
  right: 96px;
  background: rgba(2,6,23,.95);
  z-index: 2;
  font-family: monospace;
  font-size: .75rem;
}

#vizTable th.actions,
#vizTable td.actions {
  position: sticky;
  right: 0;
  min-width: 96px;
  text-align: center;
  background: rgba(2,6,23,.98);
  z-index: 3;
  box-shadow: -2px 0 0 rgba(255,255,255,.12);
}

/* =========================================================
   COLUMN SELECTOR — RESPONSIVE
========================================================= */
#columnSelector {
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  padding: .75rem;
}

#columnSelector label {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-right: .5rem;
  padding: .35rem .6rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  font-size: .8rem;
}

/* Mobile drawer */
@media (max-width: 768px) {
  #columnSelector {
    position: fixed;
    left: .75rem;
    right: .75rem;
    bottom: .75rem;
    z-index: 90;
    background: rgba(2,6,23,.96);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 14px;
    box-shadow: 0 20px 40px rgba(0,0,0,.6);
  }
}

/* =========================================================
   📱 VISUALIZER — MOBILE CARDS
========================================================= */
@media (max-width: 900px) {

  #vizTable thead {
    display: none;
  }

  #vizTable tbody tr {
    display: block;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: .8rem;
    margin-bottom: .75rem;
  }

  #vizTable tbody td {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    padding: .35rem 0;
    white-space: normal;
  }

  #vizTable tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #9ca3af;
    font-size: .75rem;
  }

  /* PK toujours visible */
  #vizTable td.pk {
    font-family: monospace;
    font-size: .75rem;
  }

  /* Actions bien en bas */
  #vizTable td.actions {
    justify-content: flex-end;
    margin-top: .5rem;
  }
}


/* ========================= */
.hidden { display: none !important; }

/* =========================================================
   MODALE ÉDITION SCAN — LAYOUT PROPRE & STABLE
========================================================= */

#editScanForm {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#editScanForm .row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

#editScanForm textarea {
  min-height: 90px;
  resize: vertical;
}

#editScanForm .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
}

@media (max-width: 800px) {
  #editScanForm .row {
    grid-template-columns: 1fr;
  }

  #editScanForm .form-actions {
    flex-direction: column;
  }

  #editScanForm .form-actions .btn {
    width: 100%;
  }
}

/* =========================================================
   🔧 FIX FORMULAIRE MODALE (ALIGNEMENT)
========================================================= */

#modalEditScan form {
  max-width: 100%;
}

#modalEditScan label {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

#modalEditScan .row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (max-width: 800px) {
  #modalEditScan .row {
    grid-template-columns: 1fr;
  }
}
/* =========================================================
   🔒 FIX PK & ACTIONS — PAS DE TRONCATURE
========================================================= */

/* PK : jamais tronqué */
#vizTable th.pk,
#vizTable td.pk {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;

  min-width: 180px;     /* largeur lisible */
  max-width: none;
}

/* Actions : boutons toujours visibles */
#vizTable th.actions,
#vizTable td.actions {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;

  min-width: 120px;
}

/* Sécurité : code PK lisible */
#vizTable td.pk code {
  display: inline-block;
  white-space: nowrap;
  font-size: .75rem;
}
