/* =========================================
   1. CORE & BACKGROUND
   ========================================= */
body {
    background: radial-gradient(at 0% 0%, rgba(14, 165, 233, 0.1) 0px, transparent 50%),
                radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%),
                #f8fafc;
    background-attachment: fixed;
    min-height: 100vh;
    margin: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: #334155;
    overflow-x: hidden; /* Ngăn thanh cuộn ngang không mong muốn */
}

/* Glass Panel Standard */
.glass-panel {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
    border-radius: 16px;
}

/* Custom Scrollbar */
.custom-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.custom-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.custom-scroll::-webkit-scrollbar-track { background: transparent; }

/* Animation Pulse */
.btn-pulse { animation: pulse-blue 2s infinite; }
@keyframes pulse-blue {
    0% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(14, 165, 233, 0); }
    100% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0); }
}

/* =========================================
   2. NAVIGATION (SUPER FIXED - ANTI LAG)
   ========================================= */
.sidebar-glass {
    width: 260px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.6);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1050;
}

/* MENU LINK: Cấu hình "đóng băng" kích thước */
.nav-link {
    /* 1. KÍCH THƯỚC TUYỆT ĐỐI */
    height: 48px !important;       /* Chiều cao cố định */
    width: 100% !important;        /* Chiều rộng cố định */
    max-width: 100%;               
    
    /* 2. CẤU TRÚC HỘP (Box Model) */
    box-sizing: border-box;        /* Viền nằm trong kích thước, không làm phình nút */
    margin-bottom: 8px;
    padding: 0 16px;
    
    /* 3. FLEXBOX & CĂN CHỈNH */
    display: flex;
    align-items: center;           /* Căn giữa dọc */
    justify-content: flex-start;   /* Căn trái ngang */
    
    /* 4. XỬ LÝ VĂN BẢN (Chống phình to do text dài) */
    white-space: nowrap;           /* Cấm xuống dòng */
    overflow: hidden;              /* Cắt phần thừa */
    text-overflow: ellipsis;       
    
    /* 5. FONT & MÀU SẮC */
    font-size: 0.95rem;
    font-weight: 600 !important;   /* Đậm cố định ở MỌI TRẠNG THÁI (Fix lag font) */
    color: #64748b;
    
    /* 6. VIỀN CHỜ SẴN */
    border: 1px solid transparent; 
    border-radius: 12px;
    
    /* 7. HIỆU ỨNG (Tắt biến đổi kích thước) */
    transition: background-color 0.1s linear, color 0.1s linear, border-color 0.1s linear;
}

/* ICON: Xử lý xung đột kích thước icon khác nhau */
.nav-link i {
    width: 30px !important;        /* Ép mọi icon về cùng 1 chiều rộng */
    min-width: 30px !important;    
    text-align: center;
    margin-right: 12px;
    font-size: 1.1rem;
    flex-shrink: 0;                /* Không cho icon bị méo */
    transform: none !important;    /* Tắt hiệu ứng nhảy icon */
    transition: none !important;
}

/* --- TRẠNG THÁI HOVER --- */
.nav-link:hover {
    background-color: rgba(14, 165, 233, 0.1);
    color: #0ea5e9;
    border-color: rgba(14, 165, 233, 0.2);
    /* Không thay đổi bất kỳ kích thước nào ở đây */
}

/* --- TRẠNG THÁI ACTIVE --- */
.nav-link.active {
    background-color: #ffffff;
    color: #0284c7;
    border-color: rgba(14, 165, 233, 0.3);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.1);
}

/* Dropdown User */
.dropdown-menu {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

/* =========================================
   3. TABLE & GRID EDITOR (FIX OVERLAP)
   ========================================= */
.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: rgba(255, 255, 255, 0.5);
    margin-bottom: 0;
}

.excel-table { 
    border-collapse: separate; 
    border-spacing: 0; 
    width: 100%;
}

.excel-table td {
    border: 1px solid #f1f5f9;
    vertical-align: middle;
    height: 45px;
    padding: 0 !important;
    background: #fff; /* Nền trắng mặc định */
}

/* HEADER CỐ ĐỊNH (Sticky Top) - NỀN ĐẶC */
.excel-table thead th {
    position: sticky;
    top: 0;
    z-index: 90;
    background: #f8fafc !important; /* MÀU NỀN ĐẶC: Che chữ khi cuộn dọc */
    color: #475569;
    font-size: 0.75rem;
    text-transform: uppercase;
    border-bottom: 2px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    white-space: nowrap;
    vertical-align: middle;
    text-align: center;
    padding: 12px 5px;
}

/* CỘT CỐ ĐỊNH (Sticky Left) - NỀN ĐẶC */
.sticky-col {
    position: sticky;
    left: 0;
    z-index: 50;
    background-color: #ffffff !important; /* MÀU NỀN ĐẶC: Che chữ khi cuộn ngang */
    border-right: 2px solid #e2e8f0 !important;
    box-shadow: 4px 0 10px rgba(0,0,0,0.03);
    width: 250px;
}

/* Ô GIAO ĐIỂM (Góc trên trái) - Cao nhất */
thead th.sticky-col {
    z-index: 100 !important;
    background-color: #f8fafc !important;
}

/* Input Styles */
.cell-input { 
    width: 100%; height: 100%; border: none; background: transparent; 
    padding: 0 5px; text-align: center; font-size: 0.9rem; font-weight: 500; 
    color: #334155; outline: none; transition: background 0.2s;
}
.cell-input:focus { background: #fff; box-shadow: inset 0 0 0 2px #3b82f6; position: relative; z-index: 2; }
.cell-input.text-start { text-align: left; padding-left: 10px; }

/* Trạng thái lưu */
.saving { background: #fef9c3 !important; }
.saved { background: #dcfce7 !important; transition: background 1s ease-out; }
.error { background: #fee2e2 !important; }

/* =========================================
   4. MOBILE & RESPONSIVE
   ========================================= */
/* Header Mobile */
.mobile-header {
    display: none;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 1040;
    height: 60px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.sidebar-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1045;
    display: none; opacity: 0; transition: opacity 0.3s;
}
.sidebar-overlay.show { display: block; opacity: 1; }

@media (max-width: 991px) {
    .mobile-header { display: flex; align-items: center; justify-content: space-between; }
    
    .sidebar-glass {
        position: fixed; top: 0; left: -280px; height: 100vh;
        box-shadow: 5px 0 25px rgba(0,0,0,0.1);
    }
    .sidebar-glass.show { left: 0; }
    
    .flex-grow-1 { margin-top: 60px; padding: 15px !important; }

    /* Grid Editor Mobile */
    .grid-container { height: calc(100vh - 170px) !important; }
    .sticky-col { width: 150px !important; } /* Thu nhỏ cột cố định */
    .via-info-box { padding: 4px 8px; }
    .via-info-box .badge { display: none; } 
    
    .excel-table td, .excel-table th { font-size: 13px; }
    .cell-input { font-size: 13px; }
    
    /* Modal Fullscreen */
    .modal-fullscreen-sm-down { width: 100%; margin: 0; height: 100%; }
    .modal-fullscreen-sm-down .modal-content { height: 100%; border-radius: 0; border: none; }
}

/* =========================================
   5. FORM & UTILS
   ========================================= */
.form-control, .form-select {
    background-color: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(203, 213, 225, 0.8);
}
.form-control:focus, .form-select:focus {
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
    border-color: #38bdf8;
}
.card { background: transparent !important; border: none !important; }

/* Thêm vào cuối style.css */
.hover-scale { transition: transform 0.2s; }
.hover-scale:hover { transform: translateY(-3px); }