/* ================================================
   DASHBOARD KINH DOANH - NAMGROUP
   Custom Styles
   ================================================ */

:root {
    --sidebar-width: 250px;
    --sidebar-collapsed: 60px;
    --primary-color: #0d6efd;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #0dcaf0;
    --dark-color: #212529;
    --bg-body: #f0f2f5;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-body);
    overflow-x: hidden;
}

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #1a3a5c 0%, #0d2137 100%);
    color: #fff;
    z-index: 1050;
    transition: width var(--transition-speed) ease;
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 16px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    height: 60px;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    margin-right: 10px;
    flex-shrink: 0;
}

.sidebar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-brand {
    opacity: 0;
}

.sidebar-nav {
    list-style: none;
    padding: 6px 0;
    margin: 0;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
}

/* Sidebar group */
.sidebar-group-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 4px;
    margin-top: 4px;
    cursor: pointer;
    user-select: none;
}

.sidebar-group-label span {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-group-label i.chevron {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.35);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.sidebar-group-label.collapsed-group i.chevron {
    transform: rotate(-90deg);
}

.sidebar-group-items {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.sidebar-group-items.group-hidden {
    max-height: 0 !important;
}

.sidebar.collapsed .sidebar-group-label span,
.sidebar.collapsed .sidebar-group-label i.chevron {
    opacity: 0;
}

.sidebar-item {
    margin: 2px 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-item.active .sidebar-link {
    color: #fff;
    background: rgba(13, 110, 253, 0.4);
    font-weight: 600;
}

.sidebar-link i {
    font-size: 1.2rem;
    margin-right: 12px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.sidebar.collapsed .sidebar-link span {
    opacity: 0;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-speed) ease;
    min-height: 100vh;
}

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

/* ========== TOP NAVBAR ========== */
.top-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 1040;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.page-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--dark-color);
}

/* ========== FILTER BAR ========== */
.filter-bar {
    background: #fff;
    padding: 14px 20px 10px;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.filter-bar .form-label {
    margin-bottom: 2px;
    color: #555;
    font-size: 0.78rem;
}

.filter-bar .form-select,
.filter-bar .form-control {
    font-size: 0.85rem;
    height: 34px;
}

/* Select2 Overrides */
.select2-container--bootstrap-5 .select2-selection {
    min-height: 34px !important;
    font-size: 0.85rem;
    border-color: #dee2e6;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
    font-size: 0.75rem;
    padding: 1px 6px;
}

/* ========== KPI CARDS ========== */
.kpi-card {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border-left: 4px solid transparent;
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.kpi-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.kpi-label {
    font-size: 0.75rem;
    color: #777;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark-color);
    line-height: 1.2;
}

.kpi-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0 16px 8px;
}

/* KPI Color Variants */
.kpi-booking { border-left-color: #6f42c1; }
.kpi-booking .kpi-icon { background: rgba(111, 66, 193, 0.1); color: #6f42c1; }

.kpi-giucho { border-left-color: #fd7e14; }
.kpi-giucho .kpi-icon { background: rgba(253, 126, 20, 0.1); color: #fd7e14; }

.kpi-xngc { border-left-color: #0dcaf0; }
.kpi-xngc .kpi-icon { background: rgba(13, 202, 240, 0.1); color: #0dcaf0; }

.kpi-vbttgd { border-left-color: #ffc107; }
.kpi-vbttgd .kpi-icon { background: rgba(255, 193, 7, 0.1); color: #d4a106; }

.kpi-hdmb { border-left-color: #198754; }
.kpi-hdmb .kpi-icon { background: rgba(25, 135, 84, 0.1); color: #198754; }

.kpi-revenue { border-left-color: #0d6efd; }
.kpi-revenue .kpi-icon { background: rgba(13, 110, 253, 0.1); color: #0d6efd; }

.kpi-revenue-after { border-left-color: #20c997; }
.kpi-revenue-after .kpi-icon { background: rgba(32, 201, 151, 0.1); color: #20c997; }

.kpi-completion { border-left-color: #e35d6a; }
.kpi-completion .kpi-icon { background: rgba(227, 93, 106, 0.1); color: #e35d6a; }

.kpi-absorption { border-left-color: #6610f2; }
.kpi-absorption .kpi-icon { background: rgba(102, 16, 242, 0.1); color: #6610f2; }

/* ========== CHART CARDS ========== */
.chart-card {
    border: none;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.chart-card .card-header {
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 12px 16px;
}

.chart-card .card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--dark-color);
}

.chart-card .card-body {
    padding: 16px;
}

/* ========== ALERTS ========== */
.alert-banner {
    padding: 8px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.alert-dropdown {
    min-width: 340px;
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.alert-dropdown .dropdown-item {
    white-space: normal;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.82rem;
    border-left: 3px solid transparent;
    margin-bottom: 4px;
}

.alert-dropdown .dropdown-item:hover {
    background: #f8f9fa;
}

.alert-dropdown .alert-danger-item { border-left-color: var(--danger-color); }
.alert-dropdown .alert-warning-item { border-left-color: var(--warning-color); }
.alert-dropdown .alert-info-item { border-left-color: var(--info-color); }

/* Alert list in card */
#alertList .list-group-item {
    border-left: 4px solid transparent;
    padding: 10px 16px;
    font-size: 0.82rem;
}

#alertList .list-group-item.alert-danger-item {
    border-left-color: var(--danger-color);
    background: #fff5f5;
}

#alertList .list-group-item.alert-warning-item {
    border-left-color: var(--warning-color);
    background: #fffbf0;
}

#alertList .list-group-item.alert-info-item {
    border-left-color: var(--info-color);
    background: #f0faff;
}

.alert-icon {
    font-size: 1rem;
    margin-right: 8px;
}

/* ========== TABULATOR OVERRIDES ========== */
.tabulator {
    border: none !important;
    font-size: 0.82rem;
}

.tabulator .tabulator-header {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

.tabulator .tabulator-header .tabulator-col {
    border-right: 1px solid #e9ecef;
}

.tabulator .tabulator-header .tabulator-col-title {
    font-weight: 600;
    color: #495057;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tabulator-row {
    border-bottom: 1px solid #f0f0f0;
}

.tabulator-row:hover {
    background: #f0f7ff !important;
}

.tabulator-row.tabulator-row-even {
    background: #fafafa;
}

/* Progress bar in grid */
.grid-progress-bar {
    height: 20px;
    border-radius: 4px;
    overflow: hidden;
    background: #e9ecef;
    position: relative;
}

.grid-progress-bar .fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

.grid-progress-bar .fill-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.72rem;
    font-weight: 600;
    color: #333;
}

/* ========== UTILITY ========== */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-collapsed);
    }

    .sidebar .sidebar-brand,
    .sidebar .sidebar-link span {
        opacity: 0;
    }

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

    .top-navbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .kpi-value {
        font-size: 1.2rem;
    }

    .filter-bar {
        padding: 10px 12px 8px;
    }
}

@media (max-width: 576px) {
    .sidebar {
        width: 0;
        overflow: hidden;
    }

    .sidebar.mobile-open {
        width: var(--sidebar-width);
    }

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

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

.kpi-card {
    animation: fadeInUp 0.4s ease forwards;
}

.kpi-card:nth-child(1) { animation-delay: 0s; }
.kpi-card:nth-child(2) { animation-delay: 0.05s; }
.kpi-card:nth-child(3) { animation-delay: 0.1s; }
.kpi-card:nth-child(4) { animation-delay: 0.15s; }
.kpi-card:nth-child(5) { animation-delay: 0.2s; }

.chart-card {
    animation: fadeInUp 0.5s ease forwards;
    animation-delay: 0.2s;
    opacity: 0;
    animation-fill-mode: forwards;
}

/* ========== LOADING SPINNER ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}
