/* =========================================================
   HỆ THỐNG QUẢN LÝ CLB TAEKWONDO - FULL STYLE (FINAL)
   HLV NGUYỄN THANH HUY - VTF PORTAL
========================================================== */

:root {
    --tkd-blue: #0b3d91; 
    --tkd-red: #d32f2f;  
    --tkd-gold: #c5a059; 
    --bg-light: #f1f5f9;
    --sidebar-width: 250px;
    --header-height: 60px;
    --transition-speed: 0.3s;
}

/* --- 1. THU NHỎ TỶ LỆ TOÀN HỆ THỐNG (ZOOM 80%) --- */
html {
    font-size: 85%; /* Ép toàn bộ giao diện Bootstrap thu nhỏ lại cho thanh thoát */
}

body { 
    font-family: 'Montserrat', sans-serif; 
    background-color: var(--bg-light); 
    color: #334155; 
    font-size: 0.95rem; /* Tương đương 80% so với ban đầu */
    margin: 0; padding: 0; 
    overflow-x: hidden; 
}
a { text-decoration: none; }
h4, h5, h6 { font-weight: 700; letter-spacing: 0.5px; margin-bottom: 0; }
.form-control-sm, .form-select-sm, .btn-sm { font-size: 0.85rem; border-radius: 4px; box-shadow: none !important; }

/* --- 2. LOADER & LOGIN --- */
.fullscreen-loader {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: #ffffff; z-index: 9999;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    transition: opacity var(--transition-speed) ease;
}

.login-page {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    background: linear-gradient(135deg, #1e293b 0%, #050505 100%);
    z-index: 9998;
}

.auth-card {
    width: 100%; max-width: 380px; margin: 0 20px;
    border-radius: 8px; border-top: 4px solid var(--tkd-blue);
    background: #ffffff; padding: 2.5rem 2rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5); text-align: center;
}

/* --- 3. BỐ CỤC ADMIN & HEADER CỐ ĐỊNH --- */
.admin-header {
    height: var(--header-height); 
    background: #ffffff;
    position: fixed !important; 
    top: 0; left: 0; right: 0; 
    z-index: 1050 !important; 
    border-bottom: 1px solid #e2e8f0; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    padding-right: 15px !important; 
}

.admin-header .d-flex.align-items-center.gap-2 {
    flex-wrap: nowrap;
}

.admin-header .fw-bold.ms-1 {
    white-space: nowrap;
    font-size: 1.1rem !important;
}

.admin-container {
    display: flex; 
    padding-top: var(--header-height); 
    min-height: 100vh; 
    width: 100%;
}

/* --- 4. SIDEBAR & MENU --- */
.admin-sidebar {
    width: var(--sidebar-width); 
    background: #ffffff; 
    border-right: 1px solid #e2e8f0; 
    flex-shrink: 0; 
    z-index: 1040;
    transition: all var(--transition-speed) ease;
    display: flex; 
    flex-direction: column;
    position: fixed; 
    top: var(--header-height); 
    bottom: 0; 
    left: 0;
    overflow-x: hidden; 
    overflow-y: auto;
}

.admin-main {
    flex-grow: 1; 
    /* TẠO KHOẢNG TRỐNG LỀ PHẢI Ở ĐÂY: Trên 25px - Phải 40px - Dưới 25px - Trái 25px */
    padding: 25px 40px 25px 25px; 
    background: var(--bg-light);
    width: calc(100% - var(--sidebar-width)); 
    min-height: calc(100vh - var(--header-height));
    transition: all var(--transition-speed) ease;
    margin-left: var(--sidebar-width);
}

.sidebar-menu-list { padding-top: 15px; }

.sidebar-title { 
    font-size: 0.75rem; 
    color: #94a3b8; 
    font-weight: 800;
    letter-spacing: 1px; 
    padding: 20px 20px 8px; 
    white-space: nowrap;
}

.menu-item { 
    display: flex; 
    align-items: center; 
    padding: 12px 20px; 
    color: #475569; 
    font-weight: 600; 
    font-size: 0.95rem; 
    border-left: 4px solid transparent; 
    transition: 0.2s; 
    white-space: nowrap;
}

.menu-item i { 
    width: 30px; 
    font-size: 1.2rem; 
    text-align: center; 
    margin-right: 10px; 
    color: #64748b; 
}

.menu-item:hover { background: #f8fafc; color: var(--tkd-blue); }
.menu-item.active { background: #e0e7ff; color: var(--tkd-blue); border-left-color: var(--tkd-blue); }
.menu-item.active i { color: var(--tkd-blue); }

/* --- 5. NÚT EMAIL & DROPDOWN HEADER --- */
.admin-header .dropdown-toggle {
    display: flex;
    align-items: center;
    padding-right: 5px;
}

.header-user-info {
    max-width: 140px; /* Giới hạn độ rộng trên điện thoại */
}
.header-user-info span {
    white-space: normal; /* Cho phép rớt dòng nếu email dài */
    word-break: break-all; /* Bẻ chữ để không tràn lề */
    overflow: visible;
}
@media (min-width: 768px) {
    .header-user-info { max-width: 250px; } /* Rộng hơn trên máy tính */
}

/* --- 6. PHẢN HỒI (RESPONSIVE) --- */
.mobile-backdrop {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.5); z-index: 1035;
    opacity: 0; visibility: hidden; transition: all 0.3s ease;
}

/* Giao diện Mobile (< 768px) */
@media (max-width: 767.98px) {
    html { font-size: 95%; } /* Chữ trên điện thoại thì không nên nhỏ quá */
    
    .admin-main { 
        margin-left: 0; 
        width: 100%; 
        padding: 15px; /* Giảm lề trên mobile cho thoáng */
    }
    .admin-sidebar { left: calc(-1 * var(--sidebar-width)); } 
    
    .admin-sidebar.show-mobile { left: 0; }
    .mobile-backdrop.show { opacity: 1; visibility: visible; }
}

/* Giao diện PC (>= 768px) */
@media (min-width: 768px) {
    .mobile-backdrop { display: none !important; }
    .admin-header { padding-right: 25px !important; }
    .admin-header .fw-bold.ms-1 { font-size: 1.2rem !important; }
    #header-user-email { max-width: 250px; } 
    
    .admin-sidebar.collapsed { width: 75px; }
    .admin-sidebar.collapsed .sidebar-title, 
    .admin-sidebar.collapsed .menu-text { display: none; }
    
    .admin-sidebar.collapsed .menu-item { padding: 15px 0; justify-content: center; }
    .admin-sidebar.collapsed .menu-item i { margin-right: 0; font-size: 1.4rem; }
    
    .admin-main.collapsed { 
        margin-left: 75px; 
        width: calc(100% - 75px); 
    }
}

/* --- 7. BẢNG DỮ LIỆU & STICKY HEADER --- */
.table-container {
    width: 100%; max-height: calc(100vh - 170px);
    overflow-y: auto; overflow-x: auto;
    border-radius: 6px; border: 1px solid #cbd5e1; background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.table-container table { margin-bottom: 0; width: 100%; border-collapse: separate; border-spacing: 0; }
.table-container thead th {
    position: sticky; top: 0; z-index: 10;
    background-color: #f8fafc; color: #475569;
    font-size: 0.8rem; font-weight: 700;
    border-bottom: 2px solid #cbd5e1; padding: 12px 10px;
}
.table-container tbody td { padding: 10px; vertical-align: middle; font-size: 0.9rem; color: #334155; border-bottom: 1px solid #f1f5f9; }
.table-container tbody tr:hover { background-color: #f8fafc; }

/* Scrollbar mỏng thẩm mỹ */
.table-container::-webkit-scrollbar { width: 5px; height: 5px; }
.table-container::-webkit-scrollbar-track { background: #f8fafc; }
.table-container::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* --- 8. CÁC THÀNH PHẦN KHÁC --- */
.badge-rank { font-size: 0.8rem; font-weight: 600; padding: 4px 8px; border-radius: 4px; background: #f8fafc; color: #475569; border: 1px solid #cbd5e1; display: inline-block; }
.status-badge-select { appearance: none; -webkit-appearance: none; padding: 4px 12px; border-radius: 50px; font-size: 0.8rem; font-weight: 700; text-align: center; cursor: pointer; border: 1px solid transparent; outline: none; width: 90px; transition: 0.2s; }
.status-badge-select.on { background-color: #e6f4ea; color: #1e8e3e; border-color: #cce8d6; }
.status-badge-select.off { background-color: #fce8e6; color: #d93025; border-color: #fad2cf; }

.sheet-table th { background-color: #f8fafc; font-size: 0.8rem; padding: 10px; border-bottom: 2px solid #cbd5e1; text-transform: uppercase; color: #475569;}
.sheet-table td { padding: 0 !important; border: 1px solid #e2e8f0; vertical-align: middle; position: relative; }
.spreadsheet-input, .spreadsheet-select { width: 100%; border: none; padding: 10px 8px; font-size: 0.9rem; background: transparent; outline: none; border-radius: 0; color: #334155; }
.spreadsheet-input:focus, .spreadsheet-select:focus { background-color: #f0fdf4; box-shadow: inset 0 0 0 2px #22c55e; z-index: 1; position: relative; }
.row-error { box-shadow: inset 0 0 0 2px var(--tkd-red) !important; background-color: #fef2f2; }

.custom-select-wrapper { position: relative; }
.search-select-input { padding-right: 30px !important; cursor: text; background-color: #fff !important; }
.custom-select-list { display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 1060; max-height: 220px; overflow-y: auto; padding: 0; margin: 4px 0 0 0; list-style: none; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
.custom-select-list.show { display: block; }
.custom-select-list li { padding: 10px 15px; cursor: pointer; border-bottom: 1px solid #f1f5f9; font-size: 0.9rem; color: #334155; transition: background 0.1s; }
.custom-select-list li:hover { background-color: #f0f4f8; color: var(--tkd-blue); font-weight: 600; }