:root {
    --primary: #4e73df;
    --primary-dark: #3a5bc7;
    --secondary: #858796;
    --success: #1cc88a;
    --danger: #e74a3b;
    --warning: #f6c23e;
    --info: #36b9cc;
    --bg-light: #f8f9fc;
    --bg-sidebar: #2c3e6b;
    --bg-sidebar-hover: #3d5291;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html {
    font-size: 14px;
}

@media (min-width: 768px) {
    html { font-size: 15px; }
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-light);
    margin: 0;
}

/* Login page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-sidebar) 0%, var(--primary) 100%);
}

.login-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.login-card h2 {
    color: var(--bg-sidebar);
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Dashboard layout */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--bg-sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: width 0.2s;
}

.sidebar-brand {
    padding: 1.2rem 1rem;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    text-decoration: none;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.2rem;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: var(--bg-sidebar-hover);
    color: #fff;
    border-left-color: var(--primary);
}

.sidebar-nav li a .nav-icon {
    width: 20px;
    text-align: center;
}

/* Nav groups (collapsible) */
.nav-group > .nav-group-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.2rem;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    cursor: pointer;
}

.nav-group > .nav-group-header:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
    border-left-color: var(--primary);
}

.nav-group > .nav-group-header .nav-group-chevron {
    margin-left: auto;
    font-size: 1.1rem;
    transition: transform 0.2s;
}

.nav-group > .nav-group-header:not(.collapsed) .nav-group-chevron {
    transform: rotate(90deg);
}

.nav-group-items {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0,0,0,0.15);
}

.nav-group-items li a {
    padding-left: 2.5rem !important;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.15);
    font-size: 0.8rem;
    text-align: center;
    color: rgba(255,255,255,0.5);
}

/* Main content */
.main-content {
    margin-left: 250px;
    flex: 1;
    display: flex;
    flex-direction: column;
    /* min-width:0 để .table-responsive bên trong có thể co lại và tự hiện scrollbar ngang */
    min-width: 0;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid #e3e6f0;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
}

.topbar .user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--secondary);
    font-size: 0.9rem;
}

.content-area {
    padding: 1.5rem;
    flex: 1;
    min-width: 0;
}

/* Cards */
.card {
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #e3e6f0;
    font-weight: 600;
    color: var(--primary);
    padding: 0.75rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Tables */
.table {
    font-size: 0.88rem;
}

.table thead th {
    background: var(--bg-light);
    border-bottom: 2px solid var(--primary);
    color: var(--bg-sidebar);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Căn giữa (vertical) mọi ô trong bảng, bao gồm cả nội dung con (badge, button, form...) */
.table > :not(caption) > * > * {
    vertical-align: middle;
}

/* Buttons */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-sm {
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
}

/* Modals */
.modal-header {
    background: var(--primary);
    color: #fff;
    border-radius: 0;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

/* Alerts */
.alert {
    font-size: 0.88rem;
    border-radius: 6px;
}

/* Badge */
.badge-status {
    font-size: 0.75rem;
    padding: 0.3em 0.6em;
    border-radius: 4px;
}

/* Pagination */
.pagination .page-link {
    color: var(--primary);
    font-size: 0.85rem;
}

.pagination .page-item.active .page-link {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* Form focus */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--primary);
}

/* Sidebar toggle button (mobile) */
.sidebar-toggle {
    display: none;
    background: transparent;
    border: 1px solid #e3e6f0;
    color: var(--bg-sidebar);
    font-size: 1.2rem;
    line-height: 1;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    margin-right: auto;
}

.sidebar-toggle:hover {
    background: var(--bg-light);
}

/* Backdrop khi mở sidebar trên mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 99;
}

.sidebar-backdrop.show {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 2px 0 12px rgba(0,0,0,0.25);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .topbar {
        justify-content: flex-start;
    }
}
