/* ===== Customs Clearance System - Premium Dark Theme ===== */
:root {
    --bg-primary: #0f172a;
    /* Deeper background for more contrast */
    --bg-secondary: #1e293b;
    /* Softer secondary */
    --bg-card: rgba(30, 41, 59, 0.7);
    /* More transparent card for glass effect */
    --bg-card-hover: rgba(51, 65, 85, 0.8);
    --glass: rgba(255, 255, 255, 0.05);
    /* Slightly noticeable glass background */
    --glass-border: rgba(255, 255, 255, 0.1);
    /* Brighter glass border */
    --accent-primary: #2E76BB;
    /* Brand Blue */
    --accent-secondary: #5ba3e2;
    /* Complementary lighter blue */
    --accent-glow: rgba(46, 118, 187, 0.2);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #2E76BB;
    --sidebar-width: 280px;
    /* Slightly wider for better text reading */
    --sidebar-collapsed: 80px;
    /* IMPORTANT: Reduced to 80px instead of 0px */
    --topbar-height: 70px;
    /* Taller topbar for breathing room */
    --border-radius: 16px;
    /* Rounder corners for a modern feel */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-bs-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    /* Opaque white for clear boundaries */
    --bg-card-hover: #f8fafc;
    --glass: rgba(0, 0, 0, 0.04);
    /* Slightly darker glass */
    --glass-border: rgba(0, 0, 0, 0.12);
    /* Much clearer borders, no bleeding */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --accent-glow: rgba(99, 102, 241, 0.1);
}

[data-bs-theme="light"] .sidebar-nav a:hover,
[data-bs-theme="light"] .btn-glass:hover,
[data-bs-theme="light"] .page-link:hover {
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

[data-bs-theme="light"] .table thead th {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
}

[data-bs-theme="light"] .table tbody td {
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

[data-bs-theme="light"] .form-control,
[data-bs-theme="light"] .form-select {
    background: rgba(255, 255, 255, 0.8);
    border-color: #cbd5e1;
    color: var(--text-primary);
}

[data-bs-theme="light"] .form-control:focus,
[data-bs-theme="light"] .form-select:focus {
    background: #ffffff;
    border-color: var(--accent-primary);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

body.sidebar-open {
    overflow: hidden;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: var(--transition);
    z-index: 999;
}

.sidebar-brand {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--accent-primary);
    border-bottom: 1px solid var(--glass-border);
    min-height: 90px;
    overflow: hidden;
}

.sidebar-brand i {
    font-size: 1.6rem;
}

.sidebar-brand-logo {
    height: 72px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    flex-shrink: 0;
    padding: 8px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    filter: none;
    transition: transform 0.25s ease, max-width 0.25s ease, height 0.25s ease;
}

[data-bs-theme="light"] .sidebar-brand-logo {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(148, 163, 184, 0.24);
    filter: none;
}

.sidebar-brand-title {
    font-size: 0.78rem;
    line-height: 1.2;
    opacity: 0.9;
    font-weight: 700;
    color: var(--text-secondary);
    white-space: normal;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sidebar-nav {
    list-style: none;
    padding: 12px 10px;
    margin: 0;
    flex: 1;
}

.sidebar-nav .nav-section {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 18px 14px 6px;
    letter-spacing: 1px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    transition: var(--transition);
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.sidebar-nav a:hover {
    background: var(--glass);
    color: var(--text-primary);
    transform: translateX(-5px);
    /* RTL subtle hover effect */
}

.sidebar-nav a.active {
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.2), rgba(167, 139, 250, 0.2));
    color: var(--accent-primary);
    border-right: 4px solid var(--accent-primary);
    font-weight: 700;
}

.sidebar-nav a i {
    font-size: 1.25rem;
    width: 26px;
    text-align: center;
    transition: var(--transition);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--glass-border);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: var(--danger);
    text-decoration: none;
    border-radius: 10px;
    transition: var(--transition);
    font-weight: 500;
    width: 100%;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Sidebar collapse */
.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}

.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 14px 0;
    min-height: 72px;
}

.sidebar-collapsed .sidebar-brand-title {
    opacity: 0;
    width: 0;
    transform: translateX(8px);
    pointer-events: none;
}

.sidebar-collapsed .sidebar-brand-logo {
    max-width: 52px;
    height: 40px;
    padding: 5px;
    border-radius: 12px;
}

.sidebar-collapsed .nav-section {
    display: none;
}

.sidebar-collapsed .sidebar-nav a span {
    display: none;
}

.sidebar-collapsed .sidebar-nav a {
    justify-content: center;
    padding: 12px 0;
}

.sidebar-collapsed .sidebar-nav a i {
    margin: 0;
}

.sidebar-collapsed .btn-logout span,
.sidebar-collapsed .btn-logout.text-node {
    display: none;
}

.sidebar-collapsed .btn-logout {
    justify-content: center;
    padding: 12px 0;
}

.sidebar-collapsed .main-content {
    margin-right: var(--sidebar-collapsed);
}

/* ===== Main Content ===== */
.main-content {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: radial-gradient(circle at top right, rgba(129, 140, 248, 0.05), transparent 40%),
        radial-gradient(circle at bottom left, rgba(167, 139, 250, 0.05), transparent 40%);
}

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
}

.topbar-right {
    min-width: 0;
}

.sidebar-toggle {
    color: var(--text-secondary);
    text-decoration: none;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Cards ===== */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    backdrop-filter: blur(10px);
    transition: var(--transition);
}

[data-bs-theme="light"] .glass-card {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.glass-card:hover {
    border-color: rgba(99, 102, 241, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="light"] .glass-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

/* Stat Cards */
.stat-card {
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 0 var(--border-radius) 0 80px;
    opacity: 0.1;
}

.stat-card.purple::before {
    background: var(--accent-primary);
}

.stat-card.blue::before {
    background: var(--info);
}

.stat-card.green::before {
    background: var(--success);
}

.stat-card.orange::before {
    background: var(--warning);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 16px;
}

.stat-icon.purple {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
}

.stat-icon.blue {
    background: rgba(6, 182, 212, 0.15);
    color: var(--info);
}

.stat-icon.green {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.stat-icon.orange {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ===== Tables ===== */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.table {
    margin: 0;
    color: var(--text-primary);
}

.table thead th {
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--glass-border);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 14px 16px;
    white-space: nowrap;
}

[data-bs-theme="light"] .table thead th {
    background: rgba(0, 0, 0, 0.04);
    border-bottom: 2px solid var(--glass-border);
    color: var(--text-secondary);
}

.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
    font-size: 0.9rem;
}

[data-bs-theme="light"] .table tbody td {
    border-bottom: 1px solid var(--glass-border);
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: var(--bg-card-hover);
}

/* ===== Responsive Table Cards ===== */
@media (max-width: 768px) {
    .table-responsive-cards {
        display: block;
        background: transparent;
    }

    .table-responsive-cards thead {
        display: none;
    }

    .table-responsive-cards tbody {
        display: block;
    }

    .table-responsive-cards tr {
        display: flex;
        flex-direction: column;
        background: var(--bg-card);
        border: 1px solid var(--glass-border);
        border-radius: var(--border-radius);
        margin-bottom: 16px;
        padding: 12px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        backdrop-filter: blur(10px);
    }

    [data-bs-theme="light"] .table-responsive-cards tr {
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
        border: 1px solid var(--glass-border) !important;
        margin-bottom: 20px;
    }

    .table-responsive-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 8px;
        border-bottom: 1px solid var(--glass-border);
        text-align: left;
        /* Align value to the left (since RTL, this means end of row) */
        font-size: 0.9rem;
    }

    .table-responsive-cards td:last-child {
        border-bottom: none;
        padding-bottom: 4px;
        justify-content: center;
        /* Center action buttons on mobile */
        margin-top: 8px;
    }

    .table-responsive-cards td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
        margin-left: 10px;
        /* Space between label and value in RTL */
        text-align: right;
        font-size: 0.85rem;
    }
}

/* ===== Buttons ===== */
.btn-gradient {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-gradient:hover {
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
    color: #fff;
}

.btn-glass {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-glass:hover {
    background: var(--accent-glow);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* ===== Forms ===== */
.form-control,
.form-select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 10px 14px;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    background: rgba(0, 0, 0, 0.4);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
    color: var(--text-primary);
}

.form-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 6px;
}

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

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-title i {
    color: var(--accent-primary);
}

/* ===== Badges / Status ===== */
.badge-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

/* ===== Alerts ===== */
.glass-alert {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    backdrop-filter: blur(10px);
}

.alert-success {
    border-color: rgba(16, 185, 129, 0.3);
}

.alert-danger {
    border-color: rgba(239, 68, 68, 0.3);
}

.alert-warning {
    border-color: rgba(245, 158, 11, 0.3);
}

.alert-info {
    border-color: rgba(6, 182, 212, 0.3);
}

/* ===== Search Bar ===== */
.search-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.search-bar .form-control {
    max-width: 300px;
    min-width: 0;
}

/* ===== Filters ===== */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.filter-bar .form-select {
    max-width: 200px;
}

/* ===== Pagination ===== */
.pagination {
    gap: 4px;
}

.page-link {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 8px 14px;
    transition: var(--transition);
}

.page-link:hover {
    background: var(--accent-glow);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.page-item.active .page-link {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}

/* ===== Timeline ===== */
.timeline {
    position: relative;
    padding-right: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    right: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--glass-border);
}

.timeline-item {
    position: relative;
    padding: 16px 20px;
    margin-bottom: 16px;
    background: var(--glass);
    border-radius: var(--border-radius);
    border: 1px solid var(--glass-border);
}

.timeline-item::before {
    content: '';
    position: absolute;
    right: -25px;
    top: 22px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: 2px solid var(--bg-primary);
}

.timeline-action {
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.timeline-date {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.timeline-user {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* ===== Detail Page ===== */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.info-item {
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.02);
}

[data-bs-theme="light"] .info-item {
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.01);
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.info-value {
    font-weight: 700;
    font-size: 0.95rem;
    word-break: break-word;
    color: var(--text-primary);
}

/* ===== Dashboard Charts ===== */
.chart-container {
    padding: 20px;
}

/* ===== Dashboard V3 ===== */
.dashboard-v3 {
    display: grid;
    gap: 20px;
}

.dashboard-topbar-clean {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 6px;
}

.dashboard-page-title {
    margin: 0 0 6px;
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text-primary);
}

.dashboard-page-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.8;
}

.dashboard-status-note {
    min-width: 180px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    text-align: center;
}

.status-note-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 6px;
}

.status-note-value {
    display: block;
    font-size: 1.8rem;
    line-height: 1;
    font-weight: 800;
    color: var(--text-primary);
}

.dashboard-summary-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
}

.dashboard-summary-card {
    padding: 20px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
}

.summary-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.84rem;
    margin-bottom: 8px;
}

.summary-value {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.summary-foot {
    display: block;
    color: var(--text-secondary);
    font-size: 0.84rem;
    line-height: 1.75;
}

.dashboard-content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.8fr);
    gap: 18px;
}

.dashboard-chart-panel,
.dashboard-facts-panel,
.dashboard-note-panel,
.dashboard-activity-panel {
    padding: 22px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
    background: rgba(17, 24, 39, 0.55);
}

.dashboard-side-panel {
    display: grid;
    gap: 18px;
}

.dashboard-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.dashboard-panel-title {
    margin: 0 0 6px;
    font-size: 1.08rem;
    font-weight: 800;
    color: var(--text-primary);
}

.dashboard-panel-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.86rem;
    line-height: 1.7;
}

.dashboard-status-chart {
    min-height: 320px;
}

.dashboard-chart-panel .apexcharts-legend {
    justify-content: center !important;
    padding-top: 10px !important;
}

.dashboard-chart-panel .apexcharts-legend-series {
    margin: 6px 8px !important;
}

.dashboard-chart-panel .apexcharts-legend-text {
    font-family: 'Tajawal', sans-serif !important;
    font-size: 0.92rem !important;
    font-weight: 700 !important;
    line-height: 1.7 !important;
}

.dashboard-chart-panel .apexcharts-datalabel-label,
.dashboard-chart-panel .apexcharts-datalabel-value,
.dashboard-chart-panel .apexcharts-datalabels-group text {
    font-family: 'Tajawal', sans-serif !important;
}

.dashboard-chart-panel .apexcharts-tooltip {
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 12px !important;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22) !important;
    overflow: hidden;
}

.dashboard-chart-panel .apexcharts-tooltip-title {
    font-family: 'Tajawal', sans-serif !important;
    font-weight: 700 !important;
}

.dashboard-chart-panel .apexcharts-tooltip-series-group {
    font-family: 'Tajawal', sans-serif !important;
}

.dashboard-facts-list {
    display: grid;
    gap: 10px;
}

.dashboard-fact-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.dashboard-fact-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.dashboard-fact-row span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.dashboard-fact-row strong {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.dashboard-note-text {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.9;
    font-size: 0.92rem;
}

.dashboard-activity-list {
    display: grid;
    gap: 10px;
}

.dashboard-activity-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.dashboard-activity-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.dashboard-activity-mark {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(46, 118, 187, 0.12);
    color: var(--accent-secondary);
    flex-shrink: 0;
}

.dashboard-activity-main {
    min-width: 0;
    flex: 1;
}

.dashboard-activity-action {
    display: block;
    margin-bottom: 5px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.dashboard-activity-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.dashboard-empty-state {
    min-height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
}

.dashboard-empty-state i {
    font-size: 2.2rem;
    opacity: 0.3;
}

[data-bs-theme="light"] .dashboard-status-note,
[data-bs-theme="light"] .dashboard-summary-card,
[data-bs-theme="light"] .dashboard-chart-panel,
[data-bs-theme="light"] .dashboard-facts-panel,
[data-bs-theme="light"] .dashboard-note-panel,
[data-bs-theme="light"] .dashboard-activity-panel {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(15, 23, 42, 0.08);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
}

[data-bs-theme="light"] .dashboard-chart-panel .apexcharts-tooltip {
    border-color: rgba(15, 23, 42, 0.08) !important;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08) !important;
}

/* ===== Settings Index Grid ===== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.settings-card {
    padding: 24px;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
}

.settings-card i {
    font-size: 2rem;
    color: var(--accent-primary);
    margin-bottom: 10px;
}

.settings-card h6 {
    margin: 0;
    color: var(--text-primary);
    font-weight: 600;
}

/* ===== Reports Grid ===== */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.report-card {
    padding: 24px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 16px;
}

.report-card i {
    font-size: 2rem;
}

.report-card h6 {
    margin: 0;
    color: var(--text-primary);
    font-weight: 600;
}

.report-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ===== Modal Override ===== */
.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
}

.modal-header {
    border-bottom-color: var(--glass-border);
}

.modal-footer {
    border-top-color: var(--glass-border);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        width: min(88vw, 320px);
        max-width: 320px;
        transform: translateX(100%);
        box-shadow: -18px 0 40px rgba(0, 0, 0, 0.28);
        overflow-x: hidden;
    }

    .main-content {
        margin-right: 0;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .sidebar-brand {
        justify-content: flex-start;
        padding: 16px 18px;
    }

    .sidebar-brand-title {
        display: block;
        opacity: 1;
        width: auto;
        transform: none;
    }

    .sidebar-brand-logo {
        max-width: 52px;
        height: 40px;
        padding: 5px;
        border-radius: 12px;
    }

    .dashboard-topbar-clean,
    .dashboard-panel-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-status-note {
        min-width: 100%;
    }

    .dashboard-summary-grid,
    .dashboard-content-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-status-chart {
        min-height: 300px;
    }

    .sidebar-nav {
        padding: 10px 12px 16px;
    }

    .sidebar-nav .nav-section {
        display: block;
        padding-inline: 10px;
    }

    .sidebar-nav a span,
    .btn-logout span {
        display: inline;
    }

    .sidebar-nav a {
        justify-content: flex-start;
        padding: 13px 14px;
    }

    .btn-logout {
        justify-content: flex-start;
        padding: 12px 14px;
    }

    .topbar {
        padding: 0 14px;
        gap: 10px;
    }

    .topbar-right {
        gap: 10px !important;
        flex: 1;
        justify-content: flex-start;
    }

    .topbar-right .vr {
        margin-inline: 0.25rem !important;
    }

    .user-info {
        font-size: 0.82rem;
    }

    .container-fluid.px-4 {
        padding-right: 1rem !important;
        padding-left: 1rem !important;
    }

    .page-title {
        font-size: 1.2rem;
    }

    .search-bar,
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-bar .form-control,
    .filter-bar .form-select,
    .search-bar .btn,
    .filter-bar .btn,
    .page-header .btn {
        max-width: none;
        width: 100%;
    }

    .table-container {
        border-radius: 14px;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.4s ease forwards;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
}

/* ===== Login Page ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary), #1e1b4b);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand i {
    font-size: 3rem;
    color: var(--accent-primary);
}

.login-brand h2 {
    font-weight: 800;
    margin-top: 10px;
}

/* ===== Portal ===== */
.portal-header {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    padding: 20px 30px;
    border-radius: 0 0 20px 20px;
    margin: -16px -16px 24px;
    color: #fff;
}

.portal-dashboard-shell {
    max-width: 1440px;
}

.portal-brand-logo {
    height: 72px;
    width: auto;
    padding: 8px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    filter: none;
}

.portal-table-wrap {
    overflow-x: auto;
}

[data-bs-theme="light"] .portal-brand-logo {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(148, 163, 184, 0.24);
    filter: none;
}

@media (max-width: 991.98px) {
    .portal-dashboard-shell {
        max-width: 100%;
    }

    .portal-header {
        padding: 18px 20px;
    }

    .portal-brand-block {
        gap: 14px !important;
        align-items: center !important;
    }

    .portal-header-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 767.98px) {
    .portal-header {
        padding: 16px;
        margin: -12px -12px 20px;
    }

    .portal-brand-logo {
        height: 62px;
        padding: 7px;
        border-radius: 16px;
    }

    .portal-brand-block {
        width: 100%;
        gap: 12px !important;
    }

    .portal-brand-block .border-start {
        border-inline-start: none !important;
        padding-inline-start: 0 !important;
    }

    .portal-header-actions {
        justify-content: space-between;
    }

    .portal-table-wrap table {
        min-width: 720px;
    }
}

/* ===== Tom Select Overrides ===== */
.ts-control {
    background: var(--bg-card) !important;
    border: 1px solid var(--glass-border) !important;
    color: var(--text-primary) !important;
    border-radius: 10px !important;
    padding: 10px 14px !important;
    min-height: 46px;
    /* Match standard input height */
    box-shadow: none !important;
}

.ts-control.focus {
    background: var(--bg-card-hover) !important;
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 0 3px var(--accent-glow) !important;
}

.ts-control .item {
    background: var(--accent-primary) !important;
    color: #fff !important;
    border-radius: 4px !important;
    padding: 2px 8px !important;
    border: none !important;
}

.ts-dropdown {
    background: var(--bg-card) !important;
    border: 1px solid var(--glass-border) !important;
    color: var(--text-primary) !important;
    border-radius: 10px !important;
    backdrop-filter: blur(10px);
    margin-top: 4px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
    z-index: 1000 !important;
}

.ts-dropdown .option {
    color: var(--text-primary) !important;
    padding: 8px 12px !important;
}

.ts-dropdown .option.active,
.ts-dropdown .option:hover {
    background: var(--accent-glow) !important;
    color: #fff !important;
}

.ts-control input {
    color: var(--text-primary) !important;
}

/* Light Mode Overrides for Tom Select */
[data-bs-theme="light"] .ts-control {
    background: rgba(255, 255, 255, 0.8) !important;
    border-color: #cbd5e1 !important;
    color: var(--text-primary) !important;
}

[data-bs-theme="light"] .ts-control.focus {
    background: #ffffff !important;
}

[data-bs-theme="light"] .ts-dropdown {
    background: rgba(255, 255, 255, 0.95) !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1) !important;
}

[data-bs-theme="light"] .ts-dropdown .option.active {
    background: rgba(99, 102, 241, 0.1) !important;
    color: var(--accent-primary) !important;
}

/* ===== Custom Nav Tabs ===== */
.custom-tabs {
    border-bottom: 2px solid var(--glass-border);
    gap: 8px;
}

.custom-tabs .nav-link {
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: 12px 12px 0 0;
    padding: 12px 24px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    position: relative;
    margin-bottom: -2px;
}

.custom-tabs .nav-link:hover {
    color: var(--text-primary);
    background: var(--glass);
    border-color: var(--glass-border) var(--glass-border) transparent;
}

.custom-tabs .nav-link.active {
    color: var(--accent-primary);
    background: var(--bg-card);
    border-color: var(--glass-border) var(--glass-border) var(--accent-primary);
    border-bottom-width: 2px;
}

/* ===== Micro-interactions ===== */
.transition-hover {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.2) !important;
    z-index: 2;
}

[data-bs-theme="light"] .hover-lift:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1) !important;
}

/* ===== Accordion Light Mode Fixes ===== */
[data-bs-theme="light"] .accordion-item {
    background: var(--bg-card) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--border-radius) !important;
    margin-bottom: 12px;
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    overflow: hidden;
}

[data-bs-theme="light"] .accordion-button {
    background: transparent !important;
    color: var(--text-primary) !important;
    box-shadow: none !important;
}

[data-bs-theme="light"] .accordion-button:not(.collapsed) {
    background: rgba(99, 102, 241, 0.05) !important;
    border-bottom: 1px solid var(--glass-border);
}
