/* ═══════════════════════════════════════════════════════════════
   Jus d'orange — Components
   ═══════════════════════════════════════════════════════════════ */

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: border-color var(--transition-base);
}
.card:hover { border-color: var(--border); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card-title .icon {
  color: var(--orange);
  font-size: 16px;
}

/* ─── Stat Card ──────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}
.stat-card:hover {
  border-color: rgba(255,107,0,0.3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-orange);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: radial-gradient(circle at 100% 0, var(--orange-glow2), transparent 70%);
  pointer-events: none;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -1px;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.stat-icon {
  position: absolute;
  top: var(--space-5); right: var(--space-5);
  font-size: 24px;
  opacity: 0.4;
}

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}
.stat-trend.up   { background: var(--green-bg);  color: var(--green); }
.stat-trend.down { background: var(--red-bg);    color: var(--red); }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
  text-decoration: none;
  outline: none;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--orange);
  color: white;
  border-color: var(--orange);
}
.btn-primary:hover {
  background: var(--orange-light);
  box-shadow: 0 0 16px rgba(255,107,0,0.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-surface2);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--text-muted); }

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: rgba(239,68,68,0.3);
}
.btn-danger:hover { background: var(--red); color: white; }

.btn-success {
  background: var(--green-bg);
  color: var(--green);
  border-color: rgba(34,197,94,0.3);
}
.btn-success:hover { background: var(--green); color: white; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-surface2); color: var(--text-primary); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: var(--radius-lg); }
.btn-icon { padding: 8px; }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

.badge-active   { background: var(--green-bg);  color: var(--green);  }
.badge-active::before { background: var(--green); }
.badge-inactive { background: var(--bg-surface3); color: var(--text-muted); }
.badge-inactive::before { background: var(--text-muted); }
.badge-pending  { background: var(--yellow-bg); color: var(--yellow); }
.badge-pending::before { background: var(--yellow); animation: pulse 1.5s infinite; }
.badge-failed   { background: var(--red-bg);    color: var(--red);    }
.badge-failed::before { background: var(--red); }
.badge-success  { background: var(--green-bg);  color: var(--green);  }
.badge-success::before { background: var(--green); }
.badge-unused   { background: var(--blue-bg);   color: var(--blue);   }
.badge-unused::before { background: var(--blue); }
.badge-used     { background: var(--bg-surface3); color: var(--text-muted); }
.badge-used::before { background: var(--text-muted); }
.badge-invalid  { background: var(--red-bg);    color: var(--red);    }
.badge-invalid::before { background: var(--red); }
.badge-info     { background: var(--blue-bg);   color: var(--blue);   }
.badge-info::before { background: var(--blue); }
.badge-warn     { background: var(--yellow-bg); color: var(--yellow); }
.badge-warn::before { background: var(--yellow); }
.badge-error    { background: var(--red-bg);    color: var(--red);    }
.badge-error::before { background: var(--red); }
.badge-debug    { background: var(--purple-bg); color: var(--purple); }
.badge-debug::before { background: var(--purple); }

/* ─── Form Controls ──────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 14px;
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-glow);
}

.form-input::placeholder { color: var(--text-muted); }
.form-select { cursor: pointer; appearance: none; }
.form-textarea { resize: vertical; min-height: 80px; }

.form-hint { font-size: 11px; color: var(--text-muted); }
.form-error { font-size: 11px; color: var(--red); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* Toggle / Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--bg-surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition-fast);
}
.toggle input:checked + .toggle-slider { background: var(--orange-glow); border-color: var(--orange); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); background: var(--orange); }

/* ─── Mobile card table ───────────────────────────────────────── */
/* On small screens, tables with class .table-cards become stacked cards */
@media (max-width: 768px) {
  .table-cards thead { display: none; }

  .table-cards tbody tr {
    display: block;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    background: var(--bg-surface);
    padding: var(--space-3);
  }
  .table-cards tbody tr:last-child { margin-bottom: 0; }
  .table-cards tbody tr td { border-bottom: none; }

  .table-cards td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border-subtle) !important;
    gap: var(--space-3);
  }
  .table-cards td:last-child { border-bottom: none !important; padding-bottom: 0; }
  .table-cards td:first-child { padding-top: 0; }

  /* Label shown before each cell value using data-label attribute */
  .table-cards td::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 80px;
  }

  /* Actions row: no label, right-aligned */
  .table-cards td[data-label="Actions"] {
    justify-content: flex-end;
    padding-top: var(--space-2);
  }
  .table-cards td[data-label="Actions"]::before { display: none; }

  /* Table wrapper: no border/overflow on mobile when using cards */
  .table-cards-wrap {
    border: none !important;
    overflow: visible !important;
    background: transparent !important;
  }
  .table-cards-wrap .table-wrapper {
    border: none;
    overflow: visible;
  }
}


.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

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

.table th {
  background: var(--bg-surface2);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

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

.table tbody tr:hover td { background: var(--bg-surface2); color: var(--text-primary); }

.table-empty {
  text-align: center;
  padding: var(--space-12) var(--space-4);
  color: var(--text-muted);
  font-size: 13px;
}
.table-empty .empty-icon { font-size: 32px; display: block; margin-bottom: var(--space-2); opacity: 0.4; }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-base);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 20px;
  line-height: 1; padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}
.modal-close:hover { color: var(--red); }

.modal-body { display: flex; flex-direction: column; gap: var(--space-4); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

/* ─── Search bar ─────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: border-color var(--transition-fast);
}
.search-bar:focus-within { border-color: var(--orange); }
.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  flex: 1;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-icon { color: var(--text-muted); font-size: 14px; }

/* ─── Toast ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  min-width: 280px;
  max-width: 380px;
  animation: slideInRight var(--transition-base) ease;
}

.toast.removing { animation: slideOutRight var(--transition-base) ease forwards; }

.toast-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-content { flex: 1; }
.toast-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.toast-msg   { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.toast.success { border-color: rgba(34,197,94,0.3); }
.toast.error   { border-color: rgba(239,68,68,0.3); }
.toast.warning { border-color: rgba(245,158,11,0.3); }
.toast.info    { border-color: rgba(59,130,246,0.3); }

/* ─── Progress / Loading ─────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-sm { width: 14px; height: 14px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

/* ─── Log stream ─────────────────────────────────────────────── */
.log-stream {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  font-family: var(--font-mono);
  font-size: 12px;
  height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-line {
  display: flex;
  gap: var(--space-3);
  padding: 2px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.log-line:last-child { border-bottom: none; }
.log-time { color: var(--text-muted); flex-shrink: 0; }
.log-level { width: 50px; flex-shrink: 0; }
.log-msg { color: var(--text-secondary); flex: 1; word-break: break-word; }
.log-line.info  .log-level { color: var(--blue);   }
.log-line.warn  .log-level { color: var(--yellow); }
.log-line.error .log-level { color: var(--red);    }
.log-line.debug .log-level { color: var(--purple); }

/* ─── Drag and Drop zone ─────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-6);
  text-align: center;
  transition: all var(--transition-base);
  cursor: pointer;
  position: relative;
}
.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--orange);
  background: var(--orange-glow2);
}
.drop-zone .drop-icon { font-size: 48px; opacity: 0.3; display: block; margin-bottom: var(--space-3); }
.drop-zone p { font-size: 14px; margin-bottom: var(--space-2); }
.drop-zone .drop-hint { font-size: 12px; color: var(--text-muted); }
.drop-zone input[type="file"] {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer;
}

/* ─── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-5);
}
.page-btn {
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-fast);
}
.page-btn:hover, .page-btn.active {
  background: var(--orange);
  border-color: var(--orange);
  color: white;
}
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ─── Skeleton loader ────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-surface2) 25%,
    var(--bg-surface3) 50%,
    var(--bg-surface2) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: shimmer 1.5s infinite;
}

/* ─── Divider ────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-4) 0;
}

/* ─── Empty state ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  text-align: center;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; opacity: 0.3; margin-bottom: var(--space-4); }
.empty-state h3 { font-size: 15px; color: var(--text-secondary); }
.empty-state p { font-size: 13px; margin-top: var(--space-2); }

/* ─── Alert / info box ───────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 13px;
  border: 1px solid;
}
.alert-info    { background: var(--blue-bg);   color: var(--blue);   border-color: rgba(59,130,246,0.3); }
.alert-success { background: var(--green-bg);  color: var(--green);  border-color: rgba(34,197,94,0.3); }
.alert-warning { background: var(--yellow-bg); color: var(--yellow); border-color: rgba(245,158,11,0.3); }
.alert-error   { background: var(--red-bg);    color: var(--red);    border-color: rgba(239,68,68,0.3); }
