/* ==========================================================================
   CSS Design System: โรงเรียนธรรมโชติศึกษาลัย (Pastel Purple & Yellow + Glassmorphism)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&family=Sriracha&display=swap');

:root {
    /* Color Palette (Pastel Purple & Yellow) */
    --primary-color: #8E7CC3;
    --primary-light: #BDB2FF;
    --primary-dark: #6D5C9D;
    --primary-glass: rgba(189, 178, 255, 0.25);
    
    --secondary-color: #FFD97D;
    --secondary-light: #FDFFB6;
    --secondary-dark: #E6B655;
    --secondary-glass: rgba(253, 255, 182, 0.35);

    --bg-gradient: linear-gradient(135deg, #F4F1FA 0%, #FFFDF0 50%, #F5F2F9 100%);
    
    /* Neutral Colors */
    --text-main: #3C354A;
    --text-muted: #7C758A;
    --text-white: #FFFFFF;
    
    /* System Status (Pastel) */
    --status-pending: #FFF4DE;
    --status-pending-text: #B07D1E;
    --status-approved: #E1F8EB;
    --status-approved-text: #1E7B4D;
    --status-rejected: #FFEBEB;
    --status-rejected-text: #C0392B;
    --status-draft: #EAECEE;
    --status-draft-text: #5D6D7E;

    /* Fonts */
    --font-title: 'Prompt', sans-serif;
    --font-body: 'Sarabun', sans-serif;

    /* Transitions & Shadows */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-soft: 0 10px 30px -10px rgba(142, 124, 195, 0.15);
    --shadow-hover: 0 15px 35px -5px rgba(142, 124, 195, 0.25);
    
    /* Borders */
    --glass-border: 1px solid rgba(255, 255, 255, 0.55);
}

/* ==========================================================================
   Base & Reset Styles
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

/* Glowing background elements for Glassmorphism effect */
body::before, body::after {
    content: '';
    position: fixed;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    z-index: -1;
    filter: blur(100px);
    opacity: 0.5;
    pointer-events: none;
}

body::before {
    background: var(--primary-light);
    top: 10%;
    left: -10%;
    animation: float-slow 20s infinite alternate;
}

body::after {
    background: var(--secondary-light);
    bottom: 10%;
    right: -10%;
    animation: float-slow 25s infinite alternate-reverse;
}

@keyframes float-slow {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 30px) scale(1.1); }
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-title);
    font-weight: 600;
}

/* ==========================================================================
   Glassmorphism Utilities
   ========================================================================== */
.glass-panel {
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    transition: var(--transition-smooth);
}

.glass-panel:hover {
    box-shadow: var(--shadow-hover);
    border-color: rgba(255, 255, 255, 0.75);
}

.glass-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(142, 124, 195, 0.05);
    transition: var(--transition-smooth);
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(142, 124, 195, 0.1);
    background: rgba(255, 255, 255, 0.7);
}

/* ==========================================================================
   App Layout
   ========================================================================== */
.app-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 30px;
    margin-bottom: 25px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 20px;
}

.school-logo {
    width: 75px;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(142, 124, 195, 0.2));
}

.brand-text h1 {
    font-size: 1.5rem;
    color: var(--primary-dark);
    margin-bottom: 2px;
}

.brand-text p {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Navigation */
.app-nav {
    display: flex;
    gap: 10px;
    padding: 10px;
    overflow-x: auto;
}

.nav-btn {
    font-family: var(--font-title);
    background: transparent;
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.nav-btn:hover {
    background: rgba(142, 124, 195, 0.15);
    color: var(--primary-dark);
}

.nav-btn.active {
    background: var(--primary-color);
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(142, 124, 195, 0.3);
}

/* Main Content Area */
.main-content {
    margin-top: 10px;
}

.view-section {
    display: none;
    animation: fadeIn 0.4s ease-in-out forwards;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Dashboard View
   ========================================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 25px;
}

@media (min-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 3fr 1fr;
    }
}

/* Stats Cards */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    position: relative;
    overflow: hidden;
    padding: 24px 24px 24px 40px; /* เพิ่มระยะหลบขอบซ้ายเป็น 40px ป้องกันการโดนตัดขอบด้านข้างและบน */
    cursor: pointer;
    user-select: none;
    transition: var(--transition-smooth);
}

.stat-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.65);
    border-color: rgba(142, 124, 195, 0.45);
    box-shadow: 0 12px 25px rgba(142, 124, 195, 0.12);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: var(--primary-color);
}

.stat-card.pending::before { background: var(--secondary-color); }
.stat-card.approved::before { background: var(--status-approved-text); }
.stat-card.rejected::before { background: var(--status-rejected-text); }

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 8px; /* เพิ่มช่องว่างระหว่างตัวหนังสือหัวข้อกับตัวเลข */
}

.stat-title {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1.2;
}

.stat-value {
    font-family: var(--font-title);
    font-size: 2.2rem; /* เพิ่มขนาดตัวเลขเล็กน้อย */
    font-weight: 700;
    color: var(--text-main);
    line-height: 1; /* กำหนด line-height เป็น 1 เพื่อไม่ให้เบียดกันหรือกินขอบด้านบน */
    margin: 0;
}

.stat-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.5rem;
    opacity: 0.15;
    color: var(--primary-dark);
}

/* Dashboard Panels */
.panel-title {
    font-size: 1.2rem;
    color: var(--primary-dark);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px dashed rgba(142, 124, 195, 0.2);
    padding-bottom: 10px;
}

/* Room Grid */
.room-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 15px;
}

.room-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.room-image-placeholder {
    height: 140px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(189, 178, 255, 0.3) 0%, rgba(253, 255, 182, 0.3) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    color: var(--primary-dark);
    font-size: 2.5rem;
    border: 1px dashed rgba(142, 124, 195, 0.3);
}

.room-card h4 {
    font-size: 1.05rem;
    color: var(--text-main);
    margin-bottom: 8px;
}

.room-details {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 15px;
    flex-grow: 1;
}

.room-details p {
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.room-capacity-badge {
    background: var(--primary-glass);
    color: var(--primary-dark);
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.75rem;
    display: inline-block;
}

/* Quick Actions & Contact */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn {
    font-family: var(--font-title);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition-smooth);
    font-size: 0.95rem;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(142, 124, 195, 0.25);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 6px 20px rgba(142, 124, 195, 0.35);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-main);
    border: 1px solid rgba(142, 124, 195, 0.3);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 1);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.btn-accent {
    background: var(--secondary-color);
    color: #5d481b;
    box-shadow: 0 4px 15px rgba(255, 217, 125, 0.25);
}

.btn-accent:hover {
    background: #ffcc55;
    transform: translateY(-2px);
}

.contact-box {
    margin-top: 20px;
    padding: 15px;
    border-radius: 12px;
    background: var(--secondary-glass);
    border: 1px dashed rgba(230, 180, 50, 0.3);
}

.contact-box h5 {
    color: #b07d1e;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.contact-box p {
    font-size: 0.85rem;
    color: #7d5815;
}

/* ==========================================================================
   Booking Form View
   ========================================================================== */
.form-layout {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px;
}

.form-section-title {
    font-size: 1.1rem;
    color: var(--primary-dark);
    margin: 25px 0 15px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-section-title::after {
    content: '';
    flex-grow: 1;
    height: 1px;
    background: linear-gradient(to right, rgba(142, 124, 195, 0.3), transparent);
    margin-left: 10px;
}

.form-section-title:first-of-type {
    margin-top: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .form-grid.two-cols {
        grid-template-columns: repeat(2, 1fr);
    }
    .form-grid.three-cols {
        grid-template-columns: repeat(3, 1fr);
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-control {
    font-family: var(--font-body);
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(142, 124, 195, 0.3);
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-smooth);
}

.form-control:focus {
    border-color: var(--primary-color);
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(189, 178, 255, 0.25);
}

/* Custom Checkbox/Radio styling for premises */
.premises-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 768px) {
    .premises-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.custom-option-card {
    position: relative;
    border: 1px solid rgba(142, 124, 195, 0.2);
    border-radius: 12px;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    transition: var(--transition-smooth);
}

.custom-option-card:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--primary-light);
}

.custom-option-card input[type="radio"],
.custom-option-card input[type="checkbox"] {
    margin-top: 4px;
    accent-color: var(--primary-color);
}

.option-details {
    display: flex;
    flex-direction: column;
}

.option-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
}

.option-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Radio purpose row */
.purpose-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.purpose-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95rem;
}

.purpose-option input {
    accent-color: var(--primary-color);
    width: 18px;
    height: 18px;
}

/* Signature Pad container */
.signature-container {
    border: 1px dashed rgba(142, 124, 195, 0.4);
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    padding: 10px;
    position: relative;
}

.signature-pad {
    width: 100%;
    height: 150px;
    background: #FFFFFF;
    border-radius: 6px;
    cursor: crosshair;
}

.signature-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* ==========================================================================
   Manage / Bookings List View
   ========================================================================== */
.list-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
    justify-content: space-between;
}

.search-input-wrapper {
    position: relative;
    flex-grow: 1;
    max-width: 350px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input-wrapper .form-control {
    padding-left: 35px;
    width: 100%;
}

.filter-select {
    width: 160px;
}

/* Table styling */
.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid rgba(142, 124, 195, 0.15);
}

.booking-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.5);
}

.booking-table th,
.booking-table td {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(142, 124, 195, 0.1);
}

.booking-table th {
    font-family: var(--font-title);
    background: rgba(189, 178, 255, 0.15);
    color: var(--primary-dark);
    font-weight: 600;
}

.booking-table tr:last-child td {
    border-bottom: none;
}

.booking-table tr:hover td {
    background: rgba(255, 255, 255, 0.3);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-draft { background: var(--status-draft); color: var(--status-draft-text); }
.badge-pending { background: var(--status-pending); color: var(--status-pending-text); }
.badge-approved { background: var(--status-approved); color: var(--status-approved-text); }
.badge-rejected { background: var(--status-rejected); color: var(--status-rejected-text); }

/* ==========================================================================
   Simulator Widget (Interactive floating panel)
   ========================================================================== */
.simulator-panel {
    background: rgba(253, 255, 220, 0.75);
    border: 1px solid rgba(230, 190, 50, 0.35);
    border-radius: 16px;
    padding: 15px 20px;
    margin-bottom: 25px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.simulator-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.simulator-icon {
    font-size: 1.5rem;
    color: var(--secondary-dark);
}

.simulator-text h4 {
    font-size: 0.95rem;
    color: #6a4f15;
}

.simulator-text p {
    font-size: 0.8rem;
    color: #7d6023;
}

.simulator-roles {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.role-btn {
    font-family: var(--font-title);
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(142, 124, 195, 0.2);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.role-btn:hover {
    background: var(--primary-glass);
}

.role-btn.active {
    background: var(--primary-color);
    color: var(--text-white);
    border-color: var(--primary-color);
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-container {
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    background: var(--bg-gradient);
    border-radius: 20px;
    border: var(--glass-border);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-container {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid rgba(142, 124, 195, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.5);
}

.modal-header h3 {
    font-size: 1.25rem;
    color: var(--primary-dark);
}

.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-smooth);
}

.modal-close-btn:hover {
    color: var(--text-main);
    transform: scale(1.1);
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex-grow: 1;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid rgba(142, 124, 195, 0.15);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: rgba(255, 255, 255, 0.5);
}

/* Detail tabs inside modal */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid rgba(142, 124, 195, 0.15);
    margin-bottom: 20px;
}

.modal-tab-btn {
    font-family: var(--font-title);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition-smooth);
}

.modal-tab-btn:hover {
    color: var(--primary-color);
}

.modal-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
}

/* Approval actions in modal */
.approval-box {
    background: var(--secondary-glass);
    border: 1px dashed rgba(230, 190, 50, 0.35);
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
}

.approval-box h4 {
    color: #6a4f15;
    margin-bottom: 15px;
}

/* ==========================================================================
   Calendar View
   ========================================================================== */
.calendar-wrapper {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    padding: 20px;
    border: var(--glass-border);
}

/* FullCalendar Custom Theme Overrides to match our palette */
.fc {
    font-family: var(--font-body) !important;
}

.fc-theme-standard td, .fc-theme-standard th {
    border-color: rgba(142, 124, 195, 0.15) !important;
}

.fc-col-header-cell {
    background: rgba(189, 178, 255, 0.1) !important;
    padding: 10px 0 !important;
}

.fc-col-header-cell-cushion {
    font-family: var(--font-title) !important;
    color: var(--primary-dark) !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
    text-decoration: none !important;
}

.fc-daygrid-day-number {
    font-family: var(--font-title) !important;
    color: var(--text-main) !important;
    font-size: 0.9rem !important;
    text-decoration: none !important;
    font-weight: 500 !important;
}

/* สีแดงสำหรับตัวเลขวันเสาร์และวันอาทิตย์ */
.fc-day-sun .fc-daygrid-day-number,
.fc-day-sat .fc-daygrid-day-number {
    color: #E74C3C !important;
    font-weight: 600 !important;
}

/* ปรับสีหัวข้อคอลัมน์ อาทิตย์ (Sun) และ เสาร์ (Sat) ให้เป็นโทนสีแดงเพื่อความเข้ากัน */
.fc-day-sun .fc-col-header-cell-cushion,
.fc-day-sat .fc-col-header-cell-cushion {
    color: #C0392B !important;
}

.fc-button-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    font-family: var(--font-title) !important;
    font-weight: 500 !important;
    text-transform: capitalize !important;
}

.fc-button-primary:hover {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
}

.fc-button-primary:disabled {
    background-color: var(--text-muted) !important;
    border-color: var(--text-muted) !important;
    opacity: 0.5 !important;
}

.fc-event {
    border-radius: 6px !important;
    padding: 2px 6px !important;
    font-size: 0.8rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    border: none !important;
}

.fc-day-today {
    background-color: rgba(253, 255, 182, 0.25) !important;
}

/* Event status colors in calendar */
.event-pending { background-color: var(--secondary-color) !important; color: #5d481b !important; }
.event-approved { background-color: #82E0AA !important; color: #1E6043 !important; }
.event-rejected { background-color: #F1948A !important; color: #78281F !important; }
.event-holiday { background-color: #FADBD8 !important; color: #78281F !important; border-left: 4px solid #E74C3C !important; font-weight: bold !important; cursor: default !important; }

/* ==========================================================================
   Official A4 Document Print Layout
   ========================================================================== */
#official-document-view {
    display: none; /* Hidden on screen by default */
}

/* Custom signature font simulation */
.sig-font {
    font-family: 'Sriracha', 'Courier New', cursive;
    font-size: 1.25rem;
    font-weight: bold;
    color: #1A5276;
    white-space: nowrap; /* ป้องกันลายเซ็นภาษาไทยหักบรรทัดทับซ้อน */
}

/* CSS Print Media Rules */
@media print {
    /* Hide all screen elements */
    body * {
        visibility: hidden;
    }
    
    body {
        background: #FFFFFF !important;
        color: #000000 !important;
    }
    
    /* Display and format only the official document */
    #official-document-view, #official-document-view * {
        visibility: visible;
    }
    
    #official-document-view {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 0;
        margin: 0;
        background: #FFFFFF !important;
        font-family: 'Sarabun', 'TH Sarabun PSK', sans-serif !important;
        font-size: 11pt !important; /* ปรับลดขนาดฟอนต์ลงเล็กน้อยเพื่อให้กระชับในหน้าเดียว */
        line-height: 1.4 !important;
    }

    .print-page {
        width: 100%;
        max-width: 210mm; /* A4 width */
        min-height: 297mm; /* A4 height */
        margin: 0 auto;
        padding: 8mm 12mm 6mm 12mm; /* ปรับลดขอบกระดาษเพื่อเพิ่มพื้นที่แนวตั้ง */
        background: #FFFFFF;
        box-sizing: border-box;
    }
    
    /* Styling elements inside the official document */
    .print-header {
        text-align: center;
        margin-bottom: 8px;
    }
    
    .print-logo {
        width: 55px; /* ปรับโลโก้ให้เล็กลงเล็กน้อย */
        height: auto;
        display: block;
        margin: 0 auto 4px auto;
    }
    
    .print-title {
        font-family: 'Sarabun', sans-serif;
        font-size: 14pt;
        font-weight: bold;
        text-align: center;
        margin-bottom: 2px;
    }

    .print-subtitle {
        font-size: 12pt;
        text-align: center;
        margin-bottom: 8px;
    }
    
    .doc-meta {
        margin-bottom: 15px;
        font-size: 14pt;
    }
    
    .dot-leader {
        border-bottom: 1px dotted #000000;
        display: inline-block;
        min-width: 50px;
        padding-left: 5px;
        padding-right: 5px;
        font-weight: bold;
    }

    .print-checkbox-grid {
        margin: 5px 0 5px 20px;
        display: grid;
        grid-template-columns: 1fr 1fr; /* แสดงผลแบบ 2 คอลัมน์เพื่อประหยัดพื้นที่แนวตั้ง */
        gap: 3px 15px;
    }

    .print-checkbox-item {
        display: flex;
        align-items: flex-start;
        gap: 8px;
    }

    .print-box {
        width: 14px;
        height: 14px;
        border: 1px solid #000000;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin-top: 5px;
        flex-shrink: 0;
        font-size: 10pt;
        font-weight: bold;
    }

    .print-checked {
        background: transparent;
    }
    
    .print-checked::after {
        content: '✓';
    }

    .print-radio-group {
        display: flex;
        gap: 20px;
        margin-left: 30px;
    }
    
    .print-radio-item {
        display: flex;
        align-items: center;
        gap: 5px;
    }

    .print-circle {
        width: 14px;
        height: 14px;
        border: 1px solid #000000;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    
    .print-circle-checked::after {
        content: '✓';
        font-size: 11pt;
        font-weight: bold;
        line-height: 1;
        margin-top: -1px;
    }

    /* Print signatures section */
    .print-signatures-grid {
        margin-top: 15px; /* ลดระยะห่างด้านบน */
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px 15px; /* ลดช่องว่างระหว่างจุดลงนาม */
    }

    .sig-column {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        font-size: 13pt;
    }

    .sig-area {
        height: 45px;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        width: 150px;
        border-bottom: 1px solid #000000; /* เส้นใต้ทึบสำหรับลงชื่อด้วยปากกาจริงตอนพิมพ์ */
        margin-bottom: 5px;
    }

    .sig-img-print {
        max-height: 45px;
        max-width: 150px;
        object-fit: contain;
    }

    /* Page margins adjustment */
    @page {
        size: A4;
        margin: 0;
    }
}

/* Screen Preview version of the official A4 sheet (shows inside detail modal) */
.official-doc-preview {
    background: #FFFFFF;
    color: #000000;
    box-shadow: 0 4px 25px rgba(0,0,0,0.1);
    border: 1px solid #E0E0E0;
    border-radius: 4px;
    padding: 30px 40px;
    margin: 0 auto;
    width: 100%;
    max-width: 800px;
    font-family: 'Sarabun', sans-serif;
    font-size: 11.5pt;
    line-height: 1.6;
}

.official-doc-preview h3.preview-doc-title {
    font-family: 'Sarabun', sans-serif;
    font-size: 13.5pt;
    font-weight: bold;
    color: #000000;
    text-align: center;
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 5px;
}

.official-doc-preview .preview-logo {
    width: 60px;
    height: auto;
    display: block;
    margin: 0 auto 10px auto;
}

.preview-dot-leader {
    border-bottom: 1px dotted #888888;
    display: inline-block;
    padding-left: 4px;
    padding-right: 4px;
    font-weight: 600;
    color: #1A5276;
}

.preview-checkbox-grid {
    margin: 8px 0 8px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preview-checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.preview-box {
    width: 14px;
    height: 14px;
    border: 1px solid #555555;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
    font-size: 9pt;
    font-weight: bold;
}

.preview-checked::after {
    content: '✓';
    color: #1A5276;
}

.preview-radio-group {
    display: flex;
    gap: 15px;
    margin-left: 20px;
}

.preview-radio-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.preview-circle {
    width: 14px;
    height: 14px;
    border: 1px solid #555555;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.preview-circle-checked::after {
    content: '✓';
    font-size: 10pt;
    font-weight: bold;
    line-height: 1;
    color: #1A5276;
    margin-top: -1px;
}

.preview-signatures-grid {
    margin-top: 25px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px 15px;
}

.preview-sig-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    font-size: 10.5pt;
}

.preview-sig-area {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 120px;
    border-bottom: 1px dashed #CCCCCC;
    margin-bottom: 5px;
}

.preview-sig-img {
    max-height: 35px;
    max-width: 120px;
    object-fit: contain;
}

/* Form alert styling */
.validation-message {
    color: var(--status-rejected-text);
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 3px;
    display: none;
}

.form-control.invalid {
    border-color: #E74C3C;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.15);
}

/* ==========================================================================
   Developer Mode Styles
   ========================================================================== */
.dev-tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out forwards;
}

.dev-tab-content.active {
    display: block;
}

#nav-btn-developer:hover {
    background: rgba(231, 76, 60, 0.2) !important;
}

#nav-btn-developer.active {
    background: #C0392B !important;
    color: #FFFFFF !important;
    box-shadow: 0 4px 15px rgba(192, 57, 43, 0.3) !important;
}
