@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@500&display=swap');

:root {
  --ink: #F8FAFC;
  --slate: #94A3B8;
  --paper: #0B0F19;
  --paper-dim: #1E293B;
  --charcoal: #0F172A;
  --charcoal-soft: #1E293B;
  --belt-red: #A8112B;
  --belt-red-dark: #7E0D21;
  --gold: #C9A14A;
  --line: rgba(255, 255, 255, 0.08);
  --white: #111827; /* Used for card backgrounds */

  /* Sidebar & Input Defaults */
  --sidebar-bg: #0F172A;
  --sidebar-text: #9CA3AF;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
  --sidebar-hover-text: #FFFFFF;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --input-bg: #1E293B;
  --card-bg: linear-gradient(135deg, #1e293b, #0f172a);
}

:root.light-theme {
  --ink: #0F172A;
  --slate: #475569;
  --paper: #F8FAFC;
  --paper-dim: #E2E8F0;
  --charcoal: #FFFFFF;
  --charcoal-soft: #F1F5F9;
  --line: rgba(15, 23, 42, 0.08);
  --white: #FFFFFF;

  /* Sidebar & Input Light Mode overrides */
  --sidebar-bg: #FFFFFF;
  --sidebar-text: #475569;
  --sidebar-hover-bg: #F1F5F9;
  --sidebar-hover-text: #0F172A;
  --sidebar-border: rgba(15, 23, 42, 0.08);
  --input-bg: #FFFFFF;
  --card-bg: #FFFFFF;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', Arial, Helvetica, sans-serif;
  background: var(--paper);
  margin: 0;
  padding: 0;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: 'Oswald', Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink);
  margin: 0 0 16px;
}
h1 { font-size: 24px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 600; color: var(--slate); margin-bottom: 12px; }

.mono { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }

.container { max-width: 1200px; margin: 0 auto; padding: 28px 24px; }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

label { display: block; font-size: 12px; font-weight: 600; color: var(--slate); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.04em; }
input, select, textarea {
  padding: 9px 10px; font-size: 14px; font-family: 'Inter', sans-serif;
  border: 1px solid var(--line); border-radius: 4px; box-sizing: border-box;
  background: var(--input-bg); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--belt-red); outline-offset: 1px; border-color: var(--belt-red); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: var(--paper-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate); font-weight: 600; }
td.mono, th.mono { font-family: 'JetBrains Mono', monospace; }

.btn {
  padding: 10px 18px; font-size: 13px; font-weight: 600; font-family: 'Inter', sans-serif;
  border-radius: 4px; border: none; cursor: pointer; text-decoration: none; display: inline-block;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.btn-blue { background: var(--charcoal-soft); color: #ffffff; border: 1px solid var(--line); }
.btn-blue:hover { background: #334155; }
.btn-green { background: var(--belt-red); color: #ffffff; }
.btn-green:hover { background: var(--belt-red-dark); }
.btn-red { background: rgba(220, 38, 38, 0.15); color: #f87171; }
.btn-gray { background: var(--paper-dim); color: var(--ink); }
.btn-purple { background: #7c3aed; color: #ffffff; }
.btn-purple:hover { background: #6d28d9; }

.banner { padding: 12px 14px; border-radius: 4px; margin-bottom: 16px; font-size: 14px; border-left: 3px solid; }
.banner-success { background: rgba(16, 185, 129, 0.1); color: #34d399; border-color: #10b981; }
.banner-error { background: rgba(239, 68, 68, 0.1); color: #f87171; border-color: #ef4444; }
.banner-warning { background: rgba(245, 158, 11, 0.1); color: #fbbf24; border-color: #f59e0b; }

.status-pending { color: #f59e0b; font-weight: 600; }
.status-passed { color: #34d399; font-weight: 600; }
.status-failed { color: #f87171; font-weight: 600; }
.status-flagged_ready { color: #60a5fa; font-weight: 600; }

/* ─── NAVBAR ─── */
.navbar { background: var(--charcoal); padding: 0 24px; display: flex; align-items: center; height: 58px; }
.navbar .brand { color: var(--white); font-family: 'Oswald', sans-serif; font-weight: 700; font-size: 16px; letter-spacing: 0.04em; text-transform: uppercase; margin-right: 36px; white-space: nowrap; }
.navbar nav { display: flex; gap: 2px; flex-wrap: wrap; }
.navbar nav a { color: #A6A8B0; text-decoration: none; font-size: 12.5px; font-weight: 500; padding: 9px 13px; border-radius: 3px; letter-spacing: 0.02em; }
.navbar nav a:hover { background: var(--charcoal-soft); color: var(--white); }
.navbar nav a.active { background: var(--belt-red); color: var(--white); }

/* ─── BELT STRIPE ─── */
.belt-stripe { display: flex; height: 5px; width: 100%; }
.belt-stripe span { flex: 1; }
.belt-stripe .s-white { background: #ECE9E1; }
.belt-stripe .s-yellow { background: #E0B82E; }
.belt-stripe .s-green { background: #3F7A3D; }
.belt-stripe .s-blue { background: #2A5C9E; }
.belt-stripe .s-red { background: var(--belt-red); }
.belt-stripe .s-black { background: var(--charcoal); }

/* ─── DASHBOARD ─── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--white); border: 1px solid var(--line); border-radius: 4px; padding: 18px 20px; border-top: 3px solid var(--belt-red); }
.stat-card .number { font-family: 'Oswald', sans-serif; font-size: 34px; font-weight: 700; line-height: 1; color: var(--ink); }
.stat-card .label { font-size: 11.5px; color: var(--slate); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }

.bar-row { display: grid; grid-template-columns: 70px 1fr 40px; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 13px; }
.bar-track { background: var(--paper-dim); border-radius: 3px; height: 18px; overflow: hidden; }
.bar-fill { background: var(--belt-red); height: 100%; border-radius: 3px 0 0 3px; }
.bar-count { font-family: 'JetBrains Mono', monospace; font-weight: 600; text-align: right; }

.quick-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.quick-links a {
  background: var(--white); border: 1px solid var(--line); border-radius: 4px; padding: 18px;
  text-decoration: none; color: var(--ink); font-weight: 600; font-size: 13.5px; text-align: left;
  display: flex; align-items: center; gap: 10px; transition: border-color 0.15s;
}
.quick-links a:hover { border-color: var(--belt-red); color: var(--belt-red-dark); }
.quick-links .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--belt-red); flex-shrink: 0; }

/* ─── SIDEBAR LAYOUT ─── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ─── SINGLE MERGED SIDEBAR RULE ─── */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow: hidden;             /* ← Fixed: was overflow-y:auto which broke collapse */
  z-index: 100;
  scrollbar-width: thin;
  scrollbar-color: #2D2F3A transparent;
  transition: width 0.25s ease; /* ← Merged from duplicate rule */
}

/* Collapsed state */
.sidebar.collapsed {
  width: 56px;
  min-width: 56px;
}

.main-content {
  margin-left: 240px;
  flex: 1;
  background: var(--paper);
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}

body.sidebar-collapsed .main-content { margin-left: 56px; }

/* ─── SIDEBAR BRAND ─── */
.sidebar-brand { padding: 18px 14px 14px; border-bottom: 1px solid var(--sidebar-border); flex-shrink: 0; }
.sidebar-brand-name { color: var(--sidebar-hover-text); font-family: 'Oswald', sans-serif; font-size: 14px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }

.sidebar-nav { padding: 8px 0 24px; flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #2D2F3A transparent; }

/* ─── NAV ITEMS ─── */
.nav-single {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; color: var(--sidebar-text); font-size: 13px; text-decoration: none;
  transition: background 0.1s;
}
.nav-single:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-hover-text); }
.nav-single.active { background: var(--belt-red); color: #fff; }

.nav-divider { height: 1px; background: var(--sidebar-border); margin: 6px 0; }

.nav-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; cursor: pointer; user-select: none;
  color: var(--sidebar-text); font-size: 11.5px; font-weight: 600;
}
.nav-group-header:hover { color: var(--sidebar-hover-text); }
.nav-icon { font-size: 13px; margin-right: 2px; }
.arrow { font-size: 9px; transition: transform 0.2s; display: inline-block; }

.nav-group-items { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px 7px 26px; color: var(--sidebar-text); font-size: 13px;
  text-decoration: none; transition: background 0.1s; width: 100%; box-sizing: border-box;
}
.nav-item:hover:not(.soon) { background: var(--sidebar-hover-bg); color: var(--sidebar-hover-text); }
.nav-item.active { background: var(--belt-red); color: #fff; border-radius: 0; }
.nav-item.soon { color: #4B5563; cursor: default; pointer-events: none; }

.nav-logout {
  background: none; border: none; cursor: pointer; text-align: left;
  font-family: 'Inter', sans-serif; color: var(--sidebar-text); font-size: 13px;
}
.nav-logout:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-hover-text); }

.nav-badge {
  margin-left: auto; background: var(--belt-red); color: #fff;
  border-radius: 10px; padding: 1px 7px; font-size: 10px; font-weight: 700;
}
.soon-badge {
  margin-left: auto; background: #1F2937; color: #4B5563;
  border-radius: 3px; padding: 1px 5px; font-size: 9px; font-weight: 600; letter-spacing: 0.03em;
}

/* ─── COLLAPSED SIDEBAR STYLES ─── */
.sidebar.collapsed .sidebar-brand-name,
.sidebar.collapsed .nav-group-items,
.sidebar.collapsed .nav-toggle-btn,
.sidebar.collapsed .soon-badge,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-single span:last-child { display: none !important; }

.sidebar.collapsed .sidebar-brand a { justify-content: center; }
.sidebar.collapsed .sidebar-brand { padding: 18px 0; }
.sidebar.collapsed .nav-single,
.sidebar.collapsed .nav-group-header { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .nav-group-link { padding: 0; justify-content: center; }
.sidebar.collapsed .nav-icon { margin: 0; font-size: 16px; }

/* ─── TOOLTIPS WHEN COLLAPSED ─── */
.sidebar.collapsed .nav-single,
.sidebar.collapsed .nav-group-header { position: relative; }
.sidebar.collapsed .nav-single:hover::after,
.sidebar.collapsed .nav-group-header:hover::after {
  content: attr(data-label);
  position: absolute;
  left: 60px;
  top: 50%;
  transform: translateY(-50%);
  background: #1F2937;
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 200;
  pointer-events: none;
}

/* ─── COLLAPSE TOGGLE BUTTON ─── */
.sidebar-collapse-btn {
  width: 100%;
  background: none;
  border: none;
  border-top: 1px solid rgba(255,255,255,0.07);
  color: #3B82F6;               /* ← Blue color for visibility */
  padding: 10px 0;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: color 0.15s;
  margin-top: auto;
  flex-shrink: 0;
}
/* ─── COLLAPSED SIDEBAR STYLES ─── */
.sidebar.collapsed .sidebar-brand-name,
.sidebar.collapsed .nav-group-items,
.sidebar.collapsed .nav-toggle-btn,
.sidebar.collapsed .soon-badge,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .arrow,
.sidebar.collapsed .nav-group-text,
.sidebar.collapsed .nav-single-text { display: none !important; }

/* Hide Language & Theme panels when sidebar is collapsed */
.sidebar.collapsed .sidebar-lang-panel,
.sidebar.collapsed .sidebar-theme-panel { display: none !important; }

.sidebar.collapsed .sidebar-brand a { justify-content: center; }
.sidebar.collapsed .sidebar-brand { padding: 18px 0; }
.sidebar.collapsed .nav-single,
.sidebar.collapsed .nav-group-header { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .nav-group-link { padding: 0; justify-content: center; }
.sidebar.collapsed .nav-icon { margin: 0; font-size: 16px; }

/* ─── MOBILE TOP BAR ─── */
.mobile-topbar {
  display: none; background: var(--charcoal);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 98;
}
.mobile-menu-btn { background: none; border: none; color: var(--ink); font-size: 20px; cursor: pointer; padding: 0; }
.mobile-brand { color: var(--ink); font-family: 'Oswald', sans-serif; font-size: 14px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.55); z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .main-content { margin-left: 0; }
  .mobile-topbar { display: flex; }
  .sidebar { transform: translateX(-240px); transition: transform 0.25s ease; box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.4); }
  .sidebar-collapse-btn { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px 14px !important; }
  .stat-card .number { font-size: 24px; }
  .stat-card .label { font-size: 10px; }
  .quick-links { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: 1fr !important; }
  .header-grid { grid-template-columns: 1fr 1fr !important; }
  table { font-size: 12px; }
  th, td { padding: 6px; }
  .container { padding: 16px; }
  .navbar { flex-wrap: wrap; height: auto; padding: 10px 16px; }
  .navbar .brand { margin-bottom: 6px; width: 100%; }
  .navbar nav { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; padding-bottom: 4px; }
  .navbar nav a { white-space: nowrap; }
  .navbar form { margin-left: 0 !important; margin-top: 6px; width: 100%; text-align: right; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 10px 12px !important; }
  .stat-card .number { font-size: 20px; }
  .stat-card .label { font-size: 9.5px; letter-spacing: 0.02em; }
  .header-grid { grid-template-columns: 1fr !important; }
  .container { padding: 12px; }
}

/* Action Icons */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--white);
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s ease;
  margin: 0 2px;
  line-height: 1;
}
.btn-icon svg {
  flex-shrink: 0;
}
.btn-icon-view { color: #60a5fa; }
.btn-icon-view:hover { background: rgba(37, 99, 235, 0.15); border-color: #3b82f6; transform: scale(1.05); }

.btn-icon-edit { color: #f59e0b; }
.btn-icon-edit:hover { background: rgba(217, 119, 6, 0.15); border-color: #d97706; transform: scale(1.05); }

.btn-icon-delete { color: #f87171; background: var(--white); }
.btn-icon-delete:hover { background: rgba(220, 38, 38, 0.15); border-color: #ef4444; transform: scale(1.05); }

.btn-icon-warning { color: #f59e0b; }
.btn-icon-warning:hover { background: rgba(245, 158, 11, 0.15); border-color: #f59e0b; transform: scale(1.05); }

/* Laravel Pagination SVG Fix */
nav[role="navigation"] svg {
    width: 16px !important;
    height: 16px !important;
    display: inline-block;
    vertical-align: middle;
}
nav[role="navigation"] .flex {
    display: flex;
    align-items: center;
    gap: 8px;
}
nav[role="navigation"] .hidden {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}
@media (max-width: 640px) {
    nav[role="navigation"] .hidden {
        flex-direction: column;
        gap: 12px;
    }
}

.sidebar.collapsed .nav-badge.always-show-badge {
    display: flex !important;
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 8px;
    padding: 1px 4px;
    min-width: 12px;
    height: 12px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
}

.notification-bell-wrapper {
    position: relative;
}

.notification-bell-wrapper .bell-dropdown.active {
    display: block !important;
}

/* ─── MOBILE RESPONSIVE HELPERS ─── */
.show-on-mobile {
    display: none !important;
}

@media (max-width: 768px) {
    .hide-on-mobile {
        display: none !important;
    }
    .show-on-mobile {
        display: block !important;
    }
    /* Force grids to stack on mobile */
    .form-grid, .filter-grid, .grid-3, .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    /* Stacking card lists */
    .mobile-card-list {
        display: flex;
        flex-direction: column;
        gap: 16px;
        width: 100%;
        padding-bottom: 20px;
    }
    .mobile-card {
        background: var(--white);
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 16px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    }
    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 10px;
    }
    .mobile-card-title {
        font-weight: 700;
        font-size: 14.5px;
        color: var(--ink);
    }
    .mobile-card-body {
        font-size: 12.5px;
        color: var(--slate);
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-bottom: 14px;
    }
    .mobile-card-actions {
        display: flex;
        gap: 8px;
        border-top: 1px solid var(--line);
        padding-top: 12px;
        flex-wrap: wrap;
    }
    .mobile-card-actions .btn, .mobile-card-actions form {
        flex: 1;
        min-width: 100px;
    }
    .mobile-card-actions .btn-icon {
        flex: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 8px;
        font-size: 13px;
        font-weight: 600;
        border-radius: 4px;
        border: 1px solid var(--line);
        text-decoration: none;
        background: var(--paper-dim);
        color: var(--ink);
    }
}

/* Dropdowns & Popovers */
.bell-dropdown {
    background: var(--white) !important;
    border: 1px solid var(--line) !important;
}
.bell-dropdown-header {
    background: var(--paper-dim) !important;
    color: var(--slate) !important;
    border-bottom: 1px solid var(--line) !important;
}
.bell-item {
    color: var(--ink) !important;
    border-bottom: 1px solid var(--line) !important;
}
.bell-item:hover {
    background: var(--paper-dim) !important;
}
.bell-item-title {
    color: var(--ink) !important;
}

/* Pagination Overrides */
nav[role="navigation"] div, nav[role="navigation"] span {
    color: var(--slate) !important;
}
nav[role="navigation"] button, nav[role="navigation"] a {
    background: var(--paper-dim) !important;
    border-color: var(--line) !important;
    color: var(--ink) !important;
}
nav[role="navigation"] button:hover, nav[role="navigation"] a:hover {
    background: var(--charcoal-soft) !important;
}

/* ─── LIGHT THEME OVERRIDES ─── */
html.light-theme input,
html.light-theme select,
html.light-theme textarea,
html.light-theme .search-result,
html.light-theme .suggestions,
html.light-theme .suggestions div {
  background: var(--input-bg) !important;
  color: var(--ink) !important;
  border-color: var(--line) !important;
}

html.light-theme .suggestions div:hover {
  background: var(--paper-dim) !important;
}

html.light-theme .btn-blue {
  color: #0F172A !important;
}
html.light-theme .btn-blue:hover {
  background: var(--paper-dim) !important;
}