/* Global crisp styling enhancements */
:root {
  --zy-spacing-xs: .25rem;
  --zy-spacing-sm: .5rem;
  --zy-spacing-md: 1rem;
  --zy-radius-sm: .25rem;
  --zy-radius-md: .5rem;
  --zy-shadow-sm: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.02);
  --zy-shadow-md: 0 2px 4px rgba(0,0,0,.12), 0 1px 3px rgba(0,0,0,.08);
  
  /* Consistent color coding system */
  --zy-status-planning: #0d6efd;
  --zy-status-live: #198754;
  --zy-status-hold: #ffc107;
  --zy-status-completed: #6c757d;
  --zy-status-cancelled: #dc3545;
  --zy-orange: #fd7e14;
  --zy-purple: #6f42c1;
}

/* Utility: semantic color classes (visible on both light & dark backgrounds) */
.text-zy-orange { color: var(--zy-orange) !important; }
.text-zy-purple { color: var(--zy-purple) !important; }
.bg-zy-orange { background-color: var(--zy-orange) !important; }

html { scroll-behavior: smooth; }
body { background: #f7f9fb; font-feature-settings: "kern" 1; }

.navbar { backdrop-filter: blur(6px); background: rgba(255,255,255,.85); }
.navbar .nav-link { font-weight: 500; }
.navbar .nav-link.active { position: relative; }
.navbar .nav-link.active::after { content:""; position:absolute; left:0; bottom:0; height:3px; width:100%; background:var(--zyte-primary); border-radius:2px; }

/* Typography Hierarchy */
h1,h2,h3,h4,h5 { font-weight:600; letter-spacing:-0.01em; margin-bottom: 1rem; }
h1 { font-size: 2rem; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; letter-spacing: -0.015em; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.15rem; }
h5 { font-size: 1rem; }

.page-title { 
  font-size: 1.5rem; 
  font-weight: 600; 
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}

.page-subtitle {
  font-size: 0.95rem;
  color: #6c757d;
  font-weight: 400;
}

/* Advanced Filter Panel */
.filter-panel {
  background: #f8f9fa;
  border: 1px solid #e1e5ea;
  border-radius: var(--zy-radius-md);
  padding: 1.25rem;
  margin: 1rem 0;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.05);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

[data-bs-theme="dark"] .filter-panel {
  background: #2a2a3e;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.3);
}

.filter-panel .form-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

[data-bs-theme="dark"] .filter-panel .form-label {
  color: #e4e4e7;
}

.active-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.active-filters .badge {
  font-size: 0.85rem;
  padding: 0.35rem 0.65rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  transition: background-color 0.3s ease, color 0.3s ease;
}

[data-bs-theme="dark"] .active-filters .badge {
  background-color: rgba(139, 95, 199, 0.4);
  color: #f4f4f5;
}

.active-filters .badge a {
  margin-left: 0.5rem;
  font-size: 1.2em;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.active-filters .badge a:hover {
  opacity: 1;
}

/* Responsive Tables */
.table { 
  --bs-table-bg: #fff; 
  background:#fff; 
  box-shadow: var(--zy-shadow-sm);
}

.table thead th { 
  border-bottom:2px solid #e2e6ea; 
  font-size:.75rem; 
  text-transform:uppercase; 
  letter-spacing:.05em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 10;
}

.table tbody tr:hover { background: var(--zyte-row-hover); }
[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * {
  --bs-table-color-state: #e4e4e7;
  --bs-table-bg-state: var(--zyte-row-hover);
  color: #e4e4e7 !important;
}
.table td, .table th { vertical-align: middle; }

/* Mobile responsive table wrapper */
.table-responsive {
  position: relative;
  box-shadow: var(--zy-shadow-sm);
  border-radius: var(--zy-radius-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .table-responsive {
    font-size: 0.875rem;
  }

  .table thead {
    display: none;
  }

  .table tbody tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #dee2e6;
    border-radius: var(--zy-radius-sm);
    box-shadow: var(--zy-shadow-sm);
  }

  .table tbody td {
    display: block !important;
    position: relative;
    padding: 0.75rem 1rem 0.75rem 45% !important;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    min-height: 2.5rem;
  }

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

  /* Label pinned to the left; cell content flows naturally on the right */
  .table tbody td::before {
    content: attr(data-label);
    position: absolute;
    left: 1rem;
    top: 0.75rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
    width: 40%;
  }

  /* Actions/checkbox cells — no label, full-width content */
  .table tbody td[data-label=""],
  .table tbody td[data-label="Actions"] {
    padding-left: 1rem !important;
    text-align: center;
  }

  .table tbody td[data-label=""]::before,
  .table tbody td[data-label="Actions"]::before {
    display: none;
  }
}

.card { border:1px solid #e1e5ea; box-shadow: var(--zy-shadow-sm); border-radius: var(--zy-radius-md); }
.card-header { background: var(--bs-body-bg); font-weight:600; color: var(--bs-body-color); border-bottom: 2px solid var(--zyte-primary) !important; background-image: none !important; }
/* Colored card headers keep their color but drop the border accent */
.card-header.bg-primary,
.card-header.bg-success,
.card-header.bg-warning,
.card-header.bg-danger,
.card-header.bg-info,
.card-header.bg-dark { background-image: none !important; border-bottom-color: transparent !important; }

/* Consistent Status Badge Colors — soft tint style */
.badge { font-weight:500; letter-spacing:.03em; border-radius: 5px; }
.badge.bg-success, .badge-status-live {
  background: #d1fae5 !important;
  color: #065f46 !important;
}
.badge.bg-warning, .badge-status-hold {
  background: #fef3c7 !important;
  color: #92400e !important;
}
.badge.bg-danger, .badge-status-cancelled {
  background: #fee2e2 !important;
  color: #991b1b !important;
}
.badge.bg-secondary, .badge-status-completed {
  background: #f1f5f9 !important;
  color: #475569 !important;
}
.badge.bg-info, .badge-status-planning {
  background: #ede9fe !important;
  color: #5b21b6 !important;
}
.badge.bg-primary {
  background: rgba(90,45,130,0.12) !important;
  color: var(--zyte-primary) !important;
}

/* Dark mode badge adjustments */
[data-bs-theme="dark"] .badge.bg-success, [data-bs-theme="dark"] .badge-status-live {
  background: rgba(16,185,129,0.2) !important;
  color: #6ee7b7 !important;
}
[data-bs-theme="dark"] .badge.bg-warning, [data-bs-theme="dark"] .badge-status-hold {
  background: rgba(245,158,11,0.2) !important;
  color: #fcd34d !important;
}
[data-bs-theme="dark"] .badge.bg-danger, [data-bs-theme="dark"] .badge-status-cancelled {
  background: rgba(239,68,68,0.2) !important;
  color: #fca5a5 !important;
}
[data-bs-theme="dark"] .badge.bg-secondary, [data-bs-theme="dark"] .badge-status-completed {
  background: rgba(100,116,139,0.2) !important;
  color: #94a3b8 !important;
}
[data-bs-theme="dark"] .badge.bg-info, [data-bs-theme="dark"] .badge-status-planning {
  background: rgba(139,95,199,0.25) !important;
  color: #c4b5fd !important;
}
[data-bs-theme="dark"] .badge.bg-primary {
  background: rgba(139,95,199,0.2) !important;
  color: var(--zyte-primary) !important;
}

.btn-primary { box-shadow: var(--zy-shadow-sm); }
.btn-outline-secondary { box-shadow: var(--zy-shadow-sm); }
.btn:active { transform:translateY(1px); }

/* Elevated dropdowns */
.dropdown-menu {
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.06);
  padding: 0.375rem;
}
.dropdown-item {
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
}
[data-bs-theme="dark"] .dropdown-menu {
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.2);
  border-color: rgba(255,255,255,0.08);
}

.form-control, .form-select { border-radius: 8px; padding: 0.5rem 0.875rem; }
.form-control-sm, .form-select-sm { border-radius: 6px; padding: 0.3rem 0.6rem; }
.form-control:focus, .form-select:focus { box-shadow:0 0 0 .2rem rgba(90,45,130,.25); }

/* Enhanced Toast Notifications */
.toast { 
  box-shadow: var(--zy-shadow-md); 
  border: none;
  min-width: 300px;
}

.toast-header { 
  border-bottom: none;
  font-weight: 600;
}

.toast.toast-success {
  background: #d1e7dd;
  border-left: 4px solid var(--zy-status-live);
  color: #0f5132;
}

.toast.toast-success .toast-header {
  background: var(--zy-status-live);
  color: white;
}

.toast.toast-error {
  background: #f8d7da;
  border-left: 4px solid var(--zy-status-cancelled);
  color: #842029;
}

.toast.toast-error .toast-header {
  background: var(--zy-status-cancelled);
  color: white;
}

.toast.toast-warning {
  background: #fff3cd;
  border-left: 4px solid var(--zy-status-hold);
  color: #664d03;
}

.toast.toast-warning .toast-header {
  background: var(--zy-status-hold);
  color: #212529;
}

.toast.toast-info {
  background: #cfe2ff;
  border-left: 4px solid var(--zy-status-planning);
  color: #084298;
}

.toast.toast-info .toast-header {
  background: var(--zy-status-planning);
  color: white;
}

/* Dark mode support for toasts */
[data-bs-theme="dark"] .toast.toast-success {
  background: #0f5132;
  color: #d1e7dd;
}

[data-bs-theme="dark"] .toast.toast-error {
  background: #842029;
  color: #f8d7da;
}

[data-bs-theme="dark"] .toast.toast-warning {
  background: #664d03;
  color: #fff3cd;
}

[data-bs-theme="dark"] .toast.toast-warning .toast-header {
  color: white;
}

[data-bs-theme="dark"] .toast.toast-info {
  background: #084298;
  color: #cfe2ff;
}

footer { font-size:.8rem; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1rem;
  text-align: center;
}
.empty-state-icon {
  font-size: 2.75rem;
  color: var(--bs-secondary-color);
  margin-bottom: 0.875rem;
  opacity: 0.4;
  display: block;
}
.empty-state-message {
  color: var(--bs-secondary-color);
  font-size: 0.9375rem;
  margin: 0;
}

/* Utility helpers */
.shadow-hover { transition: box-shadow .15s ease, transform .15s ease; }
.shadow-hover:hover { box-shadow: var(--zy-shadow-md); transform: translateY(-2px); }

/* Icon consistency - ensure proper spacing */
.bi { vertical-align: -0.125em; }
.btn .bi { margin-right: 0.25rem; }
.dropdown-item .bi { margin-right: 0.5rem; width: 1rem; }
.nav-link .bi { margin-right: 0.25rem; }

.api-call-row { transition: background .12s ease; }
.api-call-row:hover { background:#eef4ff !important; }

/* Orange utility (Bootstrap doesn't ship bg-orange / text-orange) */
.bg-orange-subtle { background-color: rgba(253, 126, 20, 0.1) !important; }
.text-orange { color: #fd7e14 !important; }
.border-orange { border-color: #fd7e14 !important; }

/* ================================
   Dark Mode Overrides (app.css)
   ================================ */

/* Body background */
[data-bs-theme="dark"] body {
  background: #0f0f1e;
}

/* Tables */
[data-bs-theme="dark"] .table {
  --bs-table-bg: var(--zyte-surface);
  background: var(--zyte-surface);
}

[data-bs-theme="dark"] .table thead th {
  background: rgba(139, 95, 199, 0.15);
  color: #f4f4f5;
}

/* Filter panel - override .card.bg-light used for filter sections */
[data-bs-theme="dark"] .card.bg-light {
  background-color: #2a2a3e !important;
}

/* Epic summary sections (setup status dashboard) */
[data-bs-theme="dark"] .epic-summary {
  background-color: #2a2a3e !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Gantt timeline bar backgrounds */
.gantt-bar-cell {
  height: 22px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
}

.gantt-marker {
  background: #dee2e6;
}

[data-bs-theme="dark"] .gantt-bar-cell {
  background: #2a2a3e !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="dark"] .gantt-marker {
  background: rgba(255, 255, 255, 0.15) !important;
}

/* Revenue dashboard section backgrounds */
[data-bs-theme="dark"] .section-collapse-bg {
  background-color: #1e1e30 !important;
}

/* Section collapse background (light mode base) */
.section-collapse-bg {
  background-color: #e9ecef;
}

/* Status card border in dark mode */
[data-bs-theme="dark"] .status-card {
  border-left-color: var(--zyte-primary);
}

/* Preformatted text blocks */
[data-bs-theme="dark"] pre.bg-light {
  background-color: #2a2a3e !important;
  color: #e4e4e7;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* API call row hover */
[data-bs-theme="dark"] .api-call-row:hover {
  background: rgba(139, 95, 199, 0.15) !important;
}

/* Progress bar track */
[data-bs-theme="dark"] .progress {
  background-color: #2a2a3e;
}

/* Table variant overrides for dark mode */
[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table-light > th,
[data-bs-theme="dark"] .table-light > td {
  --bs-table-bg: rgba(139, 95, 199, 0.12);
  --bs-table-hover-bg: rgba(139, 95, 199, 0.22);
  --bs-table-hover-color: #e4e4e7;
  --bs-table-color: #e4e4e7;
  background-color: rgba(139, 95, 199, 0.12) !important;
  color: #e4e4e7 !important;
  border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .table-secondary,
[data-bs-theme="dark"] .table-secondary > th,
[data-bs-theme="dark"] .table-secondary > td {
  --bs-table-bg: rgba(100, 116, 139, 0.15);
  --bs-table-hover-bg: rgba(100, 116, 139, 0.25);
  --bs-table-hover-color: #e4e4e7;
  --bs-table-color: #e4e4e7;
  background-color: rgba(100, 116, 139, 0.15) !important;
  color: #e4e4e7 !important;
  border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .table-success,
[data-bs-theme="dark"] .table-success > th,
[data-bs-theme="dark"] .table-success > td {
  --bs-table-bg: rgba(25, 135, 84, 0.15);
  --bs-table-hover-bg: rgba(25, 135, 84, 0.25);
  --bs-table-hover-color: #e4e4e7;
  --bs-table-color: #e4e4e7;
  background-color: rgba(25, 135, 84, 0.15) !important;
  color: #e4e4e7 !important;
  border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .table-warning,
[data-bs-theme="dark"] .table-warning > th,
[data-bs-theme="dark"] .table-warning > td {
  --bs-table-bg: rgba(255, 193, 7, 0.12);
  --bs-table-hover-bg: rgba(255, 193, 7, 0.2);
  --bs-table-hover-color: #e4e4e7;
  --bs-table-color: #e4e4e7;
  background-color: rgba(255, 193, 7, 0.12) !important;
  color: #e4e4e7 !important;
  border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .table-danger,
[data-bs-theme="dark"] .table-danger > th,
[data-bs-theme="dark"] .table-danger > td {
  --bs-table-bg: rgba(220, 53, 69, 0.15);
  --bs-table-hover-bg: rgba(220, 53, 69, 0.25);
  --bs-table-hover-color: #e4e4e7;
  --bs-table-color: #e4e4e7;
  background-color: rgba(220, 53, 69, 0.15) !important;
  color: #e4e4e7 !important;
  border-color: rgba(255, 255, 255, 0.1);
}

/* Dark mode: force hover colors on table variant row children */
[data-bs-theme="dark"] .table-hover > tbody > tr.table-success:hover > *,
[data-bs-theme="dark"] .table-hover > tbody > tr.table-warning:hover > *,
[data-bs-theme="dark"] .table-hover > tbody > tr.table-danger:hover > *,
[data-bs-theme="dark"] .table-hover > tbody > tr.table-light:hover > *,
[data-bs-theme="dark"] .table-hover > tbody > tr.table-secondary:hover > * {
  --bs-table-color-state: #e4e4e7;
  color: #e4e4e7 !important;
}

/* Border-top/border-bottom utility in dark mode */
[data-bs-theme="dark"] .border-top,
[data-bs-theme="dark"] .border-bottom {
  border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Navbar background override for app.css */
[data-bs-theme="dark"] .navbar {
  background: linear-gradient(90deg, #3e1f5a, #2a1a40) !important;
  backdrop-filter: none;
}

/* Narrow screens adjustments */
@media (max-width: 768px) {
  .navbar-brand { font-size:1rem; }
  .table-responsive { font-size:.8rem; }
  h1 { font-size:1.5rem; }
}
