/* ============================================================
   ระบบบริหารพัสดุ - เทศบาลเมืองนาสาร
   Modern Admin Theme | Glassmorphism + Gradient
============================================================ */
:root {
    --brand-50:  #eff6ff;
    --brand-100: #dbeafe;
    --brand-300: #93c5fd;
    --brand-500: #3b82f6;
    --brand-600: #2563eb;
    --brand-700: #1d4ed8;
    --brand-800: #1e40af;
    --brand-900: #1e3a8a;
    --accent:    #0ea5e9;
    --success:   #10b981;
    --warning:   #f59e0b;
    --danger:    #ef4444;
    --gray-50:   #f9fafb;
    --gray-100:  #f3f4f6;
    --gray-200:  #e5e7eb;
    --gray-300:  #d1d5db;
    --gray-500:  #6b7280;
    --gray-700:  #374151;
    --gray-900:  #111827;
    --bg-body:   #f4f7fb;
    --bg-card:   #ffffff;
    --text:      #1f2937;
    --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
    --shadow:    0 4px 12px rgba(15,23,42,.08);
    --shadow-lg: 0 12px 32px rgba(15,23,42,.12);
    --radius:    14px;
    --gradient:  linear-gradient(135deg,#1e3a8a 0%,#1d4ed8 50%,#0ea5e9 100%);
}
[data-bs-theme="dark"]{
    --bg-body:#0b1220;
    --bg-card:#111a2e;
    --text:#e5e7eb;
    --gray-100:#1f2a44;
    --gray-200:#2a3756;
    --gray-300:#374868;
    --gray-500:#9ca3af;
    --gray-700:#cbd5e1;
}

* { box-sizing: border-box; }
html, body {
    font-family: 'Sarabun', 'Segoe UI', Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text);
    font-size: 14.5px;
}

/* ============== AUTH (LOGIN) ============== */
.auth-body { position: relative; min-height: 100vh; overflow-x: hidden; }
.auth-bg {
    position: fixed; inset: 0;
    background: var(--gradient);
    z-index: -1;
}
.auth-bg::before, .auth-bg::after {
    content: '';
    position: absolute;
    width: 480px; height: 480px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    filter: blur(80px);
}
.auth-bg::before { top: -120px; left: -120px; }
.auth-bg::after  { bottom: -160px; right: -160px; background: rgba(14,165,233,.25); }
.auth-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
}
.auth-card {
    width: 100%; max-width: 420px;
    background: rgba(255,255,255,.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    box-shadow: 0 25px 60px rgba(0,0,0,.25);
    animation: fadeUp .5s ease;
}
@keyframes fadeUp { from { opacity:0; transform: translateY(20px);} to { opacity:1; transform:none;} }
.auth-logo { text-align: center; margin-bottom: 1.8rem; }
.logo-circle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 76px; height: 76px;
    background: var(--gradient);
    color: #fff; font-size: 32px;
    border-radius: 50%;
    box-shadow: 0 12px 28px rgba(29,78,216,.35);
}
.auth-card h4 { color: var(--brand-800); font-weight: 700; }
.auth-card .form-control { border-radius: 10px; }
.auth-card .btn-primary {
    background: var(--gradient); border: 0;
    border-radius: 10px; padding: .8rem;
    font-weight: 600; letter-spacing: .5px;
    box-shadow: 0 8px 20px rgba(29,78,216,.3);
    transition: .2s;
}
.auth-card .btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 26px rgba(29,78,216,.4); }
.auth-foot { color: var(--gray-500); }

/* ============== APP SHELL ============== */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
    width: 260px; flex-shrink: 0;
    background: linear-gradient(180deg, #0f172a 0%, #1e3a8a 100%);
    color: #cbd5e1;
    position: sticky; top: 0; height: 100vh;
    overflow-y: auto;
    transition: transform .25s ease;
    z-index: 1030;
}
.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

.sidebar-brand {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-link { display: flex; align-items: center; text-decoration: none; color: #fff; gap: .75rem; }
.brand-logo {
    width: 42px; height: 42px;
    background: linear-gradient(135deg,#3b82f6,#0ea5e9);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 20px;
    box-shadow: 0 6px 16px rgba(14,165,233,.4);
}
.brand-title { font-weight: 700; line-height: 1.1; }
.brand-sub { font-size: 11px; color: #94a3b8; }
.sidebar-toggle { color: #fff; padding: .35rem .5rem; }
.sidebar-toggle:hover { color: var(--brand-300); }

.sidebar-nav { padding: 1rem .75rem 2rem; }
.nav-section {
    font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
    color: #64748b; margin: 1rem .5rem .35rem;
}
.sidebar-nav .nav-link {
    color: #cbd5e1; padding: .65rem .85rem;
    border-radius: 10px; display: flex; align-items: center; gap: .75rem;
    font-weight: 500; font-size: 14px; margin-bottom: 2px;
    transition: .18s;
}
.sidebar-nav .nav-link i { width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active {
    background: linear-gradient(90deg, rgba(59,130,246,.18), rgba(14,165,233,.05));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--brand-500);
}
.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1029;
    display: none;
}
@media (max-width: 991px) {
    .app-sidebar {
        position: fixed; left: 0; top: 0; transform: translateX(-100%);
    }
    .app-sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.4); }
    .sidebar-backdrop.open { display: block; }
}

/* ============== MAIN ============== */
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
    height: 64px; background: var(--bg-card);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    position: sticky; top: 0; z-index: 1020;
    box-shadow: var(--shadow-sm);
}
.page-title { font-weight: 600; color: var(--text); }
.btn-icon {
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%; background: transparent; color: var(--gray-500);
    border: 0;
}
.btn-icon:hover { background: var(--gray-100); color: var(--brand-700); }
.theme-icon-light { display: none; }
[data-bs-theme="dark"] .theme-icon-dark { display: none; }
[data-bs-theme="dark"] .theme-icon-light { display: inline; }

.btn-user { display: flex; align-items: center; gap: .6rem; background:transparent; border:0; color: var(--text); }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--gradient); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.btn-user:focus { box-shadow: none; }

.app-content { padding: 1.5rem; flex: 1; }
.app-footer {
    padding: 1rem 1.5rem; font-size: 12.5px; color: var(--gray-500);
    border-top: 1px solid var(--gray-200);
    background: var(--bg-card);
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
}
.breadcrumb { background: transparent; padding: 0; font-size: 13px; }
.breadcrumb-item a { color: var(--brand-700); text-decoration: none; }
.breadcrumb-item.active { color: var(--gray-500); }

/* ============== CARDS / KPI ============== */
.card { background: var(--bg-card); border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card .card-header { background: transparent; border-bottom: 1px solid var(--gray-200); font-weight: 600; }

.kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex; align-items: center; gap: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    position: relative; overflow: hidden;
    transition: .25s;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.kpi-icon {
    width: 56px; height: 56px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 22px; flex-shrink: 0;
}
.kpi-card.kpi-blue   .kpi-icon { background: linear-gradient(135deg,#3b82f6,#1d4ed8); }
.kpi-card.kpi-green  .kpi-icon { background: linear-gradient(135deg,#10b981,#059669); }
.kpi-card.kpi-orange .kpi-icon { background: linear-gradient(135deg,#f59e0b,#d97706); }
.kpi-card.kpi-pink   .kpi-icon { background: linear-gradient(135deg,#ec4899,#be185d); }
.kpi-card.kpi-purple .kpi-icon { background: linear-gradient(135deg,#8b5cf6,#6d28d9); }
.kpi-card.kpi-cyan   .kpi-icon { background: linear-gradient(135deg,#06b6d4,#0e7490); }
.kpi-card.kpi-red    .kpi-icon { background: linear-gradient(135deg,#ef4444,#b91c1c); }

.kpi-label { font-size: 13px; color: var(--gray-500); margin: 0; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--text); margin: 0; line-height: 1.1; }
.kpi-sub { font-size: 11.5px; color: var(--gray-500); margin-top: 2px; }

/* ============== TABLES ============== */
.table { color: var(--text); }
.table > :not(caption) > * > * { padding: .7rem .8rem; }
.table thead th { background: var(--gray-100); font-weight: 600; color: var(--gray-700); border-bottom: 0; }
.table-hover tbody tr:hover { background: var(--brand-50); }
[data-bs-theme="dark"] .table-hover tbody tr:hover { background: rgba(59,130,246,.08); }

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select { border-radius: 8px; }
.dataTables_wrapper .pagination .page-link { color: var(--brand-700); }
.dataTables_wrapper .pagination .page-item.active .page-link { background: var(--brand-700); border-color: var(--brand-700); }

/* ============== BUTTONS ============== */
.btn { border-radius: 10px; font-weight: 500; }
.btn-primary {
    background: var(--gradient);
    border: 0; color: #fff;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-soft-primary { background: var(--brand-50); color: var(--brand-700); border: 0; }
.btn-soft-primary:hover { background: var(--brand-100); }
.btn-soft-danger { background: #fee2e2; color: var(--danger); border: 0; }
.btn-soft-danger:hover { background: #fecaca; }
.btn-soft-success { background: #d1fae5; color: var(--success); border: 0; }

/* ============== FORMS ============== */
.form-control, .form-select { border-radius: 10px; border-color: var(--gray-200); }
.form-control:focus, .form-select:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.form-label { font-weight: 500; font-size: 13.5px; }
.required:after { content: ' *'; color: var(--danger); }

/* ============== BADGES ============== */
.badge-soft { padding: .35rem .6rem; border-radius: 8px; font-weight: 500; font-size: 12px; }
.badge-soft.bg-success { background: #d1fae5 !important; color: var(--success); }
.badge-soft.bg-danger  { background: #fee2e2 !important; color: var(--danger); }
.badge-soft.bg-warning { background: #fef3c7 !important; color: var(--warning); }
.badge-soft.bg-info    { background: #cffafe !important; color: var(--accent); }
.badge-soft.bg-primary { background: var(--brand-50) !important; color: var(--brand-700); }

/* ============== MODALS ============== */
.modal-content { border-radius: var(--radius); border: 0; box-shadow: var(--shadow-lg); }
.modal-header { background: var(--gradient); color: #fff; border-radius: var(--radius) var(--radius) 0 0; }
.modal-header .btn-close { filter: invert(1); }

/* ============== PRINT ============== */
@media print {
    .app-sidebar, .app-topbar, .app-footer, .no-print, .btn { display: none !important; }
    .app-main, .app-content { padding: 0 !important; margin: 0 !important; }
    body { background: #fff !important; }
}
