/**
 * TitanAxe — Glass UI Theme
 * Brand: linear-gradient(135deg, #0f3145 0%, #1a3d52 50%, #1ca161 100%)
 */

:root {
    --brand-gradient: linear-gradient(135deg, #0f3145 0%, #1a3d52 50%, #1ca161 100%);
    --brand-dark: #0f3145;
    --brand-mid: #1a3d52;
    --brand-accent: #1ca161;
    --brand-accent-hover: #159654;

    --glass-bg: rgba(255, 255, 255, 0.68);
    --glass-bg-strong: rgba(255, 255, 255, 0.82);
    --glass-bg-subtle: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(255, 255, 255, 0.55);
    --glass-border-soft: rgba(255, 255, 255, 0.35);
    --glass-blur: 18px;
    --glass-shadow: 0 8px 32px rgba(8, 28, 42, 0.22), 0 2px 8px rgba(8, 28, 42, 0.12);
    --glass-shadow-hover: 0 12px 40px rgba(8, 28, 42, 0.28);

    --text-primary: #0f2236;
    --text-secondary: #3d5a73;
    --text-muted: #5f7d94;
    --text-on-brand: #ffffff;

    --nav-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --critical: #b91c1c;
    --high: #ea580c;
    --medium: #ca8a04;
    --low: #1ca161;
    --low-alt: #84cc16;

    /* Bootstrap table overrides on glass */
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.12);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.38);
    --bs-table-border-color: rgba(255, 255, 255, 0.35);
}

/* ── Page background ──────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    background: var(--brand-gradient);
    background-attachment: fixed;
    position: relative;
}

/* Subtle depth overlay on gradient */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 50% at 20% 0%, rgba(28, 161, 97, 0.18), transparent 55%),
        radial-gradient(ellipse 60% 40% at 90% 100%, rgba(15, 49, 69, 0.35), transparent 50%),
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: auto, auto, 48px 48px, 48px 48px;
}

body > nav,
body > main {
    position: relative;
    z-index: 1;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    letter-spacing: -0.02em;
}

/* ── Glass mixin (applied via classes) ────────────────── */
.glass,
.main-container .card,
.main-container .registry-card,
.main-container .panel-toolbar,
.main-container .map-card,
.main-container .stat-card,
.main-container .ind-card,
.main-container .list-group-item {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border) !important;
    box-shadow: var(--glass-shadow);
}

.main-container .card:hover,
.main-container .registry-card:hover,
.main-container .card-stats:hover {
    box-shadow: var(--glass-shadow-hover);
}

/* ── Layout ───────────────────────────────────────────── */
.main-container {
    overflow-y: auto;
    overflow-x: hidden;
    height: calc(100vh - var(--nav-height));
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 1.25rem 1.5rem 2rem;
    background: transparent;
}

.page-section {
    margin-bottom: 1.5rem;
}

.page-header__title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.page-header__subtitle {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0;
}

/* ── Navbar (solid gradient — not glass) ──────────────── */
.main-navbar {
    background: var(--brand-gradient);
    min-height: var(--nav-height);
    padding: 0 1.5rem;
    box-shadow: 0 4px 24px rgba(8, 28, 42, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    z-index: 1030;
}

.main-navbar .container-fluid {
    max-width: 100%;
    padding: 0;
}

.navbar-brand {
    color: var(--text-on-brand) !important;
    text-decoration: none !important;
    padding: 0.5rem 0;
}

.navbar-brand__logo {
    height: 42px;
    width: auto;
    object-fit: contain;
}

.navbar-brand__name {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.navbar-brand__tagline {
    font-size: 0.625rem;
    color: rgba(255, 255, 255, 0.78);
    font-weight: 500;
}

.main-navbar .nav-link {
    font-weight: 600;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.9) !important;
    padding: 0.45rem 0.75rem !important;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: background 0.2s;
}

.main-navbar .nav-link:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.14);
}

.main-navbar .nav-link.active {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.22);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.profile-btn {
    border: 1px solid rgba(255, 255, 255, 0.35) !important;
    background: rgba(255, 255, 255, 0.12) !important;
    color: #fff !important;
    backdrop-filter: blur(8px);
}

.profile-btn:hover {
    background: rgba(255, 255, 255, 0.22) !important;
}

.main-navbar .dropdown-menu--nav {
    background: rgba(15, 49, 69, 0.88);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: var(--radius-md);
    padding: 0.4rem;
    box-shadow: var(--glass-shadow) !important;
}

.main-navbar .dropdown-menu--nav .dropdown-item {
    color: rgba(255, 255, 255, 0.9) !important;
    border-radius: var(--radius-sm);
}

.main-navbar .dropdown-menu--nav .dropdown-item:hover {
    background: rgba(28, 161, 97, 0.3);
    color: #fff !important;
}

.main-navbar .dropdown-menu--nav .dropdown-item.active {
    background: rgba(28, 161, 97, 0.4) !important;
}

.dropdown-menu--profile {
    background: var(--glass-bg-strong) !important;
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius-md);
    box-shadow: var(--glass-shadow) !important;
}

.dropdown-menu--profile .dropdown-item {
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm);
}

.dropdown-menu--profile .dropdown-item:hover {
    background: rgba(28, 161, 97, 0.12);
}

/* ── Cards ────────────────────────────────────────────── */
.main-container .card {
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.main-container .card-header {
    background: rgba(255, 255, 255, 0.35) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border-soft) !important;
    padding: 0.85rem 1.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.main-container .card-body {
    padding: 1.25rem;
    background: transparent !important;
}

.main-container .card-footer {
    background: rgba(255, 255, 255, 0.25) !important;
    border-top: 1px solid var(--glass-border-soft);
    backdrop-filter: blur(8px);
}

.panel-accent {
    background: rgba(15, 49, 69, 0.75) !important;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: var(--text-on-brand);
    border-radius: var(--radius-lg);
}

.panel-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-lg);
}

/* Nested mini-cards on dashboard */
.main-container .card .card {
    background: rgba(255, 255, 255, 0.5) !important;
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border-soft) !important;
}

/* ── Tables (glass) ───────────────────────────────────── */
.main-container .table {
    font-size: 0.8125rem;
    color: var(--text-primary);
    margin-bottom: 0;
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: rgba(255, 255, 255, 0.3);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.14);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.42);
}

.main-container .table > :not(caption) > * > * {
    background-color: transparent;
    border-bottom-color: rgba(255, 255, 255, 0.28);
    box-shadow: none;
}

.main-container .table thead th,
.main-container .table thead td,
.main-container .master-table thead th {
    background: rgba(255, 255, 255, 0.55) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--brand-dark) !important;
    font-weight: 700;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid rgba(255, 255, 255, 0.45) !important;
    padding: 0.65rem 0.75rem;
    white-space: nowrap;
    vertical-align: middle;
}

/* Sticky headers keep glass when scrolling */
.main-container .table thead th[style*="sticky"],
.main-container .table thead td[style*="sticky"] {
    background: rgba(255, 255, 255, 0.78) !important;
    backdrop-filter: blur(12px);
    z-index: 40;
}

.main-container .table tbody tr {
    background: rgba(255, 255, 255, 0.22);
    transition: background 0.15s ease;
}

.main-container .table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.32);
}

.main-container .table-hover tbody tr:hover,
.main-container .table tbody tr:hover {
    background: rgba(255, 255, 255, 0.58) !important;
}

.main-container .table tbody td {
    padding: 0.55rem 0.75rem;
    vertical-align: middle;
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--text-primary);
}

.main-container .table-bordered {
    border-color: rgba(255, 255, 255, 0.35);
}

.main-container .table-bordered > :not(caption) > * {
    border-width: 1px 0;
}

/* Category header rows (countries matrix) — tinted glass */
.main-container .table thead tr:first-child th {
    font-size: 0.625rem;
}

.main-container .table thead tr th[style*="background-color: #e0f2fe"],
.main-container .table thead tr th[style*="background-color:#e0f2fe"] {
    background: rgba(186, 230, 253, 0.65) !important;
    color: #0369a1 !important;
}

.main-container .table thead tr th[style*="background-color: #fef08a"],
.main-container .table thead tr th[style*="background-color:#fef08a"] {
    background: rgba(254, 240, 138, 0.65) !important;
    color: #a16207 !important;
}

.main-container .table thead tr th[style*="background-color: #f8fafc"],
.main-container .table thead tr th[style*="background-color:#f8fafc"],
.main-container .table thead tr th[style*="background-color: #f1f5f9"],
.main-container .table thead tr th[style*="background-color:#f1f5f9"] {
    background: rgba(255, 255, 255, 0.5) !important;
}

.main-container .table thead tr th[style*="background-color: #fed7aa"],
.main-container .table thead tr th[style*="background-color:#fed7aa"] {
    background: rgba(254, 215, 170, 0.65) !important;
}

.main-container .table thead tr th[style*="background-color: #f0fdf4"],
.main-container .table thead tr th[style*="background-color:#f0fdf4"] {
    background: rgba(220, 252, 231, 0.65) !important;
}

.main-container .table thead tr th[style*="background-color: #dbeafe"],
.main-container .table thead tr th[style*="background-color:#dbeafe"] {
    background: rgba(219, 234, 254, 0.65) !important;
}

.main-container .table thead tr th[style*="background-color: #dcfce7"],
.main-container .table thead tr th[style*="background-color:#dcfce7"] {
    background: rgba(220, 252, 231, 0.65) !important;
}

.main-container .table thead tr th[style*="background-color: #0f172a"],
.main-container .table thead tr th[style*="background-color:#0f172a"] {
    background: rgba(15, 49, 69, 0.85) !important;
    color: #fff !important;
    backdrop-filter: blur(10px);
}

/* Matrix column groups */
.header-group-drivers {
    background: rgba(209, 250, 229, 0.7) !important;
    color: #065f46 !important;
}

.header-group-metrics {
    background: rgba(224, 242, 254, 0.7) !important;
    color: #1a3d52 !important;
}

.header-group-combined {
    background: rgba(237, 233, 254, 0.7) !important;
    color: #0f3145 !important;
}

.sticky-col-header,
.main-container .table tbody td[style*="sticky"],
.main-container .table thead th[style*="left: 0"] {
    background: rgba(255, 255, 255, 0.82) !important;
    backdrop-filter: blur(10px);
}

.table-registry-wrapper,
.table-responsive--scroll {
    max-height: calc(100vh - 240px);
    overflow: auto;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.4) transparent;
}

.table-registry-wrapper::-webkit-scrollbar,
.table-responsive--scroll::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-registry-wrapper::-webkit-scrollbar-thumb,
.table-responsive--scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.35);
    border-radius: 4px;
}

/* List groups inside cards */
.main-container .list-group-item {
    background: rgba(255, 255, 255, 0.35) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    color: var(--text-primary);
}

.main-container .list-group-item:hover,
.main-container .list-group-item-action:hover {
    background: rgba(255, 255, 255, 0.55) !important;
}

/* ── Forms on glass ───────────────────────────────────── */
.main-container .form-control,
.main-container .form-select {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.main-container .form-control:focus,
.main-container .form-select:focus {
    background: rgba(255, 255, 255, 0.88);
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(28, 161, 97, 0.2);
}

.main-container .input-group-text {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(255, 255, 255, 0.45);
    color: var(--text-secondary);
}

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

/* ── Buttons ──────────────────────────────────────────── */
.btn-brand {
    background: var(--brand-gradient);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-weight: 600;
    border-radius: 999px;
    padding: 0.45rem 1.25rem;
    box-shadow: 0 4px 14px rgba(8, 28, 42, 0.25);
}

.btn-brand:hover {
    color: #fff;
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.btn-primary {
    background-color: var(--brand-mid) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.btn-primary:hover {
    background-color: var(--brand-dark) !important;
}

.btn-light,
.main-container .btn-light {
    background: rgba(255, 255, 255, 0.55) !important;
    border: 1px solid var(--glass-border-soft) !important;
    backdrop-filter: blur(6px);
}

/* ── Risk badges ──────────────────────────────────────── */
.risk-low { background-color: var(--low) !important; color: white !important; }
.risk-medium_low { background-color: var(--low-alt) !important; color: white !important; }
.risk-medium { background-color: var(--medium) !important; color: #000 !important; }
.risk-medium_high { background-color: var(--high) !important; color: white !important; }
.risk-high { background-color: #ef4444 !important; color: white !important; }
.risk-critical { background-color: #7f1d1d !important; color: white !important; }

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 700;
}

.pill-l { background: rgba(236, 253, 245, 0.9); color: #166534; border: 1px solid rgba(187, 247, 208, 0.8); }
.pill-ml { background: rgba(240, 253, 250, 0.9); color: #0f766e; border: 1px solid rgba(153, 246, 228, 0.8); }
.pill-m { background: rgba(255, 251, 235, 0.9); color: #92400e; border: 1px solid rgba(253, 230, 138, 0.8); }
.pill-mh { background: rgba(255, 247, 237, 0.9); color: #c2410c; border: 1px solid rgba(254, 215, 170, 0.8); }
.pill-h { background: rgba(254, 242, 242, 0.9); color: #991b1b; border: 1px solid rgba(254, 202, 202, 0.8); }

/* ── Alerts ───────────────────────────────────────────── */
.main-container > .alert {
    background: var(--glass-bg-strong) !important;
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    box-shadow: var(--glass-shadow);
}

/* ── Modals (solid — no glass blur; prevents double overlay) ── */
body.modal-open::before {
    display: none !important;
}

.modal-backdrop {
    z-index: 1040 !important;
    background-color: #0f2236 !important;
}

.modal-backdrop.show {
    opacity: 0.55 !important;
}

.modal {
    z-index: 1055 !important;
}

.modal-content {
    background: #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: 1px solid #d8e4ec !important;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(15, 49, 69, 0.25);
}

.modal-header {
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.modal-header--brand {
    background: var(--brand-gradient);
    color: #fff;
    border-bottom: none;
}

.modal-header--brand .btn-close {
    filter: brightness(0) invert(1);
}

.modal-body {
    background: #f8fafc;
}

/* Popup tables: dark headers (modals render on body, outside .main-container) */
.modal .table thead th,
.modal .table thead td,
.modal-body .table thead th {
    background: #1a3d52 !important;
    color: #ffffff !important;
    border-bottom: 2px solid rgba(255, 255, 255, 0.12) !important;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
}

.modal .table thead.bg-light th,
.modal thead.bg-light > tr > th,
.modal .table thead.bg-light > tr > th {
    background: #1a3d52 !important;
    color: #ffffff !important;
}

.modal .table thead.bg-dark th,
.modal thead.bg-dark > tr > th {
    background: #0f3145 !important;
    color: #ffffff !important;
}

.modal .table thead th.text-secondary,
.modal .table thead th.text-muted {
    color: rgba(255, 255, 255, 0.92) !important;
}

.modal-footer {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* ── Dashboard ────────────────────────────────────────── */
.map-container {
    height: 500px;
    min-height: 500px;
    width: 100%;
    background: rgba(255, 255, 255, 0.25);
}

.dashboard-section-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    background: rgba(28, 161, 97, 0.2);
    color: var(--brand-accent);
    border: 1px solid rgba(28, 161, 97, 0.35);
}

.main-container .ind-card,
.main-container .stat-card {
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
}

.ind-card .ind-label,
.stat-card__label {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.ind-card .ind-value,
.stat-card__value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.ind-card .ind-sub {
    font-size: 0.625rem;
    color: var(--text-muted);
}

/* Override inline white/slate backgrounds in content area */
.main-container .bg-white:not(.risk-low):not(.risk-high):not(.risk-medium):not(.risk-critical):not(.risk-medium_high):not(.risk-medium_low),
.main-container .bg-light {
    background: rgba(255, 255, 255, 0.4) !important;
}

.main-container .bg-transparent {
    background: transparent !important;
}

.main-container .border,
.main-container .border-bottom,
.main-container .border-top {
    border-color: rgba(255, 255, 255, 0.35) !important;
}

.badge-soft {
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border-soft);
    font-weight: 600;
}

.text-brand { color: var(--brand-dark); }

.btn-toolbar-action {
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.btn-toolbar-action--primary { background: var(--brand-mid); }
.btn-toolbar-action--accent { background: var(--brand-accent); }
.btn-toolbar-action--muted { background: var(--text-secondary); }

@keyframes slideIn {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.slideIn { animation: slideIn 0.2s ease forwards; }

@media (max-width: 991.98px) {
    .main-navbar { padding: 0.5rem 1rem; }
    .main-container { padding: 1rem; }
    .navbar-brand__tagline { display: none; }
}
