/* Global font and variables */
:root {
    --primary: #0c4da1;
    --primary-600: #0e5bc3;
    --primary-100: #e6f0ff;
    --text: #1d2433;
    --muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f5f7fb;
    --card: #ffffff;
    --radius: 14px;
    --shadow: 0 6px 30px rgba(12, 77, 161, 0.15);
}

@font-face {
    font-family: "Inter var";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: local("Inter");
}
html {
    font-size: 14px;
}
body {
    font-family: "Inter var", "Sarabun", "Prompt", system-ui, -apple-system,
        "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Thai",
        "Noto Sans", "Liberation Sans", sans-serif;
    color: var(--text);
    background: var(--bg);
}

/* App shell */
.app-shell {
    display: flex;
    min-height: 100vh;
}
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Sidebar */
.sidebar {
    position: sticky;
    top: 0;
    align-self: flex-start;
    width: 260px;
    color: #fff;
    min-height: 100vh;
    background: linear-gradient(180deg, #0c4da1 0%, #0b3f85 100%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    overflow-x: hidden;
}
.sidebar .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.sidebar .logo-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.sidebar .logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
}
.sidebar .brand {
    font-weight: 700;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.sidebar-menu {
    padding: 10px;
}
.sidebar-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.sidebar-menu .menu-item {
    margin: 4px 0;
}
.sidebar-menu .menu-item > a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #e7ecf5;
    text-decoration: none;
    padding: 12px;
    border-radius: 10px;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}
.sidebar-menu .menu-item > a .fa-solid,
.sidebar-menu .menu-item > a .fa-regular {
    width: 18px;
    flex-shrink: 0;
    text-align: center;
}
.sidebar-menu .menu-item.active > a {
    background: #ffffff22;
    color: #fff;
}
.sidebar-menu .menu-item > a:hover {
    background: #ffffff1a;
    color: #fff;
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    z-index: 1000;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.profile {
    position: relative;
}
.profile-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
}
.profile-btn .avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #eceff7;
}
.profile-btn .name {
    font-weight: 600;
}
.profile-menu {
    position: absolute;
    right: 0;
    top: 42px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    min-width: 180px;
    display: none;
    overflow: hidden;
}
.profile-menu.show {
    display: block;
}
.profile-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    color: var(--text);
    text-decoration: none;
    background: #fff;
    border: 0;
    cursor: pointer;
    font-size: inherit;
    text-align: left;
}
.profile-item:hover {
    background: #f8fafc;
}
.profile-item.danger {
    color: #dc2626;
}

/* Content */
.app-content {
    padding: 20px;
}
@media (min-width: 992px) {
    .app-content {
        padding: 28px;
    }
}
.page-header {
    margin-bottom: 18px;
}
.page-title-text {
    font-size: 20px;
    font-weight: 800;
}

/* Cards */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
    --bs-card-cap-padding-y: 1.5rem !important;
    --bs-card-cap-padding-x: 2.3rem !important;
    --bs-card-spacer-y: 2.3rem !important;
    --bs-card-spacer-x: 2.3rem !important;
}
.custom-card-header {
    background: linear-gradient(180deg, #f9fbff 0%, #f5f7fb 100%);
    border-bottom: 1px solid var(--border);
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}
.stat-card .card-body {
    display: flex;
    align-items: center;
    gap: 14px;
}
.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}
.bg-primary-soft {
    background: rgba(12, 77, 161, 0.12);
}
.stat-content .stat-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.stat-content .stat-value {
    font-weight: 800;
    font-size: 20px;
}

/* DataTables theme */
table.data-table {
    --dt-border: #e6eaf2;
    --dt-head-bg: #f8f9fb;
    --dt-hover: #f2f6ff;
    font-size: 13px !important;
}
table.data-table thead th {
    background: var(--dt-head-bg);
    border-bottom: 1px solid var(--dt-border) !important;
}
table.data-table tbody tr:hover {
    background: var(--dt-hover);
}

.dataTables_filter{
    margin-bottom: 20px !important;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.45rem 0.75rem;
}
.dataTables_wrapper .dataTables_filter label {
    font-weight: 600;
    color: var(--muted);
    font-size: 13px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border: 1px solid var(--border) !important;
    background: #fff !important;
    color: var(--text) !important;
    border-radius: 10px !important;
    margin: 0 2px;
    padding: 0.3rem 0.6rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    color: #fff !important;
    border-color: var(--primary) !important;
}
.dt-btn.btn-outline {
    border: 1px solid var(--primary);
    color: var(--primary);
    background: #fff;
    border-radius: 10px;
    padding: 0.35rem 0.7rem;
}
.dt-btn.btn-outline:hover {
    background: var(--primary);
    color: #fff;
}

/* Utilities */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    filter: brightness(0.95);
}
.btn-light {
    background: #fff;
    border-color: var(--border);
}
