/* ALRADIX V4 — Industrial radiography marketplace theme
   Slate base + teal/emerald accents (NO indigo/blue). */

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.5; color: #0f172a; background: #f8fafc;
}
a { color: #0d9488; text-decoration: none; }
a:hover { color: #0f766e; text-decoration: underline; }
button, input, select, textarea {
  font-family: inherit; font-size: inherit; color: inherit;
}
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 12px; }

/* ============================================================
   Layout
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }
/* auth-shell: COLUMN flex so auth-layout + footer stack vertically (fixes
   the horizontal-division bug where the footer appeared beside the hero). */
.auth-shell { display: flex; flex-direction: column; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  padding: 16px 18px; border-bottom: 1px solid #1e293b;
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo { height: 34px; width: auto; flex-shrink: 0; }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-mark {
  font-weight: 700; font-size: 17px; letter-spacing: 0.06em; color: #14b8a6;
}
.brand-version { font-size: 10px; color: #64748b; letter-spacing: 0.1em; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-item {
  display: block; padding: 8px 12px; border-radius: 6px; color: #cbd5e1;
  font-size: 13px; margin-bottom: 2px; transition: all 0.15s;
}
.nav-item:hover { background: #1e293b; color: #fff; text-decoration: none; }
.nav-item.active { background: #134e4a; color: #5eead4; font-weight: 500; }
.nav-item.nav-item-demo {
  background: linear-gradient(135deg, #134e4a, #0f766e); color: #5eead4;
  font-weight: 600; border: 1px solid #14b8a6;
}
.nav-item.nav-item-demo:hover { background: #0f766e; color: #fff; }
.nav-item.logout { margin-top: 12px; border-top: 1px solid #1e293b; padding-top: 12px; color: #f87171; }
.sidebar-footer {
  padding: 12px; border-top: 1px solid #1e293b; background: #020617;
}
.user-card { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #134e4a;
  color: #5eead4; font-weight: 600; display: flex; align-items: center;
  justify-content: center; font-size: 14px;
}
.user-name { font-size: 13px; font-weight: 500; color: #e2e8f0; }
.user-role { font-size: 11px; color: #64748b; }

.main-content {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
}
.topbar {
  background: #fff; border-bottom: 1px solid #e2e8f0; padding: 16px 24px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 18px; font-weight: 600; color: #0f172a; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.page-body {
  padding: 24px; flex: 1; max-width: 1400px; width: 100%;
  margin: 0 auto;
}

/* Sticky footer */
.app-footer {
  background: #0f172a; color: #94a3b8; padding: 12px 24px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; margin-top: auto; flex-shrink: 0;
}
.app-footer a { color: #5eead4; }
.app-footer.auth-footer { background: #0f172a; color: #94a3b8; border-top: none; }
.footer-meta { color: #64748b; }
.footer-meta a { color: #94a3b8; }

/* ============================================================
   Auth layout (now inside .auth-shell column)
   ============================================================ */
.auth-layout {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 32px 16px; background:
    linear-gradient(135deg, #0f172a 0%, #134e4a 100%);
}
.auth-card {
  background: #fff; border-radius: 12px; padding: 32px;
  width: 100%; max-width: 440px; box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand img { max-width: 200px; height: auto; margin-bottom: 8px; }
.auth-brand h1 {
  font-size: 28px; letter-spacing: 0.06em; margin: 0 0 4px;
  color: #0d9488; font-weight: 700;
}
.auth-brand p { font-size: 13px; color: #64748b; margin: 0; }
.auth-tabs {
  display: flex; gap: 4px; margin-bottom: 24px;
  background: #f1f5f9; padding: 4px; border-radius: 8px;
}
.auth-tab {
  flex: 1; padding: 8px 12px; text-align: center; font-size: 13px;
  font-weight: 500; color: #64748b; border-radius: 6px; cursor: pointer;
  border: none; background: transparent;
}
.auth-tab.active { background: #fff; color: #0d9488; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.auth-seed-hint {
  margin-top: 16px; padding: 12px; background: #f0fdfa; border-radius: 6px;
  font-size: 11px; color: #0f766e; border: 1px solid #ccfbf1;
}
.auth-seed-hint strong { color: #134e4a; }
.auth-seed-hint ul { margin: 6px 0 0; padding-left: 16px; }
.auth-seed-hint button {
  background: none; border: none; color: #0d9488; cursor: pointer;
  text-decoration: underline; padding: 0; font-size: inherit;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500; color: #334155;
  margin-bottom: 4px;
}
.form-group label .req { color: #dc2626; }
.form-control {
  width: 100%; padding: 8px 12px; border: 1px solid #cbd5e1;
  border-radius: 6px; font-size: 13px; background: #fff; transition: all 0.15s;
}
.form-control:focus {
  outline: none; border-color: #14b8a6; box-shadow: 0 0 0 3px rgba(20,184,166,0.15);
}
textarea.form-control { min-height: 80px; resize: vertical; font-family: inherit; }
.form-help { font-size: 11px; color: #64748b; margin-top: 4px; }
.form-errors { color: #dc2626; font-size: 12px; margin-top: 4px; }
.checkbox-row {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px;
  background: #f8fafc; border-radius: 6px; margin-bottom: 16px;
}
.checkbox-row input[type=checkbox] { margin-top: 2px; }
.checkbox-row label { font-size: 12px; color: #475569; margin: 0; line-height: 1.5; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer; transition: all 0.15s;
  text-decoration: none; line-height: 1.2;
}
.btn-primary { background: #0d9488; color: #fff; border-color: #0d9488; }
.btn-primary:hover { background: #0f766e; color: #fff; }
.btn-secondary { background: #fff; color: #334155; border-color: #cbd5e1; }
.btn-secondary:hover { background: #f8fafc; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-success { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-warning { background: #d97706; color: #fff; border-color: #d97706; }
.btn-warning:hover { background: #b45309; color: #fff; }
.btn-ghost { background: transparent; color: #475569; }
.btn-ghost:hover { background: #f1f5f9; color: #0f172a; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { display: flex; width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 20px; margin-bottom: 16px;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #e2e8f0;
}
.card-title { font-size: 15px; font-weight: 600; color: #0f172a; margin: 0; }
.card-subtitle { font-size: 12px; color: #64748b; margin-top: 2px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }

/* Stat cards */
.stat-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px;
}
.stat-label { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 24px; font-weight: 700; color: #0f172a; margin-top: 4px; }
.stat-card.warning { border-left: 3px solid #d97706; }
.stat-card.danger { border-left: 3px solid #dc2626; }
.stat-card.success { border-left: 3px solid #16a34a; }
.stat-card.info { border-left: 3px solid #0d9488; }

/* ============================================================
   Tables
   ============================================================ */
.table-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.table-card .table-header {
  padding: 14px 16px; border-bottom: 1px solid #e2e8f0;
  display: flex; justify-content: space-between; align-items: center;
}
.table-card .table-header h3 { margin: 0; font-size: 14px; font-weight: 600; }
.table-wrap { overflow-x: auto; max-height: 540px; overflow-y: auto; }
table.data-table { width: 100%; }
table.data-table th {
  background: #f1f5f9; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: #475569;
  border-bottom: 1px solid #e2e8f0; position: sticky; top: 0;
}
table.data-table td { border-bottom: 1px solid #f1f5f9; font-size: 13px; }
table.data-table tr:hover td { background: #f8fafc; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; line-height: 1.4;
}
.badge-slate { background: #f1f5f9; color: #475569; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-teal { background: #ccfbf1; color: #115e59; }
.badge-emerald { background: #d1fae5; color: #065f46; }
.badge-rose { background: #fee2e2; color: #991b1b; }
.badge-violet { background: #ede9fe; color: #5b21b6; }
.badge-cyan { background: #cffafe; color: #155e75; }
.badge-verified {
  background: linear-gradient(135deg, #0d9488, #115e59);
  color: #fff; padding: 4px 10px; font-weight: 700; letter-spacing: 0.06em;
}

/* Status helpers */
.status-DRAFT, .status-PENDING, .status-PAYMENT_PENDING, .status-PAYMENT_UNDER_REVIEW,
.status-WAITING_FOR_INSPECTOR, .status-SUBMITTED, .status-UNDER_REVIEW { background: #fef3c7; color: #92400e; }
.status-PAYMENT_VERIFIED, .status-ACCEPTED, .status-RESPONDED { background: #ccfbf1; color: #115e59; }
.status-AI_PROCESSING, .status-HUMAN_IN_PROGRESS, .status-IN_PROGRESS { background: #cffafe; color: #155e75; }
.status-AI_COMPLETED, .status-COMPLETED, .status-DELIVERED, .status-CLIENT_FINALIZED,
.status-VERIFIED, .status-PAID, .status-CLOSED, .status-APPROVED, .status-ACTIVE { background: #d1fae5; color: #065f46; }
.status-CANCELLED, .status-REJECTED, .status-REFUNDED, .status-DISPUTED, .status-SUSPENDED,
.status-ERROR, .status-INACTIVE { background: #fee2e2; color: #991b1b; }
.status-HUMAN_REVIEW_REQUESTED { background: #ede9fe; color: #5b21b6; }

/* ============================================================
   Flash messages
   ============================================================ */
.flash-container { margin-bottom: 16px; }
.flash {
  padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 6px;
  border-left: 3px solid;
}
.flash-success { background: #d1fae5; color: #065f46; border-color: #16a34a; }
.flash-danger { background: #fee2e2; color: #991b1b; border-color: #dc2626; }
.flash-warning { background: #fef3c7; color: #92400e; border-color: #d97706; }
.flash-info { background: #ccfbf1; color: #115e59; border-color: #0d9488; }

/* ============================================================
   Marketplace cards
   ============================================================ */
.marketplace-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 20px; transition: all 0.2s; display: flex; flex-direction: column; gap: 8px;
}
.marketplace-card:hover { border-color: #14b8a6; box-shadow: 0 4px 12px rgba(20,184,166,0.1); }
.marketplace-card h3 { margin: 0; font-size: 16px; color: #0f172a; }
.marketplace-card .meta { font-size: 12px; color: #64748b; }
.marketplace-card .price { font-size: 18px; font-weight: 600; color: #0d9488; }
.marketplace-card .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.marketplace-card .tags .badge { font-size: 10px; }
.production-ready-banner {
  background: #d1fae5; color: #065f46; padding: 6px 10px; border-radius: 4px;
  font-size: 11px; font-weight: 600; margin-bottom: 8px;
}
.not-configured-banner {
  background: #fef3c7; color: #92400e; padding: 6px 10px; border-radius: 4px;
  font-size: 11px; font-weight: 600; margin-bottom: 8px;
}
.dev-only-banner {
  background: #ffedd5; color: #9a3412; padding: 6px 10px; border-radius: 4px;
  font-size: 11px; font-weight: 600; margin-bottom: 8px;
}

/* ============================================================
   Page headers / sections
   ============================================================ */
.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 22px; font-weight: 600; margin: 0; color: #0f172a; }
.page-header p { color: #64748b; margin: 4px 0 0; font-size: 13px; }
.section-title {
  font-size: 13px; font-weight: 600; color: #475569; text-transform: uppercase;
  letter-spacing: 0.05em; margin: 24px 0 8px; padding-bottom: 4px;
  border-bottom: 1px solid #e2e8f0;
}

/* ============================================================
   Empty states
   ============================================================ */
.empty-state {
  text-align: center; padding: 40px 20px; color: #64748b;
}
.empty-state .empty-icon { font-size: 36px; opacity: 0.4; margin-bottom: 8px; }
.empty-state h3 { font-size: 14px; color: #475569; margin: 8px 0 4px; }
.empty-state p { font-size: 12px; margin: 0; }

/* ============================================================
   Image grid (inspection images)
   ============================================================ */
.image-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.image-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden;
}
.image-card img { width: 100%; height: 160px; object-fit: cover; background: #0f172a; }
.image-card .image-info { padding: 8px 10px; }
.image-card .image-name { font-size: 12px; font-weight: 500; word-break: break-all; }
.image-card .image-meta { font-size: 11px; color: #64748b; margin-top: 2px; }
.image-card .image-actions { padding: 6px 10px; border-top: 1px solid #f1f5f9; display: flex; gap: 4px; flex-wrap: wrap; }

/* ============================================================
   DICOM viewer full-screen
   ============================================================ */
.viewer-fullscreen {
  position: fixed; inset: 0; z-index: 1000; background: #0f172a;
}
.viewer-fullscreen iframe { width: 100%; height: 100%; border: none; }
.viewer-close-btn {
  position: fixed; top: 12px; right: 12px; z-index: 1001;
  background: #dc2626; color: #fff; border: none; border-radius: 6px;
  padding: 8px 16px; cursor: pointer; font-size: 13px; font-weight: 500;
}
.viewer-close-btn:hover { background: #b91c1c; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .auth-shell { flex-direction: column; }
  .sidebar {
    position: static; width: 100%; height: auto; flex-direction: row;
    overflow-x: auto; padding: 12px;
  }
  .sidebar-brand { padding: 0 12px 0 0; border-bottom: none; border-right: 1px solid #1e293b; }
  .sidebar-nav { display: flex; gap: 4px; padding: 0; }
  .nav-item { white-space: nowrap; margin-bottom: 0; }
  .sidebar-footer { display: none; }
  .page-body { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .app-footer { flex-direction: column; gap: 6px; text-align: center; padding: 10px 16px; }
}

/* ============================================================
   Utilities
   ============================================================ */
.text-muted { color: #64748b; }
.text-danger { color: #dc2626; }
.text-success { color: #16a34a; }
.text-warning { color: #d97706; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.w-full { width: 100%; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================================
   Landing page (index)
   ============================================================ */
.landing-hero {
  text-align: center; padding: 12px 0 20px;
}
.landing-hero img { max-width: 220px; height: auto; margin: 0 auto 16px; display: block; }
.landing-hero h1 { font-size: 30px; font-weight: 700; color: #0d9488; margin: 0 0 6px; letter-spacing: 0.04em; }
.landing-hero p { color: #475569; font-size: 14px; margin: 0 0 20px; }

/* ============================================================
   Policy page
   ============================================================ */
.policy-page { max-width: 820px; margin: 0 auto; }
.policy-body { white-space: pre-wrap; font-size: 13px; line-height: 1.7; color: #334155;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 24px; }
.policy-accepted { background: #d1fae5; color: #065f46; padding: 8px 14px; border-radius: 6px;
  font-size: 12px; font-weight: 600; display: inline-block; margin-bottom: 16px; }

/* ============================================================
   Demo guide (StartupDZ Comité de labellisation)
   ============================================================ */
.demo-header {
  background: linear-gradient(135deg, #0f172a 0%, #134e4a 100%);
  color: #fff; border-radius: 12px; padding: 28px 24px; margin-bottom: 20px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.demo-header img { height: 60px; width: auto; }
.demo-header h1 { font-size: 22px; margin: 0 0 4px; color: #5eead4; }
.demo-header p { font-size: 13px; margin: 0; color: #cbd5e1; }

.demo-lang-switch { display: flex; gap: 4px; margin-bottom: 16px; background: #f1f5f9;
  padding: 4px; border-radius: 8px; width: fit-content; }
.demo-lang-switch button { padding: 8px 18px; border: none; background: transparent;
  border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; color: #64748b; }
.demo-lang-switch button.active { background: #0d9488; color: #fff; }

.demo-section { display: none; }
.demo-section.active { display: block; }
.demo-section[lang="ar"] { direction: rtl; text-align: right; font-family: "Segoe UI", Tahoma, sans-serif; }

.demo-step {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 18px; margin-bottom: 14px; border-left: 4px solid #0d9488;
}
.demo-step .step-num { display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; background: #0d9488; color: #fff;
  font-weight: 700; font-size: 13px; margin-right: 8px; }
.demo-step h3 { display: inline; font-size: 15px; color: #0f172a; margin: 0; }
.demo-step p, .demo-step li { font-size: 13px; color: #475569; line-height: 1.6; }
.demo-step ul { padding-left: 20px; margin: 8px 0; }
.demo-step[lang="ar"] ul { padding-left: 0; padding-right: 20px; }

.demo-accounts {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px; margin: 16px 0;
}
.demo-account-card {
  background: #f0fdfa; border: 1px solid #ccfbf1; border-radius: 8px; padding: 14px;
}
.demo-account-card .role { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: #0f766e; }
.demo-account-card .email { font-size: 14px; font-weight: 600; color: #0f172a; margin: 4px 0; word-break: break-all; }
.demo-account-card .pw { font-size: 12px; color: #475569; font-family: monospace; }
.demo-account-card .label { font-size: 11px; color: #64748b; margin-top: 4px; }

.demo-workflow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; margin-bottom: 20px;
}
.demo-workflow .wf-step { background: #134e4a; color: #5eead4; padding: 6px 12px; border-radius: 6px;
  font-size: 11px; font-weight: 600; white-space: nowrap; }
.demo-workflow .wf-arrow { color: #94a3b8; font-size: 14px; }

.demo-test-btn { display: inline-flex; align-items: center; gap: 6px; background: #0d9488; color: #fff;
  padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 600; text-decoration: none; margin-top: 8px; }
.demo-test-btn:hover { background: #0f766e; color: #fff; }

.demo-icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin: 12px 0; }
.demo-icon-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px; text-align: center; }
.demo-icon-card .icon { font-size: 24px; margin-bottom: 6px; }
.demo-icon-card .title { font-size: 12px; font-weight: 600; color: #0f172a; }
.demo-icon-card .desc { font-size: 11px; color: #64748b; margin-top: 2px; }

@media (max-width: 768px) {
  .demo-header { flex-direction: column; text-align: center; }
  .demo-accounts { grid-template-columns: 1fr; }
  .demo-workflow .wf-step { font-size: 10px; padding: 4px 8px; }
}
