@import url('/vendor/fonts/local-fonts.css');

:root {
    /* Color Palette - Premium SaaS */
    --bg-body: #f0f2f5;
    --bg-surface: #ffffff;
    --bg-surface-subtle: #f8fafc;
    
    --primary: #3b82f6; /* Vivid Blue */
    --primary-dark: #2563eb;
    --primary-light: #eff6ff;
    
    --text-primary: #1e293b; /* Slate 800 */
    --text-secondary: #64748b; /* Slate 500 */
    --text-tertiary: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    /* Shadows & Elevation */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Layout */
    --header-height: 70px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* --- Top Navigation Bar (The "Command Center") --- */
.app-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 1030;
    padding: 0 24px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.header-wrap {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* .app-title::before removed to use actual image */

.header-actions .btn {
    border-radius: 50px; /* Pill shape buttons in header */
    font-size: 13px;
    padding: 6px 16px;
}

/* --- Layout Container --- */
.main-container {
    max-width: 1600px; /* Wide screen support */
    margin: 0 auto;
    padding: 24px;
}

/* --- Tabs as Navigation (Pills) --- */
.nav-tabs {
    border: none;
    background: var(--bg-surface);
    padding: 6px;
    border-radius: 12px;
    display: inline-flex;
    gap: 4px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}

.nav-tabs .nav-link {
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
    padding: 8px 16px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.nav-tabs .nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-surface-subtle);
}

.nav-tabs .nav-link.active {
    background: var(--text-primary); /* Dark active tab */
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.nav-tabs .nav-link i {
    margin-right: 6px;
}

/* --- Controls / Filter Bar --- */
.controls {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.controls label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 700;
    margin-bottom: 6px;
    display: block;
}

.form-control, .form-select, .select2-container .select2-selection--single {
    background-color: var(--bg-surface-subtle);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    padding: 10px 12px;
    height: auto;
    min-height: 42px;
    box-shadow: none;
    transition: all 0.2s;
}

.form-control:focus, .form-select:focus {
    background-color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Select2 Fixes */
.select2-container .select2-selection--single { height: 42px !important; display: flex; align-items: center; }
.select2-container--bootstrap-5 .select2-selection { border-color: var(--border-color) !important; }
.select2-container--bootstrap-5 .select2-dropdown { border-color: var(--border-color); box-shadow: var(--shadow-lg); border-radius: 12px; overflow: hidden; padding: 5px;}

/* --- KPI Cards --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(0,0,0,0.03);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 100px; height: 100px;
    background: radial-gradient(circle at top right, var(--primary-light), transparent 70%);
    opacity: 0.5;
}

/* --- Overview meta bar --- */
body[data-page="dashboard"] .overview-meta-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: var(--shadow-sm);
}

body[data-page="dashboard"] .overview-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg-surface-subtle);
    border: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-primary);
    max-width: min(320px, 90vw);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body[data-page="dashboard"] .overview-chip--muted {
    color: var(--text-secondary);
}

/* --- ApexCharts tooltip safety --- */
body[data-page="dashboard"] .apexcharts-canvas {
    overflow: visible !important;
}

body[data-page="dashboard"] .apexcharts-tooltip {
    max-width: min(360px, 90vw);
    white-space: normal;
    word-break: break-word;
    box-shadow: var(--shadow-lg);
    border-radius: 10px;
    z-index: 2000;
}

body[data-page="dashboard"] .apexcharts-tooltip-title {
    white-space: normal;
}

.kpi-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    margin-bottom: 4px;
    display: block;
}

.kpi-trend {
    font-size: 13px;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* --- Charts Containers --- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h6 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

    padding: 4px;
}

/* --- Modern Tables --- */
.table-responsive {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background: var(--bg-surface-subtle);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table tbody td {
    padding: 4px 4px; /* Reduced padding as requested */
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 13px;
    vertical-align: middle;
}

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

.table-hover tbody tr:hover {
    background-color: var(--primary-light);
}

/* Numeric columns should look monospaced for easier reading */
.table td.numeric, 
.table td:nth-child(n+4) { /* Heuristic for data columns */
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

/* Styles for specific analytics list items to reduce font size on desktop */
.card .list-group-item {
    font-size: 13px; /* Slightly smaller font for list items */
    padding: 8px 16px;
}

/* --- Buttons --- */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
    font-weight: 600;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.4);
}

.btn-outline-secondary {
    color: var(--text-primary);
    border-color: var(--border-color);
    background: #fff;
}

.btn-outline-secondary:hover {
    background: var(--bg-surface-subtle);
    border-color: var(--text-secondary);
    color: #000;
}

/* Select2 Dropdown Options Customization */
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option {
    padding: .175rem .075rem;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 900px) {
    .main-container { padding: 12px; }
    .header-wrap { flex-direction: column; gap: 10px; align-items: flex-start; }
    .header-actions { width: 100%; display: flex; justify-content: space-between; }
    .nav-tabs { width: 100%; justify-content: flex-start; padding: 4px; margin-bottom: 16px; }
    .controls { padding: 16px; }
    .app-header { height: auto; padding: 12px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .kpi-card { padding: 16px; }
    .kpi-value { font-size: 20px; }
    /* Horizontal Scroll for tables on mobile */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* Compact desktop: keep every dashboard navigation item visible at 100% zoom. */
@media (min-width: 901px) and (max-width: 1400px) {
    body[data-page="dashboard"] .main-container {
        width: 100%;
        max-width: none;
        padding-left: 16px;
        padding-right: 16px;
    }
    body[data-page="dashboard"] #nav-tab {
        display: flex;
        width: 100%;
        max-width: 100%;
        gap: 2px;
        overflow-x: hidden;
        justify-content: space-between;
    }
    body[data-page="dashboard"] #nav-tab .nav-link {
        flex: 0 1 auto;
        min-width: 0;
        font-size: 12px;
        padding: .25rem .35rem !important;
        white-space: nowrap;
    }
    body[data-page="dashboard"] #nav-tab #nav-refresh-link {
        padding-left: .35rem !important;
    }
}
