/* ==========================================================
   หลังบ้านระบบรับสมัคร — วิทยาลัยเทคนิคหนองคาย
   รองรับ คอมพิวเตอร์ / แท็บเล็ต / มือถือ
   ========================================================== */
:root {
    --nk-navy: #0f2742;
    --nk-navy-2: #17365c;
    --nk-accent: #f5a524;
    --nk-blue: #1d6fd8;
    --nk-bg: #f2f5f9;
    --nk-sidebar-w: 272px;
    --bs-body-font-family: 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

html { -webkit-text-size-adjust: 100%; }
body.admin-body { background: var(--nk-bg); font-family: var(--bs-body-font-family); font-size: 0.95rem; }

/* ---------- Sidebar ---------- */
.admin-sidebar {
    background: linear-gradient(180deg, var(--nk-navy) 0%, var(--nk-navy-2) 100%) !important;
    color: #fff;
    --bs-offcanvas-width: 290px;
}
.admin-sidebar .brand {
    display: flex; align-items: center; gap: .75rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo {
    width: 44px; height: 44px; border-radius: 12px; flex: none;
    display: grid; place-items: center; font-size: 1.5rem;
    background: var(--nk-accent); color: var(--nk-navy);
}
.brand-title { font-weight: 600; line-height: 1.2; color: #fff; }
.brand-sub { font-size: .75rem; color: rgba(255,255,255,.6); }

.menu-scroll { overflow-y: auto; padding: .5rem .75rem 1rem; }
.menu-group {
    font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
    color: rgba(255,255,255,.45); padding: 1rem .75rem .35rem;
}
.admin-sidebar .nav-link {
    display: flex; align-items: center; gap: .7rem;
    color: rgba(255,255,255,.82); border-radius: .6rem;
    padding: .55rem .75rem; min-height: 44px; /* พื้นที่แตะสำหรับมือถือ/แท็บเล็ต */
}
.admin-sidebar .nav-link i { font-size: 1.1rem; width: 1.25rem; text-align: center; }
.admin-sidebar .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-sidebar .nav-link.active { background: var(--nk-accent); color: var(--nk-navy); font-weight: 600; }
.admin-sidebar .nav-link.disabled { opacity: .45; pointer-events: none; }
.admin-sidebar .badge.soon { background: rgba(255,255,255,.14); font-weight: 400; font-size: .65rem; }

.sidebar-user { padding: 1rem 1.25rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); }
.avatar {
    width: 40px; height: 40px; border-radius: 50%; flex: none;
    background: var(--nk-blue); color: #fff; font-weight: 600;
    display: grid; place-items: center;
}

/* ---------- Topbar มือถือ ---------- */
.admin-topbar { background: var(--nk-navy); position: sticky; top: 0; z-index: 1030; padding: .6rem 0; }

/* ---------- Layout หลัก ---------- */
.admin-main { min-height: 100vh; display: flex; flex-direction: column; }
.admin-content { padding: 1rem; flex: 1; }
.page-head {
    align-items: center; justify-content: space-between;
    padding: 1.1rem 1.75rem; background: #fff; border-bottom: 1px solid #e3e8ef;
}
.admin-footer { text-align: center; color: #8793a5; font-size: .8rem; padding: 1rem; }

@media (min-width: 992px) {
    .admin-sidebar {
        position: fixed !important; top: 0; bottom: 0; left: 0;
        width: var(--nk-sidebar-w) !important; height: 100vh !important;
        visibility: visible !important; transform: none !important;
        background: linear-gradient(180deg, var(--nk-navy) 0%, var(--nk-navy-2) 100%) !important;
        z-index: 1020;
    }
    .admin-main { margin-left: var(--nk-sidebar-w); }
    .admin-content { padding: 1.5rem 1.75rem; }
}

/* ---------- การ์ด / ตาราง ---------- */
.card { border: 0; border-radius: .9rem; box-shadow: 0 1px 3px rgba(15,39,66,.07), 0 4px 14px rgba(15,39,66,.04); }
.card-header { background: transparent; border-bottom: 1px solid #edf0f5; font-weight: 600; padding: .9rem 1.1rem; }

.stat-card { position: relative; overflow: hidden; }
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.4rem;
}
.stat-card .stat-num { font-size: 1.9rem; font-weight: 700; line-height: 1.1; color: var(--nk-navy); }
.stat-card .stat-label { color: #6b7789; font-size: .85rem; }

table.dataTable { width: 100% !important; }
table.dataTable thead th { background: #f6f8fb; color: #475467; font-weight: 600; white-space: nowrap; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select { border-radius: .5rem; }
.dataTables_wrapper .page-link { min-width: 38px; text-align: center; }

/* ---------- ฟอร์มและ Modal (ปุ่มใหญ่พอสำหรับแท็บเล็ต) ---------- */
.form-control, .form-select { border-radius: .55rem; min-height: 42px; }
.btn { border-radius: .55rem; }
.modal-content { border: 0; border-radius: 1rem; }
.modal-header { background: var(--nk-navy); color: #fff; border-radius: 1rem 1rem 0 0; }
.modal-header .btn-close { filter: invert(1) grayscale(1) brightness(2); }
.form-label { font-weight: 500; font-size: .9rem; }
.required::after { content: ' *'; color: #dc3545; }

@media (max-width: 575.98px) {
    .modal-dialog { margin: .5rem; }
    .btn-action-group .btn { padding: .4rem .6rem; }
}

/* ---------- หน้า Login / Install ---------- */
.auth-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 1.25rem;
    background:
        radial-gradient(circle at 15% 20%, rgba(245,165,36,.25), transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(29,111,216,.35), transparent 45%),
        linear-gradient(135deg, var(--nk-navy), var(--nk-navy-2));
}
.auth-card { width: 100%; max-width: 440px; border-radius: 1.25rem; }
.auth-card .auth-logo {
    width: 68px; height: 68px; border-radius: 18px; margin: 0 auto 1rem;
    display: grid; place-items: center; font-size: 2.1rem;
    background: var(--nk-accent); color: var(--nk-navy);
}

/* ---------- CRUD Modal ---------- */
.form-section {
    margin: .5rem 0 0; padding-bottom: .4rem; border-bottom: 1px dashed #d5dbe5;
    color: var(--nk-navy); font-weight: 600;
}
.checks-box { background: #f8fafc; border: 1px solid #e3e8ef; border-radius: .6rem; margin: 0; padding: .6rem .75rem .75rem; }
.checks-box .form-check-input { width: 1.15em; height: 1.15em; }
.img-prev img { max-height: 120px; max-width: 100%; }
img.thumb { height: 40px; width: 64px; object-fit: cover; border-radius: .4rem; border: 1px solid #e3e8ef; }
.color-dot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0,0,0,.2); vertical-align: -3px; }
.btn-action-group .btn { min-width: 36px; min-height: 34px; }

/* เมนูข้างเลื่อนได้เมื่อจอเตี้ย โดยปุ่มออกจากระบบอยู่ล่างสุดเสมอ */
.admin-sidebar .offcanvas-body { min-height: 0; overflow: hidden; }
.admin-sidebar .menu-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.admin-sidebar .brand, .admin-sidebar .sidebar-user { flex-shrink: 0; }
@media (min-width: 992px) { .admin-sidebar { display: flex; flex-direction: column; } .admin-sidebar .offcanvas-body { flex: 1 1 auto; } }
/* ชื่อผู้ใช้/ปุ่มออก อยู่ท้ายรายการเมนู (เลื่อนลงถึงจะเจอ) */
.menu-scroll .sidebar-user { margin: 1rem -.75rem -1rem; }

/* ===== การ์ดสีสถิติ (small-box) ===== */
.sb-card { position: relative; overflow: hidden; height: 100%; border-radius: .6rem; background: var(--sc); color: var(--sf); box-shadow: 0 1px 3px rgba(20,40,75,.18); }
.sb-body { position: relative; padding: 1rem 1.1rem; }
.sb-bg { position: absolute; right: .8rem; top: .5rem; font-size: 3.8rem; opacity: .2; pointer-events: none; }
.sb-num { font-size: 2.2rem; font-weight: 700; line-height: 1.15; }
.sb-num small { font-size: .95rem; font-weight: 400; opacity: .85; }
.sb-name { font-weight: 600; font-size: 1.05rem; }
.sb-name small { font-weight: 400; opacity: .85; font-size: .85rem; }
.sb-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.35); margin: .6rem 0 .3rem; overflow: hidden; }
.sb-card[style*="#ffc107"] .sb-bar { background: rgba(0,0,0,.15); }
.sb-bar i { display: block; height: 100%; background: currentColor; border-radius: 3px; }
.sb-note { font-size: .82rem; opacity: .9; }
.lv-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* การ์ดสีผู้สมัครแยกตามระดับชั้น (เหมือนหน้าสถิติสาธารณะ) */
.lvl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.lvl-card { position: relative; overflow: hidden; border-radius: 10px; padding: 16px 16px 14px; background: var(--lc); color: var(--lfg); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.lvl-bg { position: absolute; right: 10px; top: 8px; font-size: 3.4rem; opacity: .22; pointer-events: none; }
.lvl-num strong { font-size: 2rem; line-height: 1.1; }
.lvl-num span { opacity: .85; font-size: .92rem; }
.lvl-name { position: relative; font-weight: 600; font-size: 1.1rem; margin-top: 2px; }
.lvl-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.35); margin: 10px 0 6px; overflow: hidden; }
.lvl-card[style*="#ffc107"] .lvl-bar { background: rgba(0,0,0,.15); }
.lvl-bar i { display: block; height: 100%; background: currentColor; border-radius: 3px; }
.lvl-pct { opacity: .9; font-size: .82rem; }
