﻿/* ==========================================================================
   🎨 1. CORE & DESIGN SYSTEM (ระบบฟอนต์และตัวแปรหลัก)
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@400;500;600&family=Sarabun:wght@300;400;500;600&display=swap');

:root {
    --sidebar-width: 80px;
    --tcas-blue: #004785;
    --tcas-bg: #F8FAFC;
    --hot-pink: #ff758c;
    --hot-pink-gradient: linear-gradient(135deg, #ff758c 0%, #ff7eb3 100%);
    --stou-gold: #cca43b;
    --transition-smooth: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --primary-soft-bg: #e0f2fe;
    --primary-soft-text: #0369a1;
    --danger-soft-bg: #fee2e2;
}

body {
    background-color: var(--tcas-bg);
    font-family: 'Sarabun', sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .fw-bold {
    font-family: 'Kanit', sans-serif;
}

/* ==========================================================================
   🧭 2. SIDEBAR NAVIGATION & ANIMS (แถบเมนูข้างและเอฟเฟกต์)
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    z-index: 1050;
    transition: var(--transition-smooth);
}

.nav-item-custom {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    margin-bottom: 15px;
    color: #64748b;
    text-decoration: none;
    position: relative;
    transition: var(--transition-smooth);
}

    .nav-item-custom:hover, .nav-item-custom.active {
        background-color: #f1f5f9;
        color: var(--tcas-blue);
    }

    .nav-item-custom i {
        font-size: 1.5rem;
        display: inline-block;
        transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.2s ease;
    }

    .nav-item-custom:hover i {
        transform: scale(1.25) rotate(5deg);
    }

@media (min-width: 992px) {
    .nav-item-custom[title]:hover::after {
        content: attr(title);
        position: absolute;
        left: 100%;
        margin-left: 15px;
        top: 50%;
        transform: translateY(-50%);
        background: rgba(15, 23, 42, 0.95);
        color: #fff;
        padding: 6px 14px;
        font-size: 13px;
        border-radius: 8px;
        white-space: nowrap;
        box-shadow: 0 10px 25px rgba(0,0,0,0.15);
        pointer-events: none;
        z-index: 1060;
        font-family: 'Sarabun', sans-serif;
    }

    .nav-item-custom[title]:hover::before {
        content: '';
        position: absolute;
        left: 100%;
        margin-left: 7px;
        top: 50%;
        transform: translateY(-50%);
        border: 5px solid transparent;
        border-right-color: rgba(15, 23, 42, 0.95);
        pointer-events: none;
        z-index: 1060;
    }
}

.mt-auto {
    margin-top: auto !important;
}

/* ==========================================================================
   💻 3. WRAPRAPPER & MAIN LAYOUT (ส่วนควบคุมกรอบเนื้อหาหลัก)
   ========================================================================== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    transition: var(--transition-smooth);
}

.top-header {
    background: white;
    padding: 25px 0;
    border-bottom: 1px solid #e2e8f0;
    background-image: url('https://www.transparenttextures.com/patterns/cubes.png');
}

/* ==========================================================================
   🔍 4. SEARCH BOX & ACTIONS (ระบบกล่องค้นหา Glassmorphism)
   ========================================================================== */
.search-wrapper {
    perspective: 1000px;
}

.search-box-container {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 8px 25px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
    transition: var(--transition-smooth);
}

    .search-box-container:focus-within {
        transform: translateY(-4px) scale(1.015);
        box-shadow: 0 20px 40px rgba(0, 47, 133, 0.08) !important;
        border-color: var(--tcas-blue);
    }

.search-icon {
    font-size: 1.3rem;
    color: #94a3b8;
    margin-right: 15px;
}

.search-input {
    border: none !important;
    background: transparent !important;
    width: 100%;
    padding: 12px 0;
    font-size: 1.1rem;
    outline: none !important;
    color: #1e293b;
    font-weight: 600;
}

.search-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-action {
    border-radius: 15px;
    padding: 12px 25px;
    text-decoration: none !important;
    font-weight: 600;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 160px;
    border: none;
}

.btn-main {
    background: linear-gradient(135deg, #004785, #007bff);
    color: white !important;
    box-shadow: 0 8px 20px rgba(0, 71, 133, 0.25);
}

    .btn-main:hover {
        box-shadow: 0 12px 25px rgba(0, 71, 133, 0.35);
        transform: translateY(-2px);
        color: white !important;
    }

.btn-sub {
    background: #ffffff;
    color: #475569 !important;
    border: 1px solid #cbd5e1;
}

    .btn-sub:hover {
        background: #f8fafc;
        color: #1e293b !important;
    }

/* ==========================================================================
   🌸 5. CARD & COLOR THEMES (สกินสีของแต่ละหน้าบัตรสอบ)
   ========================================================================== */
.result-card {
    border-radius: 24px !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 15px 35px rgba(0,0,0,0.04) !important;
    background: #ffffff;
    overflow: hidden;
}

.personal-section {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-right: 1px solid #e2e8f0;
    border-top-left-radius: 24px;
    border-bottom-left-radius: 24px;
}

.id-badge {
    background: white;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 4px 12px rgba(0,0,0,0.01);
}

    .id-badge small {
        font-size: 0.7rem;
        color: #94a3b8;
        font-weight: 700;
        letter-spacing: 1px;
    }

.icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
}

.bg-primary-soft {
    background-color: var(--primary-soft-bg) !important;
    color: var(--primary-soft-text) !important;
    border: 1px solid rgba(3, 105, 161, 0.1);
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 8px 0;
}

.schedule-item-row {
    border-bottom: 1px dashed #e2e8f0;
    padding: 16px 0;
    transition: var(--transition-smooth);
}

    .schedule-item-row:hover {
        background-color: #f8fafc;
        padding-left: 8px;
    }

/* 🟢 บัตรเขียว */
.bg-success-light {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0 !important;
}

.text-success {
    color: #16a34a !important;
}

.bg-success-soft {
    background: #dcfce7;
    color: #15803d;
}

/* 🟣 บัตรนักศึกษาเดิม */
.bg-purple-light {
    background-color: #faf5ff;
    border: 1px solid #e9d5ff !important;
}

.text-purple {
    color: #9333ea !important;
}

.bg-info-soft {
    background: #e0f2fe;
    color: #0369a1;
}

.bg-warning-soft {
    background: #fef9c3;
    color: #a16207;
}

/* 🌸 บัตรชมพู มสธ. */
.bg-pink-gradient {
    background: var(--hot-pink-gradient);
}

.bg-pink-xlight {
    background-color: #fff5f7;
}

.text-pink {
    color: var(--hot-pink) !important;
}

.border-pink-sub {
    border: 1px solid #fecdd3 !important;
}

    .border-pink-sub:focus {
        border-color: var(--hot-pink) !important;
        box-shadow: 0 0 0 0.25rem rgba(255, 117, 140, 0.2) !important;
    }

.btn-pink {
    background-color: var(--hot-pink);
    color: white;
    border: none;
    transition: all 0.2s;
}

    .btn-pink:hover {
        background-color: #ff5572;
        color: white;
        box-shadow: 0 6px 14px rgba(255, 117, 140, 0.3);
    }

.btn-save-pink {
    background: var(--hot-pink-gradient);
    color: white;
    border-radius: 50px;
    font-weight: bold;
    transition: var(--transition-smooth);
    border: none;
}

    .btn-save-pink:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 20px rgba(255, 117, 140, 0.35);
        color: white;
    }

.pink-table {
    width: 100%;
}

    .pink-table thead th {
        font-weight: 600;
        border: none;
        background-color: #f1f5f9;
        color: #475569;
        padding: 12px 8px;
    }

    /* 🎯 [ปลอดภัยกู้คืน]: ปรับแต่งแถวตารางให้มีระยะพอดี ไม่โย้เย้อ ไม่ทับสไตล์พ่นข้อความหลังบ้าน */
    .pink-table tbody td {
        padding: 12px 8px !important;
    }

.form-check-input-custom input {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: var(--hot-pink);
}

.btn-outline-success {
    color: #16a34a !important;
    border-color: #16a34a !important;
    background-color: #ffffff !important;
    font-weight: 600;
    transition: var(--transition-smooth) !important;
}

    .btn-outline-success:hover {
        color: #ffffff !important;
        background-color: #16a34a !important;
        box-shadow: 0 6px 16px rgba(22, 163, 74, 0.2) !important;
        transform: translateY(-1px) !important;
    }

#imgPreview {
    box-shadow: 0 8px 20px rgba(15, 118, 110, 0.08);
    border-radius: 15px;
}

.table-sm th {
    color: #64748b;
    font-weight: 600;
    font-size: 0.8rem;
    border-bottom: 1px solid #e2e8f0 !important;
}

/* ==========================================================================
   🔐 6. BEAUTIFUL LOGIN THEME (ส่วนตกแต่งหน้ากากล็อกอินใหม่ของบอส)
   ========================================================================== */
.login-body {
    background: linear-gradient(135deg, #002244 0%, #004785 100%) !important;
    background-image: url('https://www.transparenttextures.com/patterns/cubes.png'), linear-gradient(135deg, #002244 0%, #004785 100%) !important;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 24px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    max-width: 440px;
    width: 100%;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.login-header-zone {
    background: linear-gradient(135deg, #003366 0%, #004785 100%);
    padding: 35px 20px;
    text-align: center;
    border-bottom: 4px solid var(--stou-gold);
}

.login-logo {
    width: 75px;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
    margin-bottom: 15px;
}

.login-input-group {
    position: relative;
    margin-bottom: 22px;
}

    .login-input-group i {
        position: absolute;
        left: 18px;
        top: 50%;
        transform: translateY(-50%);
        color: #94a3b8;
        font-size: 1.2rem;
        transition: color 0.3s;
    }

.login-control {
    width: 100%;
    padding: 14px 15px 14px 50px;
    border: 1.5px solid #cbd5e1;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 500;
    color: #1e293b;
    background-color: #ffffff;
    outline: none !important;
    transition: var(--transition-smooth);
}

    .login-control:focus {
        border-color: var(--tcas-blue);
        box-shadow: 0 0 0 4px rgba(0, 71, 133, 0.15);
        background-color: #fff;
    }

        .login-control:focus + i {
            color: var(--tcas-blue);
        }

.btn-login-submit {
    width: 100%;
    background: linear-gradient(135deg, #cca43b 0%, #b38f2e 100%);
    color: #fff !important;
    border: none;
    padding: 14px;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'Kanit', sans-serif;
    box-shadow: 0 8px 20px rgba(204, 164, 59, 0.3);
    transition: var(--transition-smooth);
    cursor: pointer;
}

    .btn-login-submit:hover {
        transform: translateY(-2px);
        box-shadow: 0 12px 25px rgba(204, 164, 59, 0.45);
        background: linear-gradient(135deg, #dbb34a 0%, #cca43b 100%);
    }

    .btn-login-submit:active {
        transform: translateY(0);
    }

/* ==========================================================================
   🌀 7. GLOBAL OVERLAY LOADING (ระบบกระจกฝ้าหน้าค้นหาหลัก มสธ.)
   ========================================================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.loading-box {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(204, 164, 59, 0.2);
    border-top: 4px solid var(--stou-gold);
    max-width: 360px;
    width: 90%;
    padding: 2.5rem 1.5rem;
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}

.stou-spinner {
    width: 3.5rem;
    height: 3.5rem;
    border: 4px solid rgba(204, 164, 59, 0.15);
    border-top-color: #0d6efd;
    border-bottom-color: var(--stou-gold);
    border-radius: 50%;
    display: inline-block;
    animation: stou-spin 2.2s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
}

.loading-title {
    color: #1a1a1a;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.loading-subtitle {
    color: #6c757d;
    font-size: 0.875rem;
    line-height: 1.5;
}

@keyframes stou-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   ⏳ 8. BUTTON LOADING & SPINNER (เอฟเฟกต์หมุนสี่เหลี่ยมเป้าหมายปุ่มล็อกอิน)
   ========================================================================== */
.login-wrapper-container {
    min-height: 65vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    display: inline-block;
    vertical-align: text-top;
    margin-right: 8px;
    animation: btn-spin-around 1s linear infinite;
}

.btn-login-submit:disabled {
    opacity: 0.7 !important;
    cursor: not-allowed !important;
    background: var(--stou-gold) !important;
}

.btn-login-submit.btn-loading {
    position: relative;
    color: transparent !important;
    background: var(--stou-gold) !important;
    opacity: 0.8;
}

    .btn-login-submit.btn-loading::after {
        content: "";
        position: absolute;
        width: 18px;
        height: 18px;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        margin: auto;
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-top-color: #ffffff;
        border-radius: 50%;
        animation: btn-spin-around 2.0s linear infinite;
    }

@keyframes btn-spin-around {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   📱 9. FULLY RESPONSIVE BREAKPOINTS (ปรับแต่งตามขนาดจอ)
   ========================================================================== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar {
        width: 100%;
        height: 65px;
        top: auto;
        bottom: 0;
        flex-direction: row;
        justify-content: space-around;
        padding-top: 0;
        border-right: none;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
    }

        .sidebar .mb-5 {
            display: none;
        }

    .nav-item-custom {
        margin-bottom: 0;
        width: 45px;
        height: 45px;
    }

    .main-wrapper {
        margin-left: 0;
        width: 100%;
        padding-bottom: 80px;
    }

    .top-header {
        padding: 15px 0;
        text-align: center;
    }

    .search-box-container {
        padding: 6px 16px;
        border-radius: 15px;
    }

    .search-input {
        font-size: 1rem;
    }

    .search-actions {
        flex-direction: column;
        gap: 10px;
    }

    .btn-action {
        width: 100%;
        min-width: 100%;
        padding: 14px;
    }

    .personal-section {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        padding-bottom: 25px !important;
        border-top-left-radius: 24px;
        border-top-right-radius: 24px;
        border-bottom-left-radius: 0px;
    }

    .avatar-box img {
        max-width: 120px;
        margin: 0 auto;
        display: block;
    }

    .login-card {
        border-radius: 20px;
    }

    .login-header-zone {
        padding: 25px 15px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --sidebar-width: 70px;
    }

    .sidebar {
        width: var(--sidebar-width);
    }

    .main-wrapper {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
}

/* ==========================================================================
   🟢 10. GREEN CARD STYLES (สกินเพิ่มเติมสำหรับบัตรเขียว มสธ.)
   ========================================================================== */
.bg-green-gradient {
    background: linear-gradient(135deg, #198754 0%, #0f5132 100%);
}

.text-green {
    color: #198754 !important;
}

.btn-green {
    background-color: #198754;
    color: white;
    border: none;
}

    .btn-green:hover {
        background-color: #146c43;
        color: white;
    }

.bg-green-xlight {
    background-color: #f0fdf4;
}

.border-green-sub {
    border-color: #a7f3d0 !important;
}

.green-table thead {
    background-color: #dcfce7 !important;
    color: #14532d !important;
}

.btn-save-green {
    background: linear-gradient(135deg, #198754 0%, #115e59 100%);
    color: white;
    border: none;
    border-radius: 50px;
    font-weight: bold;
    transition: all 0.3s;
}

    .btn-save-green:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 20px rgba(25, 135, 84, 0.3);
        color: white;
    }

.preview-wrapper {
    position: relative;
    display: inline-block;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.preview-img {
    max-height: 160px;
    min-width: 120px;
    object-fit: cover;
    display: block;
    border: 2px solid #198754;
    border-radius: 12px;
}

.badge-status {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    z-index: 5;
}
/* =========================================================
   WHITE CARD PAGE
   ========================================================= */

.whitecard-page {
    width: 100%;
    padding: 30px 20px 60px;
    box-sizing: border-box;
}

    .whitecard-page .whitecard-container {
        width: 100%;
        max-width: 1050px;
        margin: 0 auto;
        background: #ffffff;
        border: 2px solid #7c3aed;
        border-radius: 18px;
        overflow: hidden;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    }


    /* =========================================================
   HEADER
   ========================================================= */

    .whitecard-page .whitecard-header {
        background: #191919;
        color: #ffffff;
        text-align: center;
        padding: 24px 20px;
    }

        .whitecard-page .whitecard-header h2 {
            margin: 0;
            color: #ffffff;
            font-size: 28px;
            font-weight: 700;
        }

        .whitecard-page .whitecard-header .subtitle {
            margin-top: 6px;
            color: #cccccc;
            font-size: 14px;
        }


    /* =========================================================
   BODY
   ========================================================= */

    .whitecard-page .whitecard-body {
        padding: 40px 55px 45px;
        background: #ffffff;
    }


    /* =========================================================
   FORM ROW
   ========================================================= */

    .whitecard-page .form-row-custom {
        display: grid;
        grid-template-columns: 180px minmax(0, 1fr);
        gap: 24px;
        align-items: center;
        margin-bottom: 25px;
    }

    .whitecard-page .form-label-custom {
        margin: 0;
        font-size: 16px;
        font-weight: 600;
        color: #252b33;
    }

    .whitecard-page .field-medium {
        width: 100%;
        max-width: 430px;
    }


    /* =========================================================
   INPUT
   ========================================================= */

    .whitecard-page .white-input,
    .whitecard-page .white-select,
    .whitecard-page .white-textarea {
        display: block;
        width: 100%;
        box-sizing: border-box;
        border: 1px solid #d5d9de;
        border-radius: 8px;
        background: #f1f2f4;
        color: #343a40;
        font-family: inherit;
        font-size: 16px;
        outline: none;
    }

    .whitecard-page .white-input {
        height: 52px;
        padding: 0 15px;
    }

    .whitecard-page .white-select {
        height: 52px;
        padding: 0 15px;
    }

    .whitecard-page .white-textarea {
        min-height: 125px;
        padding: 14px 15px;
        resize: vertical;
    }

        .whitecard-page .white-input:focus,
        .whitecard-page .white-select:focus,
        .whitecard-page .white-textarea:focus {
            background: #ffffff;
            border-color: #7c3aed;
            box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.10);
        }

    .whitecard-page .white-input[readonly] {
        background: #e8eaed;
    }


    /* =========================================================
   SEARCH
   ========================================================= */

    .whitecard-page .search-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 220px;
        gap: 18px;
    }

    .whitecard-page .btn-search-white {
        width: 100%;
        height: 52px;
        padding: 0 20px;
        border: none;
        border-radius: 8px;
        background: #51b847;
        color: #ffffff;
        font-size: 16px;
        font-weight: 700;
        cursor: pointer;
    }

        .whitecard-page .btn-search-white:hover {
            background: #439d3a;
        }


    /* =========================================================
   NAME
   ========================================================= */

    .whitecard-page .name-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 18px;
    }


    /* =========================================================
   STUDENT INFO
   ========================================================= */

    .whitecard-page .student-info-box {
        margin: -5px 0 25px 204px;
        padding: 12px 16px;
        background: #f7f3ff;
        border-left: 4px solid #7c3aed;
        border-radius: 7px;
        color: #5d6470;
        font-size: 14px;
    }


    /* =========================================================
   LABEL / HELP
   ========================================================= */

    .whitecard-page .required {
        color: #dc3545;
    }

    .whitecard-page .helper-text {
        display: block;
        margin-top: 6px;
        color: #8a9199;
        font-size: 12px;
    }


    /* =========================================================
   BUTTON
   ========================================================= */

    .whitecard-page .whitecard-actions {
        display: grid;
        grid-template-columns: 1fr 1fr 1.45fr;
        gap: 16px;
        margin-top: 35px;
    }

    .whitecard-page .action-btn {
        width: 100%;
        min-height: 54px;
        border: none;
        border-radius: 8px;
        color: #ffffff;
        font-size: 17px;
        font-weight: 700;
        cursor: pointer;
    }

    .whitecard-page .btn-save-white {
        background: #3978d7;
    }

        .whitecard-page .btn-save-white:hover {
            background: #2e66bb;
        }

    .whitecard-page .btn-clear-white {
        background: #ff4e5e;
    }

        .whitecard-page .btn-clear-white:hover {
            background: #df414f;
        }

    .whitecard-page .btn-export-white {
        background: #4db83f;
    }

        .whitecard-page .btn-export-white:hover {
            background: #419d36;
        }


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 768px) {

    .whitecard-page {
        padding: 15px 8px 40px;
    }

        .whitecard-page .whitecard-body {
            padding: 28px 20px;
        }

        .whitecard-page .form-row-custom {
            grid-template-columns: 1fr;
            gap: 8px;
            margin-bottom: 20px;
        }

        .whitecard-page .search-layout,
        .whitecard-page .name-layout {
            grid-template-columns: 1fr;
        }

        .whitecard-page .student-info-box {
            margin: 0 0 20px;
        }

        .whitecard-page .whitecard-actions {
            grid-template-columns: 1fr;
        }
}


/* Scoped styles: ไม่กระทบรูปแบบของบัตรต่าง ๆ */
#examScheduleModal .exam-schedule-entry {
    border: 1px solid #e2e8f0;
    border-left: 4px solid #0d6efd;
    border-radius: 12px;
    padding: 12px 14px;
    background: #fff;
}

    #examScheduleModal .exam-schedule-entry.upcoming {
        border-left-color: #198754;
        background: #f7fff9;
    }

#examScheduleModal .exam-schedule-section {
    border: 1px solid #dee2e6;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 15px;
    background: #f8fafc;
}

    #examScheduleModal .exam-schedule-section h6 {
        font-weight: 700;
    }

#examScheduleModal .exam-schedule-muted {
    color: #64748b;
    font-size: .9rem;
}

#examScheduleModal .exam-schedule-time {
    font-weight: 700;
    color: #1e3a8a;
}

/* Popup ตารางสอบ */
#examScheduleModal .modal-dialog {
    max-width: 820px;
}

#examScheduleModal .modal-content {
    border-radius: 18px !important;
}

#examScheduleModal .modal-header {
    background: linear-gradient( 120deg, #124b8d, #2474c4 ) !important;
}

#examScheduleModal #examCourseInput {
    min-width: 0;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

    #examScheduleModal #examCourseInput:focus {
        box-shadow: none;
        border-color: #86b7fe;
    }

#examScheduleModal .exam-schedule-results {
    min-height: 80px;
}

#examScheduleModal .exam-schedule-section {
    margin-bottom: 16px;
}

@media (max-width: 576px) {
    #examScheduleModal .modal-dialog {
        margin: 10px;
    }

    #examScheduleModal .modal-header,
    #examScheduleModal .modal-body,
    #examScheduleModal .modal-footer {
        padding: 16px !important;
    }

    #examScheduleModal #examCourseInput {
        font-size: 16px;
    }

    #examScheduleModal #examCourseSearch {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

/* ======================================================================
   CENTRAL ADMIN: RESPONSIVE NAVIGATION (Site1.Master)
   Desktop: compact sidebar. Mobile: scrollable bottom navigation.
   ====================================================================== */
.sidebar .central-admin-nav {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    min-height: 0;
    padding: 4px 5px 18px;
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
    scrollbar-width: thin;
}

    .sidebar .central-admin-nav .central-admin-link {
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        width: 66px;
        min-height: 68px;
        padding: 8px 3px;
        border: 1px solid #d9e4ef;
        border-radius: 13px;
        background: #fff;
        color: #243547;
        text-align: center;
        text-decoration: none;
        font-size: 11px;
        font-weight: 700;
        line-height: 1.2;
        overflow-wrap: anywhere;
        transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    }

        .sidebar .central-admin-nav .central-admin-link i {
            font-size: 22px;
            line-height: 1;
        }

    .sidebar .central-admin-nav .central-admin-data i {
        color: #0b67a3;
    }

    .sidebar .central-admin-nav .central-admin-reports i {
        color: #ae720f;
    }

    .sidebar .central-admin-nav .central-admin-white i {
        color: #48515b;
    }

    .sidebar .central-admin-nav .central-admin-link:hover,
    .sidebar .central-admin-nav .central-admin-link:focus-visible {
        background: #eef6ff;
        border-color: #77b0e1;
        box-shadow: 0 3px 11px rgba(11,80,145,.10);
        outline-offset: 2px;
    }

    .sidebar .central-admin-nav .central-admin-link[aria-current="page"] {
        background: #eaf4ff;
        border-color: #428bc8;
    }
/* Keep scrolling regions usable within the desktop shell. */
.main-wrapper, .main-wrapper > .container {
    min-width: 0;
}

@media (max-width: 768px) {
    :root {
        --stou-mobile-nav-height: 74px;
    }
    /* A single fixed row: no floating vertical cards above the page. */
    .sidebar {
        width: 100%;
        height: calc(var(--stou-mobile-nav-height) + env(safe-area-inset-bottom, 0px));
        inset: auto 0 0 0;
        padding: 5px 8px calc(5px + env(safe-area-inset-bottom, 0px));
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        border: 0;
        border-top: 1px solid #dce5ef;
        background: rgba(255,255,255,.98);
        box-shadow: 0 -4px 18px rgba(22,43,66,.10);
        box-sizing: border-box;
        z-index: 1040;
    }

        .sidebar .central-admin-nav {
            display: flex;
            flex: 1 1 auto;
            flex-direction: row;
            align-items: stretch;
            justify-content: flex-start;
            flex-wrap: nowrap;
            gap: 8px;
            width: 100%;
            height: 100%;
            min-height: 0;
            padding: 0 2px;
            overflow-x: auto;
            overflow-y: hidden;
            overscroll-behavior-x: contain;
            -webkit-overflow-scrolling: touch;
            scroll-snap-type: x proximity;
            scrollbar-width: none;
        }

            .sidebar .central-admin-nav::-webkit-scrollbar {
                display: none;
            }

            .sidebar .central-admin-nav .central-admin-link {
                flex: 0 0 78px;
                width: 78px;
                height: 100%;
                min-height: 0;
                max-width: none;
                padding: 6px 5px;
                gap: 3px;
                border-radius: 11px;
                font-size: 11px;
                line-height: 1.1;
                scroll-snap-align: start;
            }

                .sidebar .central-admin-nav .central-admin-link i {
                    font-size: 21px;
                }

    .main-wrapper {
        margin-left: 0;
        width: 100%;
        padding-bottom: calc(var(--stou-mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 22px);
    }

        .main-wrapper > .container {
            padding: 18px 14px 26px !important;
            max-width: 100%;
        }

    .top-header {
        padding: 8px 0 !important;
        text-align: left;
    }

        .top-header .container {
            max-width: 100%;
            padding-left: 14px !important;
            padding-right: 14px !important;
        }

        .top-header .d-flex {
            min-width: 0;
        }

        .top-header .lh-sm {
            min-width: 0;
            flex: 0 1 auto;
        }

        .top-header h1 {
            font-size: 1rem !important;
            overflow-wrap: anywhere;
        }

        .top-header .text-end {
            min-width: 0;
            max-width: 55vw;
        }

            .top-header .text-end .fw-bold,
            .top-header .text-end .text-muted {
                display: block;
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
            }

        .top-header .btn {
            flex: 0 0 auto;
            min-width: 40px;
            min-height: 40px;
            justify-content: center;
        }

    .sa-cards, .sa-panel, .sa-subjects, .sa-results-scroll {
        min-width: 0;
    }

    .sa-cards {
        width: 100%;
        max-width: 100%;
    }

        .sa-cards .sa-panel {
            padding: 16px;
            border-radius: 14px;
        }

        .sa-cards .sa-hero {
            padding: 21px 18px;
            border-radius: 15px;
        }

            .sa-cards .sa-hero h2 {
                font-size: 1.15rem;
                line-height: 1.4;
            }

        .sa-cards .form-control, .sa-cards .form-select {
            font-size: 16px;
        }

        .sa-cards .sa-results-scroll {
            max-width: 100%;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }

    #examScheduleModal .modal-dialog {
        margin: 8px;
    }

    #examScheduleModal .modal-content {
        max-height: calc(100dvh - 16px);
    }
}

@media (max-width: 380px) {
    .sidebar .central-admin-nav .central-admin-link {
        flex-basis: 72px;
        width: 72px;
        font-size: 10px;
    }

    .top-header .text-end {
        max-width: 47vw;
    }

    .sa-cards .sa-panel {
        padding: 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar .central-admin-nav .central-admin-link {
        transition: none;
    }

    .sidebar .central-admin-nav {
        scroll-behavior: auto;
    }
}

/* ======================================================================
   MOBILE NAV — centered items when they fit; swipe horizontally if not.
   Scoped to site sidebar. Existing card layouts remain unchanged.
   ====================================================================== */
@media (max-width: 768px) {
    /* Ordinary site staff: icons are direct children of the sidebar. */
    .sidebar {
        justify-content: center;
        gap: clamp(6px, 2vw, 16px);
    }

        .sidebar > .nav-item-custom,
        /* SuperAdmin: nav is a horizontal flex scroller.  Safe center means
       overflow begins at the left rather than hiding the first link. */
        .sidebar .central-admin-nav {
            justify-content: safe center;
            margin-inline: auto;
            gap: clamp(6px, 1.8vw, 10px);
        }

            .sidebar .central-admin-nav .central-admin-link {
                flex-shrink: 0;
            }
}
