/* =========================================================
   GLOBAL — chỉ dùng Nunito duy nhất
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

:root {
    --font-main: 'Nunito', -apple-system, sans-serif;
    --color-bg: #f5f7fb;
    --color-card: #ffffff;
    --color-border: #e5e7eb;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --sidebar-bg: #1f2937;
    --sidebar-text: #d1d5db;
    --sidebar-text-active: #ffffff;
    --sidebar-active-bg: #4f46e5;
    --sidebar-hover-bg: rgba(255,255,255,0.06);
    --header-height: 60px;
    --sidebar-width: 240px;
    --radius: 0.5rem;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -1px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
}

html, body {
    height: 100%;
    margin: 0;
    font-family: var(--font-main) !important;
    background-color: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* Override mọi font monospace của Bootstrap */
code, kbd, pre, samp, .font-monospace, tt {
    font-family: var(--font-main) !important;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-main);
    font-weight: 700;
    color: var(--color-text);
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

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

/* =========================================================
   APP SHELL — sidebar + main
   ========================================================= */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.brand-icon {
    font-size: 1.5rem;
    color: #818cf8;
}

.brand-title {
    color: white;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.2;
}

.brand-sub {
    color: rgba(255,255,255,0.55);
    font-size: 0.75rem;
}

.sidebar-nav {
    padding: 0.75rem 0.5rem;
    flex: 1;
}

.side-section-title {
    color: rgba(255,255,255,0.4);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1rem 0 0.4rem 0.75rem;
    font-weight: 700;
}

.side-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius);
    margin: 0.15rem 0;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.side-link i {
    font-size: 1.05rem;
    width: 1.25rem;
    text-align: center;
}

.side-link:hover {
    background: var(--sidebar-hover-bg);
    color: white;
}

.side-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(79,70,229,0.4);
}

/* ---- Main column ---- */
.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-left { display: flex; gap: 0.5rem; align-items: center; }

.header-page-title {
    flex: 1;
    text-align: right;
    padding: 0 1.5rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    background: #f3f4f6;
    color: #374151;
}

.chip-status .text-success { font-size: 0.55rem; }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: white;
    color: var(--color-text);
    font-weight: 600;
    font-size: 0.85rem;
}

.user-chip:hover { background: #f9fafb; }
.user-chip i.bi-person-circle { font-size: 1.2rem; color: var(--color-primary); }

.app-content {
    padding: 1.5rem;
    flex: 1;
}

/* =========================================================
   KPI CARDS — Gradient sinh động (theo screenshot mẫu)
   ========================================================= */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-height: 130px;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.kpi-card .kpi-icon {
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 7rem;
    opacity: 0.18;
    line-height: 1;
}

.kpi-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.9;
    margin-bottom: 0.25rem;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 0.25rem;
}

.kpi-sub {
    font-size: 0.8rem;
    opacity: 0.85;
    font-weight: 500;
}

/* Variants — gradient theo screenshot */
.kpi-green   { background: linear-gradient(135deg, #11b67c 0%, #0d9968 100%); }
.kpi-orange  { background: linear-gradient(135deg, #f59f00 0%, #e8590c 100%); }
.kpi-blue    { background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); }
.kpi-purple  { background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%); }
.kpi-red     { background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%); }
.kpi-cyan    { background: linear-gradient(135deg, #06b6d4 0%, #0e7490 100%); }

/* =========================================================
   CARDS / PANELS
   ========================================================= */
.panel {
    background: var(--color-card);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.panel-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.panel-body { padding: 1.25rem; }
.panel-body.no-pad { padding: 0; }

/* =========================================================
   TABS — đẹp hơn bootstrap default
   ========================================================= */
.nav-tabs {
    border: none;
    background: white;
    border-radius: 0.75rem 0.75rem 0 0;
    padding: 0.5rem 0.5rem 0;
    box-shadow: var(--shadow-md);
}

.nav-tabs .nav-link {
    color: var(--color-text-muted);
    border: none !important;
    border-radius: 0.5rem 0.5rem 0 0 !important;
    padding: 0.65rem 1.25rem;
    font-weight: 600;
    background: transparent;
}

.nav-tabs .nav-link:hover {
    background: #f9fafb;
    color: var(--color-primary);
}

.nav-tabs .nav-link.active {
    color: var(--color-primary);
    background: #eef2ff;
    border-bottom: 3px solid var(--color-primary) !important;
}

.tab-content-panel {
    background: white;
    border-radius: 0 0 0.75rem 0.75rem;
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
}

/* =========================================================
   FILTER PANEL
   ========================================================= */
.filter-panel {
    background: white;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    border: 1px solid var(--color-border);
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.3rem;
}

.form-control, .form-select {
    font-family: var(--font-main);
    border-radius: 0.5rem;
    border-color: var(--color-border);
    padding: 0.45rem 0.75rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.15rem rgba(79,70,229,0.15);
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn { font-family: var(--font-main); border-radius: 0.5rem; font-weight: 600; padding: 0.5rem 1rem; }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }

.btn-excel {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: white;
    border: none;
}
.btn-excel:hover { background: linear-gradient(135deg, #15803d 0%, #166534 100%); color: white; }

/* =========================================================
   TABLES
   ========================================================= */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

.data-table thead th {
    background: #f9fafb;
    color: #374151;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    padding: 0.75rem 0.75rem;
    border-bottom: 2px solid var(--color-border);
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 5;
}

.data-table tbody td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--color-text);
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table .text-end { text-align: right; }

/* Cột STT cố định, căn giữa, hẹp */
.data-table .col-stt {
    width: 56px;
    text-align: center;
    color: var(--color-text-muted);
    font-weight: 600;
}

.table-wrap {
    max-height: 600px;
    overflow: auto;
    border-radius: 0.5rem;
}

/* =========================================================
   LOGIN PAGE
   ========================================================= */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #db2777 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.login-card-wrap { width: 100%; max-width: 420px; }

.login-card {
    background: white;
    border-radius: 1rem;
    padding: 2.25rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.login-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: 0 8px 16px rgba(79,70,229,0.3);
}

.login-brand h3 { margin: 0 0 0.25rem; font-weight: 800; }

.btn-login {
    padding: 0.65rem;
    font-size: 1rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

.input-group-text {
    background: #f9fafb;
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

.login-footer { margin-top: 1.5rem; }

/* =========================================================
   MISC
   ========================================================= */
.text-muted { color: var(--color-text-muted) !important; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-muted);
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 0.5rem;
    display: block;
}

#blazor-error-ui {
    background: #fef2f2;
    color: #991b1b;
    border-top: 2px solid #dc2626;
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
