/* CSS Variables - Bảng màu & Kích thước chuẩn */
:root {
    --primary-color: #4361ee;
    --primary-hover: #3a56d4;
    --secondary-color: #7209b7;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #6c757d;
    --border-color: #ced4da; /* Tối hơn để viền rõ hơn */
    --danger-color: #ef233c;
    --success-color: #2ecc71;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 4px 6px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 15px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    font-size: 16px;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

/* Auth Layout */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    padding: 20px;
}

.auth-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.5s ease-out;
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 25px;
    color: var(--text-main);
    font-weight: 700;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 16px;
    transition: var(--transition);
    background-color: #fafafa;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
    background-color: #fff;
}

.btn {
    display: inline-block;
    font-weight: 500;
    text-align: center;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.w-100 {
    width: 100%;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.alert {
    padding: 15px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
}
.alert-danger {
    background-color: #ffe5e5;
    color: var(--danger-color);
    border: 1px solid #ffcccc;
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    flex: 1;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--card-bg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 100;
    height: 100vh;
    position: sticky;
    top: 0;
}
.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
}
.sidebar-menu {
    list-style: none;
    padding: 15px 0;
    flex: 1;
    overflow-y: auto;
}
.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 12px 25px;
    color: var(--text-muted);
    font-weight: 500;
}
.sidebar-menu li a i {
    margin-right: 15px;
    font-size: 1.2rem;
}
.sidebar-menu li a:hover, .sidebar-menu li.active a {
    background-color: rgba(67, 97, 238, 0.05);
    color: var(--primary-color);
    border-right: 4px solid var(--primary-color);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    min-width: 0;
}
.topbar {
    background-color: var(--card-bg);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-main);
}
.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}
.user-profile span {
    font-weight: 500;
}
.content-wrapper {
    padding: 30px;
    flex: 1;
}

/* Cards & Grid */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.stat-card {
    background-color: var(--card-bg);
    padding: 25px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
}
.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}
.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}
.icon-blue { background: rgba(67, 97, 238, 0.1); color: var(--primary-color); }
.icon-purple { background: rgba(114, 9, 183, 0.1); color: var(--secondary-color); }
.icon-green { background: rgba(46, 204, 113, 0.1); color: var(--success-color); }

.stat-info h3 {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 5px;
}
.stat-info p {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
}

/* Responsive */
@media (max-width: 991px) {
    .menu-toggle {
        display: block;
    }
    .sidebar {
        position: fixed;
        height: 100vh;
        left: -260px; /* Ẩn mặc định trên mobile */
    }
    .sidebar.active {
        left: 0;
    }
    .content-wrapper {
        padding: 15px;
    }
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tables */
.table-responsive { overflow-x: auto; margin-top: 20px; }
.table { width: 100%; border-collapse: collapse; background: var(--card-bg); border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow-sm); }
.table th, .table td { padding: 15px; text-align: left; border-bottom: 1px solid var(--border-color); }
.table th { background-color: rgba(67, 97, 238, 0.05); font-weight: 600; color: var(--text-main); }
.table tr:hover { background-color: #fcfcfc; }
.badge { padding: 5px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; display: inline-block; }
.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 4px; }
.btn-warning { background-color: #f1c40f; color: #fff; }

/* Flex Utilities */
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.gap-2 { gap: 10px; }

/* Action Menu (Three dots) */
.action-menu { position: relative; display: inline-block; }
.action-btn { background: none; border: none; cursor: pointer; padding: 5px 10px; font-size: 18px; color: var(--text-muted); }
.action-btn:hover { color: var(--primary-color); }
.action-dropdown { display: none; position: absolute; right: 0; background: var(--card-bg); min-width: 120px; box-shadow: var(--shadow-md); border-radius: var(--radius-sm); z-index: 10; border: 1px solid var(--border-color); overflow: hidden; }
.action-dropdown.show { display: block; animation: fadeIn 0.2s; }
.action-dropdown button, .action-dropdown a { display: block; width: 100%; text-align: left; padding: 10px 15px; border: none; background: none; cursor: pointer; color: var(--text-main); font-size: 14px; }
.action-dropdown button:hover, .action-dropdown a:hover { background: rgba(67, 97, 238, 0.05); color: var(--primary-color); }
.action-dropdown .text-danger:hover { background: #ffe5e5; color: var(--danger-color); }

/* Row selection and warning styles */
tr.row-selected td {
    background-color: #dbeafe !important;
}
tr.row-warning td {
    background-color: #fef2f2;
}
tr.row-selected.row-warning td {
    background-color: #dbeafe !important;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.modal-content-box {
    box-sizing: border-box !important;
    max-width: 600px;
    margin: 0 auto;
    padding: 25px;
}

/* Mobile Table as Cards & Form Adjustments */
@media (max-width: 768px) {
    .table:not(.table-compact) thead { display: none; }
    .table:not(.table-compact), .table:not(.table-compact) tbody, .table:not(.table-compact) tr, .table:not(.table-compact) td { display: block; width: 100%; }
    .table:not(.table-compact) tr { margin-bottom: 15px; border: 1px solid var(--border-color); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; background: #fff; }
    .table:not(.table-compact) td { 
        display: flex; 
        justify-content: space-between; 
        align-items: center; 
        padding: 10px 15px; 
        text-align: right; 
        border-bottom: 1px solid #f1f1f1; 
        border-top: none;
        word-break: break-word;
    }
    .table:not(.table-compact) td:last-child { border-bottom: none; }
    .table:not(.table-compact) td::before { 
        content: attr(data-label); 
        text-align: left; 
        font-weight: 600; 
        color: var(--text-muted); 
        margin-right: 15px;
        flex-shrink: 0;
        max-width: 50%;
    }
    
    .form-group { grid-column: 1 / -1; margin-bottom: 15px; }
    #formContainer { padding: 15px !important; }
    
    .hide-on-mobile { display: none !important; }
    
    table.table-compact th, table.table-compact td {
        padding: 8px 4px !important;
        font-size: 13px;
        word-break: break-word;
    }
    
    .modal-grid { grid-template-columns: 1fr !important; }
    .modal-content-box { width: 95% !important; max-width: 95% !important; padding: 15px !important; }
}
