/* ── PhoFiaFlow — Design System ── */

/* ── Design Tokens ── */
:root {
  /* Typography */
  --font-display: 'Sora', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  /* Brand colors */
  --brand-navy: #1a1d2e;
  --brand-red: #ef4444;
  --brand-red-dark: #dc2626;

  /* Surfaces */
  --bg-page: #f0f2f5;
  --bg-card: #ffffff;
  --border-card: #e2e8f0;

  /* Text hierarchy */
  --text-primary: #1e293b;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  /* Semantic colors */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #3b82f6;

  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* Bootstrap overrides */
  --bs-primary: #374151;
  --bs-primary-rgb: 55, 65, 81;
  --bs-link-color: #374151;
  --bs-link-hover-color: #111827;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-page);
  background-image:
    radial-gradient(ellipse at 15% 50%, rgba(220,38,38,0.03) 0px, transparent 50%),
    radial-gradient(ellipse at 85% 20%, rgba(55,65,81,0.05) 0px, transparent 50%),
    radial-gradient(ellipse at 50% 90%, rgba(148,163,184,0.04) 0px, transparent 50%);
  color: var(--text-primary);
  min-height: 100vh;
  position: relative;
}

/* ── Page Background Aperture (LEFT side, fixed) ── */
.page-bg-aperture {
  position: fixed;
  left: -18%;
  top: 50%;
  transform: translateY(-45%);
  width: 1100px;
  height: 790px;
  opacity: 0.04;
  pointer-events: none;
  z-index: 0;
}
@media (min-width: 1600px) {
  .page-bg-aperture { width: 1400px; height: 1000px; left: -14%; }
}
@media (max-width: 1100px) {
  .page-bg-aperture { width: 800px; height: 570px; left: -22%; }
}
@media (max-width: 768px) {
  .page-bg-aperture { width: 600px; height: 430px; left: -30%; opacity: 0.03; }
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: #0f172a;
}

.display-6 { font-weight: 700; }

code { user-select: all; color: #1e293b; }

/* Page titles */
.page-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

/* ── Cards ── */
.card {
  border: none;
  border-radius: 0.5rem;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1), 0 2px 6px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* Z-index stacking above page bg aperture */
.navbar {
  position: relative;
  z-index: 100;
}

/* ── Navbar ── */
.navbar.bg-dark {
  background-color: #0f172a !important;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.navbar-brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.5px;
  color: #fff !important;
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-brand .brand-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.navbar-brand .flow-text {
  color: var(--brand-red);
}

.navbar .nav-link {
  color: rgba(255,255,255,0.45) !important;
  font-weight: 500;
  font-size: 13px;
  padding-left: 1rem !important;
  padding-right: 1rem !important;
  transition: color 0.15s;
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
  color: rgba(255,255,255,0.9) !important;
}

.btn-logout {
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.6);
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
  background: transparent;
}
.btn-logout:hover {
  border-color: rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.9);
}

.navbar .user-info {
  color: rgba(255,255,255,0.5);
  font-size: 12px;
}

.navbar-text {
  color: rgba(255,255,255,0.5) !important;
  font-size: 12px;
}

/* ── Hero Banner ── */
.hero-banner {
  position: relative;
  background: linear-gradient(135deg, var(--brand-navy) 0%, #242838 50%, var(--brand-navy) 100%);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Hero box aperture (RIGHT side, inside hero) */
.hero-bg-aperture {
  position: absolute;
  right: -12%;
  top: 50%;
  transform: translateY(-50%);
  width: 550px;
  height: 400px;
  opacity: 0.10;
  pointer-events: none;
  z-index: 1;
}
@media (min-width: 1400px) {
  .hero-bg-aperture { width: 680px; height: 490px; right: -8%; }
}
@media (max-width: 1100px) {
  .hero-bg-aperture { width: 440px; height: 320px; right: -15%; }
}
@media (max-width: 768px) {
  .hero-bg-aperture { width: 320px; height: 230px; right: -20%; opacity: 0.06; }
}

/* Small title aperture near "Dashboard" heading */
.hero-title-icon {
  position: absolute;
  top: 16px;
  left: 20px;
  width: 56px;
  height: 40px;
  opacity: 0.22;
  pointer-events: none;
  z-index: 2;
}

.hero-art {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 2;
  padding: 28px 28px 20px;
}

.hero-content h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.hero-subtitle {
  color: var(--text-faint);
  font-size: 12px;
}

/* ── Stats Grid (dashboard hero) ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.stat-card.accent {
  border-color: rgba(239,68,68,0.3);
}
.stat-card.accent .stat-label {
  color: var(--brand-red);
}

.stat-card .stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.stat-card .stat-sub {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}

/* Clickable stat card links */
.stat-card-link,
.stat-card-link:visited,
.stat-card-link:hover,
.stat-card-link:focus,
.stat-card-link:active {
  text-decoration: none;
  color: inherit;
  display: block;
}
.stat-card-link:hover .stat-card {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.18);
}

/* Status summary row below stats */
.status-summary {
  display: flex;
  gap: 16px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 500;
}
.status-summary .count {
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  margin-left: 4px;
}
.status-summary-link,
.status-summary-link:visited,
.status-summary-link:hover,
.status-summary-link:focus,
.status-summary-link:active {
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s;
}
.status-summary-link:hover {
  opacity: 0.75;
}

/* Legacy stats-bar support (kept for non-hero contexts) */
.stats-bar {
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  display: flex;
}

.stats-bar .stat-cell {
  flex: 1;
  padding: 1rem 1.25rem;
  border-right: 1px solid #e2e8f0;
}
.stats-bar .stat-cell:last-child { border-right: none; }

.stat-cell .stat-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 0.15rem;
}
.stat-cell .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  color: #0f172a;
}
.stat-cell .stat-detail {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.15rem;
}

/* ── Dashboard Sections ── */
.dashboard-section {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  margin-bottom: 16px;
}

.dashboard-section h5,
.dashboard-section h6 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Tables ── */
.table th {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--bg-page);
  border-bottom: 1px solid var(--border-card);
  padding: 10px 18px;
}

.table td {
  font-size: 13px;
  color: var(--text-muted);
  padding: 12px 18px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.table tbody tr:hover {
  background: #fafbfc;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: rgba(0,0,0,0.015);
}

.table a { text-decoration: none; }
.table a:hover { text-decoration: underline; }

.table .name-link {
  color: var(--color-info);
  font-weight: 600;
  text-decoration: none;
}
.table .name-link:hover { text-decoration: underline; }

.key-prefix {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-faint);
}

/* ── Pills (pastel badges) ── */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.pill-green  { background: #ecfdf5; color: #059669; }
.pill-blue   { background: #eff6ff; color: #2563eb; }
.pill-amber  { background: #fffbeb; color: #d97706; }
.pill-red    { background: #fef2f2; color: #ef4444; }
.pill-purple { background: #f3e8ff; color: #7c3aed; }
.pill-gray   { background: #f1f5f9; color: #64748b; }

/* Legacy badge colors (keep for any remaining usage) */
.badge {
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
}
.badge.bg-orange { background-color: #ea580c !important; }
.badge.bg-teal { background-color: #14b8a6 !important; }

/* ── Buttons ── */
.btn-primary {
  background-color: var(--brand-red);
  border-color: var(--brand-red);
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--brand-red-dark);
  border-color: var(--brand-red-dark);
}
.btn-primary:active, .btn-primary.active {
  background-color: #b91c1c;
  border-color: #b91c1c;
}
.btn-check:checked + .btn-primary, .btn-primary:first-child:active {
  background-color: #b91c1c;
  border-color: #b91c1c;
}

.btn-outline-primary {
  color: #374151;
  border-color: #cbd5e1;
}
.btn-outline-primary:hover, .btn-outline-primary:focus {
  background-color: #374151;
  border-color: #374151;
  color: #fff;
}
.btn-outline-primary:active, .btn-outline-primary.active {
  background-color: #1f2937;
  border-color: #1f2937;
  color: #fff;
}

.btn-success {
  background-color: var(--color-success);
  border-color: var(--color-success);
}
.btn-success:hover, .btn-success:focus {
  background-color: #059669;
  border-color: #059669;
}

.btn-sm {
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
}

/* CTA / action buttons — brand crimson */
.btn-danger {
  background-color: #dc2626;
  border-color: #dc2626;
}
.btn-danger:hover, .btn-danger:focus {
  background-color: #b91c1c;
  border-color: #b91c1c;
}
.btn-danger:active, .btn-danger.active {
  background-color: #991b1b;
  border-color: #991b1b;
}

.text-bg-primary { background-color: #374151 !important; }
.badge.bg-primary { background-color: #374151 !important; }

/* ── Pagination ── */
.page-item.active .page-link {
  background-color: var(--brand-red);
  border-color: var(--brand-red);
}
.page-link { color: #374151; }
.page-link:hover { color: #1f2937; }

/* ── Forms ── */
.form-control:focus, .form-select:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 0.2rem rgba(148, 163, 184, 0.25);
}

.form-check-input:checked {
  background-color: var(--brand-red);
  border-color: var(--brand-red);
}

.form-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #1e293b;
}

/* ── Login Page ── */
.login-card {
  border: none;
  border-radius: 0.75rem;
  overflow: hidden;
}

.login-hero {
  position: relative;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  overflow: hidden;
}

.login-hero .hero-art {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.login-hero .login-icon-bg {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 180px;
  height: 180px;
  opacity: 0.06;
  pointer-events: none;
}

/* ── Breadcrumbs ── */
.breadcrumb { font-size: 0.85rem; }

/* ── Alerts ── */
.alert { font-size: 0.875rem; border-radius: 0.5rem; }

/* ── Scanner ── */
.scanner-input:focus {
  border-color: #374151;
  box-shadow: 0 0 0 0.2rem rgba(55, 65, 81, 0.15);
}

/* ── Responsive ── */
@media (max-width: 991px) {
  /* Tighter table padding on tablets */
  .table th { padding: 8px 10px; }
  .table td { padding: 10px 10px; }
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .status-summary {
    flex-wrap: wrap;
    gap: 8px 16px;
  }
  .hero-banner {
    padding: 16px;
  }
  .hero-content {
    padding: 16px 16px 12px;
  }

  /* Compact table cells on mobile */
  .table th { padding: 6px 8px; font-size: 9px; }
  .table td { padding: 8px 8px; font-size: 12px; }

  /* Container less padding */
  .container-xl { padding-left: 10px; padding-right: 10px; }

  /* Stack order detail cards */
  .row .col-md-4 { margin-bottom: 8px; }

  /* Compact pills on mobile */
  .pill { font-size: 9px; padding: 2px 6px; }

  /* Breadcrumb smaller */
  .breadcrumb { font-size: 0.75rem; }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  /* Even tighter on very small screens */
  .table th { padding: 5px 6px; }
  .table td { padding: 6px 6px; }

  h2 { font-size: 1.25rem; }
}
