/* ═══════════════════════════════════════════════════════
   TCF Bot — Dashboard CSS
   Thème : industriel sombre, technique, monospace
   ═══════════════════════════════════════════════════════ */

:root {
  --bg:         #0d0f12;
  --bg2:        #141720;
  --bg3:        #1c2030;
  --border:     #252c3d;
  --border2:    #2e3850;
  --text:       #c8d0e0;
  --text2:      #7a8aa0;
  --text3:      #4a5568;
  --accent:     #3b82f6;
  --accent2:    #1d4ed8;
  --green:      #22c55e;
  --yellow:     #eab308;
  --red:        #ef4444;
  --orange:     #f97316;
  --purple:     #a855f7;
  --radius:     6px;
  --font-mono:  'JetBrains Mono', 'Courier New', monospace;
  --font-ui:    'Space Grotesk', system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
}

/* Mobile : pas de height fixe, scroll naturel */
@media (max-width: 1023px) {
  html, body { height: auto; min-height: 100%; }
}

/* ── HEADER ──────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.5px;
}

.logo-icon {
  color: var(--accent);
  font-size: 22px;
}

.logo-text em {
  font-style: normal;
  color: var(--accent);
}

.bot-status-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border: 1px solid var(--border2);
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg3);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
  transition: background 0.3s;
}

.status-dot.active {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.header-stats {
  display: flex;
  gap: 20px;
  flex: 1;
  justify-content: center;
}

.hstat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.hstat span {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.hstat label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── LAYOUT ──────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
  padding: 16px 24px;
  height: calc(100vh - 57px);
  overflow: hidden;
}

.panel-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

.panel-right {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── CARDS ───────────────────────────────────────────── */

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.card-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.card-icon {
  color: var(--accent);
}

/* ── FORM ────────────────────────────────────────────── */

.form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.2s;
}

.input:focus {
  border-color: var(--accent);
}

.input::placeholder {
  color: var(--text3);
}

.select {
  flex: 0 0 auto;
  cursor: pointer;
}

.search-input {
  flex: 2;
}

.form-msg {
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 8px;
  min-height: 18px;
}

.form-msg.success { color: var(--green); }
.form-msg.error   { color: var(--red); }

/* ── FILTERS ─────────────────────────────────────────── */

.filters-card { padding: 12px 16px; }

.filters-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.filters-row .input { flex: 1; min-width: 140px; }

/* ── BUTTONS ─────────────────────────────────────────── */

.btn {
  padding: 8px 16px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg3);
  color: var(--text);
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #fff;
}

.btn-start {
  background: rgba(34,197,94,0.12);
  border-color: var(--green);
  color: var(--green);
}
.btn-start:hover:not(:disabled) {
  background: rgba(34,197,94,0.22);
  color: var(--green);
}

.btn-stop {
  background: rgba(239,68,68,0.12);
  border-color: var(--red);
  color: var(--red);
}
.btn-stop:hover:not(:disabled) {
  background: rgba(239,68,68,0.22);
  color: var(--red);
}

.btn-warn {
  background: rgba(234,179,8,0.1);
  border-color: var(--yellow);
  color: var(--yellow);
}
.btn-warn:hover:not(:disabled) {
  background: rgba(234,179,8,0.2);
  color: var(--yellow);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-danger {
  background: rgba(239,68,68,0.1);
  border-color: var(--red);
  color: var(--red);
}

.btn-reset {
  background: rgba(234,179,8,0.1);
  border-color: var(--yellow);
  color: var(--yellow);
}

/* ── TABLE ───────────────────────────────────────────── */

.table-card {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 8px;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.badge {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 1px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text2);
}

.table-wrapper {
  overflow-y: auto;
  flex: 1;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  position: sticky;
  top: 0;
  background: var(--bg2);
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table tbody tr {
  transition: background 0.1s;
}

.table tbody tr:hover {
  background: var(--bg3);
}

.table .email-cell {
  font-family: var(--font-mono);
  font-size: 12px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table .date-cell {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
}

.empty-row {
  text-align: center;
  color: var(--text3);
  padding: 40px !important;
  font-size: 13px;
}

.actions-cell {
  display: flex;
  gap: 4px;
}

/* ── STATUS BADGES ───────────────────────────────────── */

.status-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
}

.st-pending      { background: rgba(74,85,104,0.2); border-color: #4a5568; color: #718096; }
.st-processing   { background: rgba(59,130,246,0.15); border-color: var(--accent); color: var(--accent); }
.st-completed    { background: rgba(34,197,94,0.15); border-color: var(--green); color: var(--green); }
.st-failed       { background: rgba(239,68,68,0.15); border-color: var(--red); color: var(--red); }
.st-no_exam_found { background: rgba(249,115,22,0.15); border-color: var(--orange); color: var(--orange); }

/* ── LOGS ────────────────────────────────────────────── */

.logs-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow: hidden;
}

.logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.logs-container {
  flex: 1;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-entry {
  display: flex;
  gap: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1.4;
  animation: fadeInLog 0.2s ease;
}

@keyframes fadeInLog {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.log-ts {
  color: var(--text3);
  flex-shrink: 0;
  font-size: 10px;
  margin-top: 1px;
}

.log-info    { color: var(--text2); }
.log-success { color: var(--green); background: rgba(34,197,94,0.05); }
.log-error   { color: var(--red); background: rgba(239,68,68,0.07); }
.log-warn    { color: var(--yellow); background: rgba(234,179,8,0.05); }

/* ── SCROLLBAR ───────────────────────────────────────── */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ══════════════════════════════════════════════════════
   RESPONSIVE
   Breakpoints :
     lg  : ≥ 1024px  → layout 2 colonnes (défaut)
     md  : < 1024px  → layout 1 colonne, logs en bas
     sm  : < 640px   → mobile, tout en colonne
   ══════════════════════════════════════════════════════ */

/* ── Tablette (< 1024px) ─────────────────────────────── */
@media (max-width: 1023px) {

  /* Header : stats cachées, tout sur une ligne compacte */
  .header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 16px;
  }
  .header-stats { display: none; }
  .header-left  { flex: 1; }

  /* Layout : 1 colonne, hauteur auto (scroll naturel) */
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
    overflow: visible;
    padding: 12px 16px;
    gap: 12px;
  }

  /* Panels : scroll auto sur chacun */
  .panel-left  { overflow-y: visible; }
  .panel-right { overflow: visible; }

  /* Logs : hauteur fixe raisonnable sur tablette */
  .logs-card      { height: 380px; }
  .logs-container { flex: 1; }

  /* Table : scroll horizontal si nécessaire */
  .table-wrapper { overflow-x: auto; }
  .table-card    { overflow: hidden; }
}

/* ── Mobile (< 640px) ────────────────────────────────── */
@media (max-width: 639px) {

  /* Header compact */
  .header {
    padding: 8px 12px;
    gap: 8px;
  }
  .logo-text    { font-size: 15px; }
  .logo-icon    { font-size: 18px; }
  .header-left  { gap: 10px; }
  .bot-status-badge { font-size: 11px; padding: 3px 8px; }

  /* Boutons header plus petits */
  .header-actions .btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  /* Layout */
  .layout { padding: 8px 12px; gap: 8px; }

  /* Form rows : colonne sur mobile */
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  /* Exceptions : certains form-row restent en ligne */
  .header-actions { flex-direction: row; }
  .actions-cell   { flex-direction: row; }

  /* Date input : pleine largeur */
  .input[style*="flex:0 0 160px"],
  #inputPaymentDate {
    flex: 1 !important;
    width: 100% !important;
  }

  /* Bouton fichier : pleine largeur */
  .btn-file { width: 100%; text-align: center; }

  /* Filtres : wrap */
  .filters-row {
    flex-wrap: wrap;
    gap: 6px;
  }
  .filters-row .input  { min-width: 100%; }
  .filters-row .select { min-width: calc(50% - 3px); flex: 1; }
  .filters-row .btn-warn {
    width: 100%;
    text-align: center;
  }

  /* Table : colonnes moins importantes cachées */
  .table th:nth-child(4),
  .table td:nth-child(4),
  .table th:nth-child(5),
  .table td:nth-child(5) {
    display: none;
  }

  /* Email tronqué */
  .email-cell { max-width: 130px; }

  /* Status tag plus compact */
  .status-tag { font-size: 10px; padding: 1px 5px; }

  /* Logs */
  .logs-card      { height: 300px; }
  .logs-container { font-size: 10.5px; }

  /* Cards padding réduit */
  .card { padding: 12px; }
}

/* ── Très petit mobile (< 380px) ─────────────────────── */
@media (max-width: 379px) {
  .header-actions .btn span:first-child { display: none; }
  .email-cell { max-width: 100px; }
  .filters-row .select { min-width: 100%; }
}

/* ── RECEIPT SECTION ─────────────────────────────────────────── */

.receipt-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.receipt-title {
  font-size: 12px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  margin-bottom: 2px;
}

.btn-file {
  flex: 0 0 auto;
  background: rgba(168,85,247,0.1);
  border-color: var(--purple);
  color: var(--purple);
  cursor: pointer;
  font-size: 12px;
  padding: 8px 12px;
}

.btn-file:hover {
  background: rgba(168,85,247,0.2);
}

.file-label-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--purple);
  min-height: 16px;
  padding-left: 4px;
}
