* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /*แบ่งซ้ายและขวา*/
    gap: 30px;
}

.logo {
    width: 80px;
    height: 80px;
    background-image: url("/assets/img/logo.png");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    /* color: whitesmoke;
    background-color: rgb(255, 0, 0);
    font-size: 30px;
    font-weight: 900;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center; */
}

.header-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    /* ขยายเต็มแนวระหว่าง logo กับ datetime*/
}

.header-info h1 {
    font-size: 32px;
    color: #1e3c72;
    margin-bottom: 0;
}

.datetime {
    display: flex;
    flex-direction: column;
    /* เรียงเป็นบน-ล่าง*/
    align-items: flex-end;
    /*จัดชิดขวา*/
    text-align: right;
    gap: 4px;
}

#currentTime {
    font-size: 45px;
    font-weight: bold;
    color: #ff0000;
    line-height: 1.2;
}

#currentDate {
    font-size: 20px;
    color: #000000;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
    margin-bottom: 30px;
}

.panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.panel-title {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #1e3c72;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
}

.current-exam {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

.current-exam h3 {
    font-size: 22px;
    margin-bottom: 15px;
}

.no-exam {
    background: linear-gradient(135deg, #9e9e9e 0%, #757575 100%);
    color: white;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(158, 158, 158, 0.3);
    text-align: center;
    font-size: 18px;
}

.exam-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.exam-info p {
    font-size: 18px;
    display: flex;
    justify-content: space-between;
}

.timer {
    font-size: 48px;
    font-weight: bold;
    text-align: center;
    margin: 20px 0;
    font-family: 'Courier New', monospace;
    letter-spacing: 5px;
}

.exit-message {
    background: #fff3cd;
    color: #856404;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    margin-top: 20px;
    font-size: 18px;
    display: none;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.seating-chart {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    max-width: 100%;
    margin: 0 auto;
}

.seat-pair {
    display: flex;
    gap: 8px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
    align-items: center;
    justify-content: center;
}

.seat {
    width: 60px;
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.3s ease;
    border: 2px solid #ddd;
    background: white;
    color: #333;
    line-height: 1.2;
}

.seat:hover {
    transform: translateY(-2px);
    border-color: #2196F3;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.seat .class-level {
    font-size: 10px;
    color: #666;
    font-weight: normal;
}

.seat .seat-number {
    font-size: 16px;
    color: #333;
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.schedule-table th,
.schedule-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.schedule-table th {
    background: #f5f5f5;
    font-weight: bold;
    color: #1e3c72;
}

.schedule-table tr:hover {
    background: #f9f9f9;
}

.exam-status {
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: bold;
}

.exam-status.current {
    background: #4CAF50;
    color: white;
}

.exam-status.upcoming {
    background: #FFC107;
    color: #333;
}

.exam-status.completed {
    background: #9E9E9E;
    color: white;
}

.admin-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #FF6B6B;
    color: white;
    padding: 15px 25px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(255, 107, 107, 0.3);
    transition: all 0.3s ease;
    font-weight: bold;
}

.admin-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
}

.admin-panel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    overflow-y: auto;
}

.admin-content {
    background: white;
    max-width: 800px;
    margin: 50px auto;
    padding: 40px;
    border-radius: 15px;
    position: relative;
}

.close-admin {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 30px;
    cursor: pointer;
    color: #666;
}

.admin-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.admin-section h3 {
    margin-bottom: 15px;
    color: #1e3c72;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

.btn {
    padding: 10px 25px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.btn:hover {
    background: #1976D2;
    transform: translateY(-1px);
}

.seat-grid-config {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

#adminSection-seating #singleConfig .seat-grid-config {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
    /* ให้ปุ่ม/อินพุตชิดฐานเดียวกัน สวยขึ้น */
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    .header {
        flex-direction: column;
        text-align: center;
    }
    .datetime {
        flex-direction: column;
        gap: 10px;
    }
}


/* --- Admin Panel: Sidebar Layout --- */

.admin-content {
    background: transparent;
    max-width: 1000px;
    margin: 50px auto;
    padding: 0;
    border-radius: 15px;
    position: relative;
}

.admin-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.admin-sidebar {
    background: #0f2a52;
    color: #fff;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-sidebar h2 {
    font-size: 18px;
    font-weight: 700;
    padding: 0 24px 10px 24px;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.admin-nav-btn {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    color: #e6eefc;
    padding: 12px 24px;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background .2s ease, color .2s ease, padding-left .2s ease;
}

.admin-nav-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    padding-left: 28px;
}

.admin-nav-btn.active {
    background: #1e3c72;
    color: #fff;
    border-left: 4px solid #4fc3f7;
    padding-left: 20px;
}

.admin-main {
    background: #fff;
    padding: 28px;
}

.admin-main .admin-section {
    display: none;
    /* เริ่มต้นซ่อนทุกหน้า */
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
}


/* แถบหัว admin panel (ปุ่มปิด) */

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 12px 18px;
    /* background: #eaf2ff;
    border-bottom: 1px solid #d8e6ff; */
}


/* ปุ่มปิด X เดิมยังใช้ได้ */

.close-admin {
    position: static;
    font-size: 26px;
    color: #ffffff;
}

#seatingSection {
    display: none;
    /* ซ่อนทั้งส่วนผังที่นั่ง */
}


/* ปรับในมือถือ */

@media (max-width: 900px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }
    .admin-sidebar {
        flex-direction: row;
        overflow-x: auto;
        padding: 12px;
        gap: 8px;
    }
    .admin-nav-btn {
        white-space: nowrap;
        border-radius: 8px;
    }
}

@media (max-width: 900px) {
    .schedule-grid {
        grid-template-columns: 1fr;
    }
    /* มือถือ = ซ้อนลงมา */
}

.schedule-column-title {
    font-size: 18px;
    color: #1e3c72;
    margin-bottom: 10px;
    font-weight: 700;
}

.exit-overlay {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 14px 18px;
    border-radius: 10px;
    width: 80vw;
    max-width: 900px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    pointer-events: none;
}

.exit-overlay .ticker {
    overflow: hidden;
    white-space: nowrap;
    width: 100%;
    font-size: 18px;
    font-weight: 700;
}

.exit-overlay .ticker span {
    display: inline-block;
    padding-left: 100%;
    animation: slide-left 15s linear infinite;
    animation-delay: 1s;
    /* รอ 1 วิก่อนเริ่มเลื่อน */
}

@keyframes slide-left {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-100%);
    }
}

.exit-overlay.fadeout {
    animation: fadeout 15s ease forwards;
}

@keyframes fadeout {
    0% {
        opacity: 1;
    }
    95% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}


/* ตารางสอบแบบหลายคอลัมน์ (แยกตามระดับชั้น) */

.schedule-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 10px;
    font-size: 12px;
}


/* จัดการกับ cell ของชื่อวิชา */

.schedule-table td:nth-child(2),
.schedule-table th:nth-child(2) {
    max-width: 100px;
    /* จำกัดความกว้างสูงสุด */
    overflow: hidden;
    /* ซ่อนส่วนเกิน */
    text-overflow: ellipsis;
    /* แสดง ... */
    white-space: nowrap;
    /* ไม่ตัดบรรทัด */
}


/* จัดกลุ่มเวลาเริ่ม–สิ้นสุดให้อยู่บรรทัดเดียวกัน */

.form-group.time-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group.time-range input[type="time"] {
    flex: 1;
    /* ขยายให้กินพื้นที่เท่ากัน */
    min-width: 120px;
    /* กันไม่ให้เล็กเกินไป */
}


/* จัดให้อยู่ในแถวเดียวกัน */

.form-group.inline-fields {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-group.inline-fields label {
    white-space: nowrap;
    /* กัน label ขึ้นบรรทัดใหม่ */
    font-weight: bold;
}

.form-group.inline-fields select {
    flex: 1;
    /* ช่อง select ขยายพอดี */
    min-width: 140px;
    /* กันไม่ให้เล็กเกิน */
}

.form-group.inline-fields {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-group.inline-fields label {
    white-space: nowrap;
    font-weight: bold;
}

.form-group.inline-fields input,
.form-group.inline-fields select {
    flex: 1;
    min-width: 140px;
}