/* =========================================================
   SIP SCAN CONTROL – DESIGN PRO & LISIBLE (2025)
========================================================= */

/* ------------------ */
/* Variables globales */
/* ------------------ */

:root {
  --bg-main: #0b1220;
  --bg-alt: #020617;
  --card-bg: #0f172a;

  --border: #334155;
  --border-soft: #1e293b;

  --text-main: #e5e7eb;
  --text-muted: #94a3b8;

  --primary: #22c55e;
  --primary-dark: #16a34a;
  --primary-soft: rgba(34,197,94,.15);

  --accent: #3b82f6;

  --danger: #ef4444;
  --danger-soft: rgba(239,68,68,.18);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.45);
  --shadow-md: 0 12px 30px rgba(0,0,0,.65);

  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --transition: 0.15s ease-out;
  --font-main: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ------------------ */
/* Reset / base       */
/* ------------------ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  background: radial-gradient(circle at top, #020617, var(--bg-main) 55%);
  color: var(--text-main);
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
}

/* ------------------ */
/* Topbar / header    */
/* ------------------ */

.topbar {
  background: linear-gradient(90deg, #020617, #020617);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar .container {
  max-width: 1200px;
  margin: auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar .brand {
  font-weight: 700;
  letter-spacing: .6px;
}

.topbar a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: .9rem;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  transition: background var(--transition), color var(--transition);
}

.topbar a:hover {
  background: rgba(255,255,255,.08);
  color: var(--text-main);
}

.topbar a.active {
  background: var(--accent);
  color: #fff;
}

/* ------------------ */
/* Layout             */
/* ------------------ */

.container {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px;
}

.card {
  background: linear-gradient(180deg, #0f172a, #0b1220);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-soft);
  margin-bottom: 20px;
}

.card h2,
.card h3 {
  margin: 0 0 14px;
  font-weight: 600;
}

/* Sous-cartes (filtres par ex) */
.card.sub {
  background: #020617;
  border: 1px solid var(--border);
}

/* ------------------ */
/* Grilles            */
/* ------------------ */

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

.col-2 {
  grid-column: 1 / -1;
}

@media (min-width: 768px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ------------------ */
/* Formulaires        */
/* ------------------ */

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: .8rem;
  color: var(--text-muted);
}

input,
select,
textarea {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: .9rem;
  transition: border var(--transition), box-shadow var(--transition);
}

input::placeholder {
  color: #64748b;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59,130,246,.35);
}

input[disabled],
select[disabled] {
  opacity: .5;
  cursor: not-allowed;
}

/* ------------------ */
/* Boutons            */
/* ------------------ */

.btn {
  appearance: none;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  background: #1e293b;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform var(--transition),
              box-shadow var(--transition),
              background var(--transition);
}

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

.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #020617;
}

.btn.secondary {
  background: var(--accent);
  color: #fff;
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

/* ------------------ */
/* Feedback Scan      */
/* ------------------ */

.scan-feedback {
  margin-top: 14px;
  padding: 16px;
  border-radius: var(--radius-lg);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.scan-ok {
  background: var(--primary);
  color: #020617;
  animation: blinkGreen .25s linear 3;
}

.scan-bad {
  background: var(--danger);
  color: #fff;
  animation: blinkRed .25s linear 5;
}

@keyframes blinkGreen {
  50% { opacity: .35; }
}
@keyframes blinkRed {
  50% { opacity: .25; }
}

/* ------------------ */
/* Tables             */
/* ------------------ */

.table-wrapper {
  background: #020617;
  border-radius: var(--radius-lg);
  padding: 8px;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
  min-width: 900px;
}

.table thead {
  background: #020617;
  position: sticky;
  top: 0;
  z-index: 10;
}

.table th {
  font-weight: 600;
  color: #cbd5f5;
  text-transform: uppercase;
  font-size: .7rem;
  letter-spacing: .05em;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

.table tbody tr:hover {
  background: rgba(255,255,255,.04);
}

.table tr.nc {
  background: var(--danger-soft);
}

/* ------------------ */
/* Utilitaires        */
/* ------------------ */

.hidden { display: none !important; }

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

.w-100 { width: 100%; }

.max-400 {
  max-width: 400px;
  margin: auto;
}

/* ------------------ */
/* Responsive         */
/* ------------------ */

@media (max-width: 768px) {
  .card { padding: 16px; }
  .btn { width: 100%; }
}

/* =========================
   MODALE – COLONNES VISIBLES
========================= */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.modal.hidden {
  display: none;
}

.modal-box {
  background: linear-gradient(180deg, #0f172a, #020617);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-md);
}

.modal-box h3 {
  margin: 0 0 18px;
  font-size: 1.05rem;
  font-weight: 600;
  text-align: left;
}

/* Grille propre des colonnes */
.modal-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 24px;
  margin-bottom: 24px;
}

/* Ligne checkbox + label */
.modal-cols label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .9rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background .15s ease;
}

/* Survol ligne */
.modal-cols label:hover {
  background: rgba(255,255,255,.05);
}

/* Checkbox visuelle propre */
.modal-cols input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* Boutons */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

/* ==============================
   VIEW – CONTAINER FULL WIDTH
============================== */

.container-wide {
  width: 100%;
  max-width: none;
  margin: 24px auto;
  padding: 0 20px;
}

/* Option : encore plus confortable sur grands écrans */
@media (min-width: 1400px) {
  .container-wide {
    padding-left: 32px;
    padding-right: 32px;
  }
}

/* =====================================
   SCAN – OPTIMISATION MOBILE
===================================== */

@media (max-width: 768px) {

  /* Carte plus compacte */
  .card {
    padding: 18px 16px;
  }

  /* Labels plus lisibles */
  label {
    font-size: 0.85rem;
  }

  /* Champs plus grands pour le tactile */
  input,
  select,
  textarea {
    padding: 8px 8px;
    font-size: 1rem;
  }

  /* PK CODE = PRIORITÉ ABSOLUE */
  #pk_code {
    font-size: 1.25rem;
    font-weight: 700;
    padding: 16px;
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 2px rgba(59,130,246,.35);
  }

  /* Réduire visuellement les champs secondaires */
  #reference,
  #lot,
  #description,
  #observations {
    opacity: 0.9;
  }

  /* Checkbox non conforme mieux alignée */
  #chk_nc {
    transform: scale(1.3);
    margin-right: 8px;
  }

  /* Boutons = pleine largeur */
  .btn {
    width: 100%;
    padding: 16px;
    font-size: 1.05rem;
  }

  /* Bouton principal plus visible */
  .btn.primary {
    font-size: 1.15rem;
    font-weight: 700;
  }

  /* Bouton Enregistrer sticky */
  .scan-actions {
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, rgba(15,23,42,0), rgba(15,23,42,.95) 40%);
    padding: 12px 0;
    margin-top: 12px;
    z-index: 20;
  }

  /* Feedback scan plus visible */
  .scan-feedback {
    font-size: 1.2rem;
    padding: 18px;
  }
}




/* =========================
   ADMIN – ONGLET TABS
========================= */

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: rgba(255,255,255,.03);
  padding: 6px;
  border-radius: 999px;
}

.tabs a {
  padding: 8px 16px;
  border-radius: 999px;
  text-decoration: none;
  font-size: .85rem;
  color: var(--text-muted);
  transition: background .15s ease, color .15s ease;
}

.tabs a:hover {
  background: rgba(255,255,255,.08);
  color: var(--text-main);
}

.tabs a.active {
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
