/* TOPPION AutoUpdate — admin theme (slate/navy + compact sidebar) */
:root {
    --app-sidebar-w: 180px;
    --app-bg: #F4F6F8;
    --app-sidebar: #0F172A;
    --app-sidebar-hover: #1E293B;
    --app-accent: #2563EB;
    --app-text: #0F172A;
    --app-muted: #64748B;
    --app-border: #E2E8F0;
    --app-card: #FFFFFF;
    --app-radius: 6px;
}

html, body {
    height: 100%;
}

body.app-body {
    margin: 0;
    padding: 0 !important;
    background: var(--app-bg);
    color: var(--app-text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

input, select, textarea {
    max-width: none !important;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--app-sidebar-w);
    background: var(--app-sidebar);
    color: #E2E8F0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform .2s ease;
}

.app-brand {
    display: block;
    padding: 10px 10px 8px;
    color: #fff !important;
    text-decoration: none !important;
    border-bottom: 1px solid rgba(255,255,255,.08);
    text-align: center;
}

.app-brand-logo {
    display: block;
    width: 100%;
    max-width: 80px;
    height: auto;
    margin: 0 auto;
    padding: 8px 10px;
    background: #fff;
    border-radius: 8px;
    object-fit: contain;
}

.app-brand-title {
    display: block;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .02em;
}

.app-brand-sub {
    display: block;
    font-size: 12px;
    color: #94A3B8;
    margin-top: 6px;
}

.app-nav {
    list-style: none;
    margin: 0;
    padding: 8px 0;
    flex: 1;
    overflow-y: auto;
}

.app-nav > li > a,
.app-nav .app-nav-toggle {
    display: block;
    padding: 8px 14px;
    color: #CBD5E1 !important;
    text-decoration: none !important;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.app-nav-icon {
    display: inline-block;
    width: 18px;
    margin-right: 8px;
    text-align: center;
    font-size: 13px;
    opacity: .9;
}

.app-nav .nav-sub .app-nav-icon {
    width: 14px;
    margin-right: 6px;
    font-size: 12px;
}

.app-sidebar-foot .app-nav-icon {
    width: 16px;
    margin-right: 6px;
}

.app-nav > li > a:hover,
.app-nav .app-nav-toggle:hover {
    background: var(--app-sidebar-hover);
    color: #fff !important;
}

.app-nav > li.active > a,
.app-nav > li.active > .app-nav-toggle {
    background: rgba(37, 99, 235, .18);
    color: #fff !important;
    border-left-color: var(--app-accent);
}

.app-nav .nav-sub {
    list-style: none;
    margin: 0;
    padding: 0 0 4px;
    background: rgba(0,0,0,.15);
}

.app-nav .nav-sub a {
    display: block;
    padding: 6px 14px 6px 28px;
    color: #94A3B8 !important;
    font-size: 13px;
    text-decoration: none !important;
}

.app-nav .nav-sub a:hover,
.app-nav .nav-sub li.active a {
    color: #fff !important;
}

.app-sidebar-foot {
    border-top: 1px solid rgba(255,255,255,.08);
    padding: 8px 10px 10px;
}

.app-sidebar-foot a {
    display: block;
    padding: 6px 8px;
    color: #94A3B8 !important;
    font-size: 13px;
    text-decoration: none !important;
    border-radius: 4px;
}

.app-sidebar-foot a:hover {
    background: var(--app-sidebar-hover);
    color: #fff !important;
}

.app-menu-toggle {
    display: block;
    position: fixed;
    top: 8px;
    left: calc(var(--app-sidebar-w) + 8px);
    z-index: 1050;
    border: 0;
    background: var(--app-sidebar);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .25);
}

.app-menu-toggle:hover {
    background: var(--app-sidebar-hover);
}

.app-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 1035;
}

/* ---------- Main ---------- */
.app-main {
    margin-left: var(--app-sidebar-w);
    min-height: 100vh;
    padding: 12px 16px 20px;
    transition: margin-left .2s ease;
}

/* Desktop: thu gọn sidebar */
body.sidebar-collapsed .app-sidebar {
    transform: translateX(-100%);
}

body.sidebar-collapsed .app-main {
    margin-left: 0;
}

body.sidebar-collapsed .app-menu-toggle {
    left: 8px;
}

.app-main .body-content {
    padding: 0 !important;
}

.app-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 10px;
    padding-left: 40px;
    flex-wrap: wrap;
}

.app-page-header h1,
.app-page-header h2,
.app-page-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 650;
    line-height: 1.25;
}

.app-page-header .text-muted,
.app-page-sub {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--app-muted);
}

.app-page-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.app-card {
    background: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    padding: 10px 12px;
    margin-bottom: 10px;
    box-shadow: none;
}

.app-card > .table,
.app-card > .table-responsive {
    margin-bottom: 0;
}

.app-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 8px;
}

.app-footer-note {
    margin-top: 12px;
    font-size: 12px;
    color: var(--app-muted);
}

/* ---------- Bootstrap soft overrides ---------- */
.btn {
    border-radius: 4px;
    font-size: 13px;
    padding: 5px 10px;
    line-height: 1.35;
}

.btn-sm {
    padding: 3px 7px;
    font-size: 12px;
    line-height: 1.3;
}

.btn-xs {
    padding: 2px 6px !important;
    font-size: 11px !important;
    line-height: 1.3 !important;
    border-radius: 3px !important;
}

/* Nút thao tác trong bảng / toolbar trang */
.app-page-actions .btn,
table .btn,
.table .btn,
td .btn,
th .btn {
    padding: 2px 7px;
    font-size: 12px;
    line-height: 1.3;
    border-radius: 3px;
}

.app-page-actions .btn {
    padding: 4px 10px;
    font-size: 13px;
}

/* Dropdown thao tác trong bảng */
.btn-group-actions > .btn {
    padding: 3px 9px;
    font-size: 12px;
}

.btn-group-actions .dropdown-menu,
.app-dropdown-portal {
    min-width: 150px;
    font-size: 13px;
    padding: 4px 0;
    z-index: 1080 !important;
}

.btn-group-actions .dropdown-menu > li > a,
.app-dropdown-portal > li > a {
    padding: 5px 12px;
}

.btn-group-actions .dropdown-menu .glyphicon,
.app-dropdown-portal .glyphicon {
    width: 14px;
    margin-right: 6px;
}

/* Scroll trong vùng bảng — 1 bảng (không dùng DT scrollX/Y để tránh lệch cột) */
.app-table-scroll {
    max-height: calc(100vh - 230px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--app-radius);
    background: #fff;
    padding: 15px 0;
}

/* Khi table trong app-card được DT bọc — scroll phần chứa bảng */
.app-card .dataTables_wrapper {
    width: 100%;
}

.app-card .dt-layout-table,
.app-card .dataTables_wrapper .table-responsive,
.app-card .dt-scroll {
    max-height: calc(100vh - 280px);
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
}

.app-card > .table-responsive {
    max-height: calc(100vh - 230px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: #fff;
}

.app-table-scroll > table,
.app-table-scroll table.dataTable,
.app-card > .table-responsive > table,
.app-card .dt-layout-table table,
.app-card .dataTables_wrapper table.dataTable {
    width: 100% !important;
    margin: 0 !important;
    border-collapse: separate;
    border-spacing: 0;
}

/* Không sticky header / cột thường — chỉ sticky cột Thao tác (cột cuối) */
.app-table-scroll table > thead > tr > th,
.app-card > .table-responsive > table > thead > tr > th,
.app-card .dt-layout-table table > thead > tr > th,
.app-card .dataTables_wrapper table.dataTable > thead > tr > th {
    position: static;
}

.app-table-scroll table > thead > tr > th:last-child,
.app-table-scroll table > tbody > tr > td:last-child,
.app-card > .table-responsive > table > thead > tr > th:last-child,
.app-card > .table-responsive > table > tbody > tr > td:last-child,
.app-card .dataTables_wrapper table.dataTable > thead > tr > th:last-child,
.app-card .dataTables_wrapper table.dataTable > tbody > tr > td:last-child,
.app-card .dt-layout-table table > thead > tr > th:last-child,
.app-card .dt-layout-table table > tbody > tr > td:last-child {
    position: sticky;
    right: 0;
    z-index: 4;
    background: #fff;
    box-shadow: -4px 0 6px -2px rgba(15, 23, 42, .12);
    white-space: nowrap;
}

.app-table-scroll table > thead > tr > th:last-child,
.app-card > .table-responsive > table > thead > tr > th:last-child,
.app-card .dataTables_wrapper table.dataTable > thead > tr > th:last-child,
.app-card .dt-layout-table table > thead > tr > th:last-child {
    z-index: 5;
    background: #F8FAFC;
}

.app-table-scroll .table-striped > tbody > tr:nth-of-type(odd) > td:last-child,
.app-card .table-striped > tbody > tr:nth-of-type(odd) > td:last-child {
    background: #f9f9f9;
}

.app-table-scroll .table-hover > tbody > tr:hover > td:last-child,
.app-card .table-hover > tbody > tr:hover > td:last-child {
    background: #f5f5f5;
}

.app-table-scroll table > tbody > tr.danger > td:last-child,
.app-card table > tbody > tr.danger > td:last-child {
    background: #f2dede;
}

/* Không dùng split head/body của DT */
div.dataTables_scrollHead,
div.dt-scroll-head {
    overflow: visible !important;
}

.btn-primary {
    background: var(--app-accent);
    border-color: #1D4ED8;
}

.btn-primary:hover,
.btn-primary:focus {
    background: #1D4ED8;
    border-color: #1E40AF;
}

.label {
    font-weight: 600;
    border-radius: 4px;
    padding: .25em .5em;
}

.nav-tabs {
    margin-bottom: 8px;
    border-bottom-color: var(--app-border);
}

.nav-tabs > li > a {
    padding: 7px 12px;
    font-size: 13px;
}

.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus {
    border-color: var(--app-border) var(--app-border) transparent;
    font-weight: 600;
}

.table {
    font-size: 13px;
    background: #fff;
}

.table > thead > tr > th,
.table > tbody > tr > th,
.table > tfoot > tr > th,
.table > thead > tr > td,
.table > tbody > tr > td,
.table > tfoot > tr > td {
    padding: 7px 9px;
    vertical-align: middle;
}

.table-condensed > thead > tr > th,
.table-condensed > tbody > tr > th,
.table-condensed > tfoot > tr > th,
.table-condensed > thead > tr > td,
.table-condensed > tbody > tr > td,
.table-condensed > tfoot > tr > td {
    padding: 4px 6px;
}

.table thead tr th {
    text-align: center;
    vertical-align: middle;
    background: #F8FAFC;
    border-bottom: 1px solid var(--app-border);
}

.panel {
    border-radius: var(--app-radius);
    border-color: var(--app-border);
    box-shadow: none;
    margin-bottom: 10px;
}

.panel-heading {
    padding: 8px 12px;
    background: #F8FAFC;
    border-bottom-color: var(--app-border);
}

.panel-body {
    padding: 10px 12px;
}

.panel-title {
    font-size: 14px;
    font-weight: 650;
}

.form-control {
    height: 32px;
    padding: 5px 9px;
    font-size: 13px;
    border-radius: 5px;
    border-color: #CBD5E1;
}

.form-group {
    margin-bottom: 8px;
}

fieldset {
    margin-bottom: 10px;
}

fieldset legend {
    padding: 4px 0 8px;
    font-size: 14px;
    font-weight: 650;
    border-bottom: 1px solid var(--app-border);
    width: 100%;
    margin-bottom: 8px;
}

.alert {
    padding: 8px 12px;
    margin-bottom: 10px;
    border-radius: var(--app-radius);
    font-size: 13px;
}

.well {
    padding: 10px 12px;
    margin-bottom: 10px;
    border-radius: var(--app-radius);
    background: #F8FAFC;
    border: 1px solid var(--app-border);
}

/* DataTables */
.dt-processing {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    text-align: center;
    z-index: 9999;
    background: var(--app-accent);
    color: #fff;
}

div.dataTables_wrapper div.dataTables_length,
div.dataTables_wrapper div.dataTables_filter,
div.dataTables_wrapper div.dataTables_info,
div.dataTables_wrapper div.dataTables_paginate {
    font-size: 13px;
    padding: 4px 0;
}

div.dataTables_wrapper div.dataTables_filter input,
div.dataTables_wrapper div.dataTables_length select {
    height: 30px;
    padding: 3px 7px;
    font-size: 13px;
}

/* Scrollbar */
*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
    background: #eee;
    border-radius: 6px;
}

*::-webkit-scrollbar-thumb:vertical,
*::-webkit-scrollbar-thumb:horizontal {
    background: #406e98;
    border-radius: 6px;
}

*::-webkit-scrollbar-corner {
    background-color: #406e98;
    border-radius: 6px;
}

/* Login */
.login-body {
    min-height: 100vh;
    margin: 0;
    padding: 24px 12px !important;
    background: linear-gradient(160deg, #0F172A 0%, #1E293B 45%, #334155 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 8px;
    padding: 22px 22px 18px;
    border: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 12px 40px rgba(0,0,0,.28);
    text-align: left;
}

.login-logo-wrap {
    text-align: center;
    margin: 0 0 10px;
}

.login-logo {
    display: inline-block;
    max-width: 220px;
    width: 100%;
    height: auto;
}

.login-card h1 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
}

.login-card .login-sub {
    margin: 0 0 16px;
    color: var(--app-muted);
    font-size: 13px;
    text-align: center;
}

.login-card .form-control {
    height: 38px;
    font-size: 14px;
}

.login-card .btn-block {
    padding: 9px 12px;
    font-size: 14px;
    font-weight: 600;
}

/* Mobile */
@media (max-width: 767px) {
    .app-menu-toggle {
        left: 8px;
    }

    .app-sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .app-sidebar-backdrop {
        display: block;
    }

    body.sidebar-collapsed .app-sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-collapsed .app-main {
        margin-left: 0;
    }

    .app-main {
        margin-left: 0;
        padding: 48px 10px 16px;
    }
}
