/* =========================================================================
   HỆ THỐNG ERP ĐIỀU TÀI VẬN TẢI TMS 365 (MODERN SAAS 2026)
   File: css/style.css (Bản Thiết Kế Tối Ưu Tỉ Lệ Cột & Mọi Kích Thước Màn Hình)
   ========================================================================= */

/* 1. RESET & CẤU HÌNH CƠ BẢN */
*, *::before, *::after { box-sizing: border-box; }
body { 
    background-color: #f1f5f9; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; 
    overflow: hidden; 
    margin: 0; 
    padding: 0; 
    color: #1e293b;
    font-size: 0.88rem;
}

/* 2. MÀN HÌNH ĐĂNG NHẬP */
.login-container { 
    height: 100vh; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    background: linear-gradient(135deg, #0f2b48 0%, #061524 100%); 
}
.login-card { 
    background: white; 
    padding: 40px; 
    border-radius: 16px; 
    box-shadow: 0 20px 40px rgba(0,0,0,0.35); 
    width: 100%; 
    max-width: 420px; 
}

/* 3. BỐ CỤC SIDEBAR & MAIN LAYOUT */
#erp-layout { 
    display: none; 
    height: 100vh; 
    width: 100vw; 
    overflow: hidden; 
}

.sidebar { 
    background-color: #0f172a; 
    color: #94a3b8; 
    width: 255px; 
    flex-shrink: 0; 
    display: flex; 
    flex-direction: column; 
    overflow-y: auto; 
    height: 100vh; 
    border-right: 1px solid #1e293b;
}

.sidebar-brand { 
    background: linear-gradient(135deg, #1e3a8a 0%, #0f2b48 100%); 
    padding: 18px 20px; 
    font-size: 1.15rem; 
    font-weight: 800; 
    text-align: center; 
    letter-spacing: 1.5px; 
    color: #ffffff;
}

.sidebar-heading { 
    padding: 12px 18px 6px 18px; 
    font-size: 0.72rem; 
    color: #64748b; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    margin-top: 6px; 
    cursor: pointer; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    transition: 0.2s; 
}
.sidebar-heading:hover { background-color: #1e293b; color: #f8fafc; }
.sidebar-heading .bi-chevron-down { transition: transform 0.25s ease; font-size: 0.75rem; }
.sidebar-heading.collapsed .bi-chevron-down { transform: rotate(-90deg); }
.collapse-menu { padding-left: 0; background-color: #090e1a; }

.nav-item-custom { 
    padding: 9px 18px; 
    color: #94a3b8; 
    text-decoration: none; 
    display: flex;
    align-items: center;
    border-left: 3px solid transparent; 
    transition: all 0.2s ease; 
    font-size: 0.86rem; 
    font-weight: 500;
    cursor: pointer !important; /* 👉 HIỆN BÀN TAY CHỈ 👆 KHI RÊ CHUỘT */
    user-select: none;
}
.nav-item-custom:hover, .nav-item-custom.active { 
    color: #ffffff; 
    background-color: #1e293b; 
    border-left-color: #38bdf8; 
}
.nav-item-custom i { margin-right: 10px; font-size: 1rem; width: 20px; text-align: center; }

/* 4. KHUNG NỘI DUNG CHÍNH (MAIN CONTENT) */
.main-content { 
    flex: 1; 
    height: 100vh; 
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
    min-width: 0; 
    background-color: #f8fafc;
}

/* =========================================================================
   CĂN CHỈNH HEADER & QUẢ CHUÔNG THÔNG BÁO GỌN GÀNG (CHUẨN PIXEL)
   ========================================================================= */
.top-header { 
    background: #ffffff; 
    padding: 0 20px; 
    border-bottom: 1px solid #e2e8f0;
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-shrink: 0; 
    height: 54px;
}

/* Khu vực thông tin tài khoản bên phải */
.top-header > div.d-flex,
.top-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Nút quả chuông thông báo */
.bell-notif-btn {
    position: relative;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    margin-right: 4px;
}
.bell-notif-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

/* Badge số đỏ nằm gọn gàng ở góc trên chuông (không bị che mất số) */
.bell-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #ef4444 !important;
    color: #ffffff !important;
    font-size: 0.65rem !important;
    font-weight: 800 !important;
    padding: 2px 5px !important;
    border-radius: 10px !important;
    border: 2px solid #ffffff !important;
    line-height: 1 !important;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.35);
}

/* Căn chỉnh các nút trên Header đồng bộ */
.top-header .btn {
    height: 32px !important;
    font-size: 0.8rem !important;
    padding: 4px 10px !important;
    display: inline-flex;
    align-items: center;
    border-radius: 6px !important;
}

.card-box { 
    background: #ffffff; 
    border-radius: 12px; 
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02); 
    padding: 14px 18px; 
    margin: 10px 16px; 
    height: calc(100vh - 76px); 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}

.card-box > div[id$="-view"] { 
    display: flex; 
    flex-direction: column; 
    flex: 1; 
    min-height: 0; 
    height: 100%; 
    overflow: hidden; 
}

/* =========================================================================
   5. CĂN CHỈNH THANH CÔNG CỤ, BỘ LỌC & NÚT BẤM (CHUẨN ẨN / HIỆN)
   ========================================================================= */

/* Thanh lọc linh hoạt */
.card-box .d-flex.justify-content-between.align-items-center.mb-2,
.card-box .d-flex.justify-content-between.align-items-center.mb-3 {
    gap: 8px;
    flex-wrap: wrap;
}

/* NÚT CẦN ẨN THÌ PHẢI ẨN TUYỆT ĐỐI */
.card-box button[style*="display: none"],
.card-box .btn[style*="display: none"],
.card-box .d-none,
.d-none {
    display: none !important;
}

/* Định dạng các nút bấm hiển thị */
.card-box button,
.card-box .btn {
    height: 35px;
    font-size: 0.83rem;
    border-radius: 6px;
    white-space: nowrap !important;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    font-weight: 600;
    line-height: normal;
}

/* Các ô tìm kiếm và chọn lọc sạch sẽ, đúng màu */
.card-box input.form-control, 
.card-box select.form-select {
    height: 35px;
    font-size: 0.83rem;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background-color: #ffffff;
    padding: 4px 8px;
    box-shadow: none;
    flex-shrink: 0;
}
.card-box input.form-control:focus, 
.card-box select.form-select:focus {
    border-color: #1F4E79;
    box-shadow: 0 0 0 2px rgba(31,78,121,0.12);
}

/* Độ rộng các ô chọn ngày */
.card-box input[type="date"] {
    min-width: 125px;
    max-width: 135px;
}
.card-box input[type="text"] {
    min-width: 130px;
}

/* Nút Tất Cả & Nút Xuất Excel */
.btn-outline-secondary {
    border-color: #cbd5e1 !important;
    color: #475569 !important;
}
.btn-outline-secondary:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

/* NÚT THAO TÁC CÔNG CỤ */
.btn-success { background-color: #16a34a !important; border-color: #16a34a !important; }
.btn-success:hover { background-color: #15803d !important; }
.btn-primary { background-color: #2563eb !important; border-color: #2563eb !important; }
.btn-primary:hover { background-color: #1d4ed8 !important; }

/* 6. BẢNG DỮ LIỆU THÔNG MINH - TỰ CO GIÃN TỈ LỆ CỘT */
.table-responsive { 
    flex: 1 1 auto; 
    min-height: 0 !important; 
    max-height: calc(100vh - 185px) !important; 
    overflow-y: auto !important; 
    overflow-x: auto !important; 
    margin-bottom: 6px; 
    border: 1px solid #cbd5e1; 
    border-radius: 8px; 
    background: #ffffff;
}

.table-custom { 
    width: 100% !important; 
    margin-bottom: 0; 
    table-layout: auto !important; 
    border-collapse: separate !important; 
    border-spacing: 0 !important; 
}

/* TIÊU ĐỀ BẢNG CHUẨN SLATE NAVY SANG TRỌNG */
.table-dark-custom th { 
    background-color: #1e3a5f !important; 
    color: #ffffff !important; 
    position: sticky; 
    top: 0; 
    z-index: 2; 
    text-align: center !important; 
    vertical-align: middle !important; 
    font-weight: 700; 
    font-size: 0.82rem; 
    letter-spacing: 0.3px;
    white-space: nowrap; 
    padding: 8px 10px; 
    border-right: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-bottom: 2px solid #0f2b48 !important;
}

/* Ô DỮ LIỆU & VIỀN CARO SẮC NÉT */
.table-custom td { 
    vertical-align: middle; 
    padding: 6px 10px; 
    font-size: 0.85rem; 
    border-right: 1px solid #e2e8f0 !important; 
    border-bottom: 1px solid #e2e8f0 !important; 
    background-color: #ffffff;
}

/* CÂN CHỈNH ĐỘ RỘNG CỘT TỰ ĐỘNG THÔNG MINH */
.table-custom th:first-child,
.table-custom td:first-child { 
    width: 46px !important; 
    min-width: 46px !important; 
    max-width: 50px !important; 
    text-align: center !important; 
} /* Cột STT */

.td-nowrap { white-space: nowrap !important; }

/* Cột Lộ Trình / Điểm Đầu / Điểm Cuối tự động giãn rộng */
.td-long { 
    min-width: 220px !important; 
    max-width: 380px !important; 
    white-space: normal !important; 
    line-height: 1.35 !important; 
    word-break: break-word !important; 
}
.td-xl { 
    min-width: 280px !important; 
    white-space: normal !important; 
    line-height: 1.35 !important; 
    word-break: break-word !important; 
}

/* Rê chuột hiệu ứng bóng mờ siêu thanh lịch (1% tint) */
.table-custom tbody tr:hover td {
    background-color: rgba(30, 58, 95, 0.02) !important;
}

/* 7. KHÓA CỐ ĐỊNH CỘT THAO TÁC Ở MÉP PHẢI (STICKY RIGHT) */
.table-dark-custom th:last-child {
    position: sticky !important;
    right: 0 !important;
    top: 0 !important;
    z-index: 5 !important;
    background-color: #1e3a5f !important;
    border-left: 2px solid rgba(255, 255, 255, 0.25) !important;
    box-shadow: -3px 0 6px rgba(0, 0, 0, 0.12) !important;
    width: 115px !important;
    min-width: 115px !important;
}

.table-custom td:has(.action-btn) {
    position: sticky !important;
    right: 0 !important;
    background-color: #ffffff !important;
    border-left: 2px solid #cbd5e1 !important;
    box-shadow: -3px 0 6px rgba(0, 0, 0, 0.06) !important;
    z-index: 3 !important;
    white-space: nowrap !important;
    width: 115px !important;
    min-width: 115px !important;
    text-align: center !important;
}
.table-custom tr:hover td:has(.action-btn) {
    background-color: #f8fafc !important;
}

/* Nút bấm xem/sửa/xóa gọn gàng */
.action-btn { 
    font-size: 0.78rem !important; 
    padding: 0.2rem 0.42rem !important; 
    margin: 0 1px !important; 
    border-radius: 4px !important;
}

/* 8. THANH PHÂN TRANG (PAGINATION) DƯỚI ĐÁY GỌN GÀNG */
.card-box .d-flex.justify-content-between.align-items-center.mt-2,
.card-box .d-flex.justify-content-between.align-items-center.mt-1 {
    padding-top: 4px;
    border-top: 1px solid #f1f5f9;
}
.pagination-badge {
    background-color: #2563eb !important;
    font-weight: 700 !important;
    padding: 6px 14px !important;
    border-radius: 6px !important;
}

/* 9. MODAL THÊM / SỬA FORM & NHÓM QUYỀN */
.modal-content {
    border-radius: 14px !important;
    border: none !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
}
.modal-header {
    background-color: #1e3a5f !important;
    color: white !important;
    padding: 14px 20px !important;
    border-top-left-radius: 14px !important;
    border-top-right-radius: 14px !important;
}
.modal-header .btn-close { filter: brightness(0) invert(1); }

.form-section-card { 
    border: 1px solid #e2e8f0; 
    border-radius: 10px; 
    padding: 14px 16px; 
    margin-bottom: 16px; 
    background-color: #f8fafc; 
}
.form-section-title { 
    font-size: 0.88rem; 
    font-weight: 700; 
    color: #1e3a5f; 
    margin-bottom: 12px; 
    border-bottom: 2px solid #cbd5e1; 
    padding-bottom: 5px; 
    display: flex; 
    align-items: center; 
}
.form-section-title i { margin-right: 8px; font-size: 1.05rem; }

.dynamic-input { 
    background-color: #ffffff; 
    border: 1px solid #cbd5e1; 
    border-radius: 6px; 
    padding: 6px 10px; 
    font-size: 0.88rem; 
}
.dynamic-input:focus { 
    border-color: #2563eb; 
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12); 
    outline: none; 
}
.form-label { 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    color: #475569; 
    margin-bottom: 3px; 
    font-weight: 700; 
}

/* TAB PILLS XANH NAVY (#1F4E79) NGUYÊN BẢN SANG TRỌNG */
.nav-pills-custom { 
    background: #e2e8f0 !important; 
    border-radius: 10px !important; 
    padding: 5px !important; 
    border: 1px solid #cbd5e1 !important;
}

.nav-pills-custom .nav-link { 
    color: #475569 !important; 
    border-radius: 8px !important; 
    transition: all 0.2s ease !important; 
    border: none !important; 
    padding: 8px 18px !important; 
    font-weight: 700 !important; 
    font-size: 0.86rem !important; 
}

/* Tab đang chọn: Màu Xanh Navy Đậm (#1F4E79) kèm bóng đổ nổi 3D */
.nav-pills-custom .nav-link.active { 
    background-color: #1F4E79 !important; 
    color: #ffffff !important; 
    box-shadow: 0 4px 12px rgba(31, 78, 121, 0.35) !important; 
}

/* Rê chuột vào tab chưa chọn */
.nav-pills-custom .nav-link:hover:not(.active) { 
    background-color: #cbd5e1 !important; 
    color: #1F4E79 !important; 
}

.tab-content-custom { padding: 15px 0 0 0; }


/* 10. APP MOBILE TÀI XẾ & MODAL CẢNH BÁO */
#driver-app {
    display: none;
    max-width: 450px;
    margin: 0 auto;
    min-height: 100vh;
    background-color: #f8fafc;
    position: relative;
    box-shadow: 0 0 25px rgba(0,0,0,0.1);
    overflow-y: auto;
}
.drv-header {
    background-color: #1e3a5f;
    color: white;
    padding: 16px 20px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.2);
}
.drv-header h5 { font-weight: 700; font-size: 1.15rem; margin: 0; }
.drv-logout-btn { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); color: white !important; font-size: 1.3rem; background: none; border: none; }
.drv-body { padding: 15px 16px 30px 16px; }
.drv-profile-card { background: white; border-radius: 14px; padding: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.06); border: 1px solid #e2e8f0; margin-top: -8px; }
.drv-avatar { width: 52px; height: 52px; border-radius: 50%; background-color: #e2e8f0; color: #1e3a5f; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; border: 2px solid #cbd5e1; overflow: hidden; flex-shrink: 0; }
.drv-stat-box { background-color: #eff6ff; border-radius: 10px; padding: 12px 10px; text-align: center; border: 1px solid #dbeafe; }
.drv-trip-card { background: white; border-radius: 12px; padding: 14px 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); border: 1px solid #e2e8f0; border-left: 5px solid #2563eb !important; margin-bottom: 12px; }

#customAlertModal { z-index: 2000 !important; }
#alarm-overlay { display: none; }

/* =========================================================================
   TỐI ƯU THANH LỌC MÀN NHẬT KÝ HÀNH TRÌNH CHO LAPTOP 14 INCH (1 HÀNG DUY NHẤT)
   ========================================================================= */

/* Khóa thanh công cụ trên 1 hàng ngang tuyệt đối */
#hanhtrinh-view .d-flex:first-child,
#hanhtrinh-view .card-box > .d-flex:first-child {
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
}

/* Thu gọn tiêu đề bên trong card để nhường chỗ cho các nút */
#hanhtrinh-view .card-title,
#hanhtrinh-view h5,
#hanhtrinh-view h6,
#hanhtrinh-view .d-flex:first-child > div:first-child {
    white-space: nowrap !important;
    font-size: 0.86rem !important;
    font-weight: 700 !important;
    flex-shrink: 1 !important;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Căn chỉnh kích thước nút & ô nhập vừa vặn màn 14 inch */
#hanhtrinh-view input,
#hanhtrinh-view button,
#hanhtrinh-view .btn {
    height: 32px !important;
    font-size: 0.8rem !important;
    padding: 0 8px !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
}

#hanhtrinh-view input[type="date"] {
    min-width: 112px !important;
    max-width: 118px !important;
    padding: 2px 4px !important;
}

#hanhtrinh-view input[type="text"] {
    min-width: 105px !important;
    max-width: 125px !important;
    padding: 2px 8px !important;
}

/* =========================================================================
   TỐI ƯU MODAL PHÂN TÍCH NHIÊN LIỆU VỪA VẶN MÀN HÌNH (CHỐNG TRÀN ĐÁY)
   ========================================================================= */
#fuelAnalyticsModal .modal-dialog {
    max-width: 1050px !important;
    margin: 1.2rem auto !important;
}

#fuelAnalyticsModal .modal-content {
    max-height: 88vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

#fuelAnalyticsModal .modal-body {
    overflow-y: auto !important;
    padding: 12px 18px !important;
    flex: 1 1 auto !important;
}

/* 4 Thẻ KPI trên cùng gọn gàng */
#fuelAnalyticsModal .row.g-2 > div > div,
#fuelAnalyticsModal .card {
    padding: 8px 10px !important;
}

/* KHỐNG CHẾ 2 BẢNG XẾP HẠNG CÓ THANH CUỘN RIÊNG BÊN TRONG */
#fuelAnalyticsModal .table-responsive {
    max-height: 36vh !important;
    min-height: 220px !important;
    overflow-y: auto !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    margin-bottom: 0 !important;
}

/* Tiêu đề 2 bảng xếp hạng dính cố định khi cuộn */
#fuelAnalyticsModal table thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 2 !important;
    background-color: #f8fafc !important;
    border-bottom: 2px solid #cbd5e1 !important;
}