/* ==========================================================================
   DESIGN SYSTEM & CUSTOM PROPERTIES
   ========================================================================== */
:root {
    /* Colors */
    --color-bg-primary: #FDFBF7;
    --color-bg-white: #FFFFFF;
    --color-bg-muted: #F5EFEB;
    --color-bg-dark: #1A2530;
    --color-text-primary: #1A2530;
    --color-text-body: #323F4B;
    --color-text-muted: #627D98;
    --color-border: #EBE4D8;
    
    --color-accent-gold: #C5A880;
    --color-accent-amber: #E5A93C;
    --color-accent-amber-hover: #D09428;
    --color-danger: #D32F2F;
    --color-danger-hover: #B71C1C;
    --color-success: #2E7D32;

    /* Fonts */
    --font-heading: 'Kanit', sans-serif;
    --font-body: 'Sarabun', sans-serif;

    /* Shadow Styles */
    --shadow-sm: 0 2px 4px rgba(26, 37, 48, 0.05);
    --shadow-md: 0 8px 24px rgba(26, 37, 48, 0.08);
    --shadow-lg: 0 16px 36px rgba(26, 37, 48, 0.12);
    
    /* Layout */
    --border-radius-sm: 6px;
    --border-radius-md: 12px;
    --border-radius-lg: 24px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
}

/* ==========================================================================
   GLOBAL STYLES & INITIALIZATION
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-bg-primary);
    color: var(--color-text-body);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--color-text-primary);
    font-weight: 600;
}

/* Icons */
.icon {
    width: 20px;
    height: 20px;
    display: inline-block;
    vertical-align: middle;
    fill: currentColor;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 500;
    padding: 10px 24px;
    border-radius: var(--border-radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    outline: none;
}

.btn-primary {
    background-color: var(--color-accent-amber);
    color: var(--color-bg-white);
}

.btn-primary:hover {
    background-color: var(--color-accent-amber-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(229, 169, 60, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--color-bg-white);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background-color: var(--color-bg-muted);
    border-color: var(--color-accent-gold);
}

.btn-text {
    background: transparent;
    color: var(--color-text-primary);
    padding: 8px 16px;
}

.btn-text:hover {
    color: var(--color-accent-amber);
    background-color: rgba(229, 169, 60, 0.05);
}

.btn-icon-only {
    padding: 10px;
    border-radius: 50%;
}

.btn-icon-only span {
    display: none; /* Screen reader only helper if text available, otherwise hidden */
}

.btn-danger-hover:hover {
    background-color: var(--color-danger) !important;
    color: var(--color-bg-white) !important;
    border-color: var(--color-danger) !important;
}

.btn-sm-file {
    padding: 6px 14px;
    font-size: 13px;
    position: relative;
    overflow: hidden;
}

.btn-sm-file input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* ==========================================================================
   SPA VIEW SWITCHING SYSTEM
   ========================================================================== */
.view {
    display: none;
    opacity: 0;
    min-height: 100vh;
}

.view.active {
    display: flex;
    flex-direction: column;
    animation: viewFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

/* ==========================================================================
   1. INTRO VIEW STYLES
   ========================================================================== */
#intro-view {
    justify-content: center;
    align-items: center;
    background-color: var(--color-bg-primary);
    position: relative;
    padding: 24px;
}

.intro-bg-shapes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
    pointer-events: none;
}

.intro-bg-shapes .shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
}

.intro-bg-shapes .circle-1 {
    width: 500px;
    height: 500px;
    background-color: var(--color-accent-amber);
    top: -100px;
    right: -100px;
}

.intro-bg-shapes .circle-2 {
    width: 600px;
    height: 600px;
    background-color: var(--color-accent-gold);
    bottom: -150px;
    left: -150px;
}

.intro-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    z-index: 5;
}

.intro-card {
    background-color: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    display: grid;
    grid-template-columns: 1.2fr 2fr;
    overflow: hidden;
}

@media (max-width: 768px) {
    .intro-card {
        grid-template-columns: 1fr;
    }
}

.teacher-profile-area {
    background-color: var(--color-bg-muted);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 48px;
    border-right: 1px solid var(--color-border);
}

@media (max-width: 768px) {
    .teacher-profile-area {
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        padding: 32px;
    }
}

.avatar-wrapper {
    width: 195px;
    height: 260px;
    border-radius: 16px;
    overflow: hidden;
    border: 4px solid var(--color-bg-white);
    box-shadow: var(--shadow-md);
    background-color: var(--color-bg-white);
}

@media (max-width: 480px) {
    .avatar-wrapper {
        width: 140px;
        height: 186px;
    }
}

.avatar-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.intro-content {
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@media (max-width: 768px) {
    .intro-content {
        padding: 32px;
    }
}

.subject-badge {
    display: inline-block;
    align-self: flex-start;
    background-color: rgba(229, 169, 60, 0.12);
    color: var(--color-accent-amber-hover);
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 50px;
    margin-bottom: 20px;
    letter-spacing: 0.5px;
}

#intro-title {
    font-size: 32px;
    line-height: 1.3;
    margin-bottom: 16px;
    color: var(--color-text-primary);
}

@media (max-width: 480px) {
    #intro-title {
        font-size: 24px;
    }
}

.intro-subtitle {
    font-size: 16px;
    color: var(--color-text-muted);
    margin-bottom: 28px;
    text-align: justify;
}

.teacher-info-box {
    background-color: var(--color-bg-primary);
    border-left: 4px solid var(--color-accent-amber);
    padding: 16px 20px;
    margin-bottom: 32px;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

.teacher-label {
    font-family: var(--font-heading);
    font-size: 12px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.teacher-name {
    font-size: 20px;
    color: var(--color-text-primary);
    margin-bottom: 2px;
}

.teacher-school {
    font-size: 14px;
    color: var(--color-text-muted);
}

.intro-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

/* ==========================================================================
   2. MAIN VIEW STYLES
   ========================================================================== */
.main-header {
    background-color: rgba(253, 251, 247, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 16px 24px;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

#header-logo-img {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-sm);
    object-fit: cover;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-sub {
    font-family: var(--font-heading);
    font-size: 12px;
    color: var(--color-accent-gold);
    font-weight: 500;
    line-height: 1.2;
}

.logo-main {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-primary);
    line-height: 1.3;
}

@media (max-width: 480px) {
    .logo-sub {
        font-size: 10px;
    }
    .logo-main {
        font-size: 14px;
    }
}

.header-nav {
    display: flex;
    gap: 12px;
}

@media (max-width: 600px) {
    .header-nav span {
        display: none;
    }
}

/* Banner section */
.banner-section {
    position: relative;
    height: 280px;
    width: 100%;
    overflow: hidden;
    background-color: var(--color-bg-dark);
}

.banner-bg-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.banner-bg-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.banner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(26, 37, 48, 0.4) 0%, rgba(26, 37, 48, 0.8) 100%);
}

.banner-content {
    position: relative;
    z-index: 5;
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: var(--color-bg-white);
}

.banner-content h2 {
    font-size: 38px;
    color: var(--color-accent-amber);
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.banner-content p {
    font-size: 18px;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

@media (max-width: 768px) {
    .banner-section {
        height: 220px;
    }
    .banner-content h2 {
        font-size: 28px;
    }
    .banner-content p {
        font-size: 15px;
    }
}

/* Main Grid content */
.main-content-area {
    max-width: 1200px;
    margin: 0 auto;
    padding: 48px 24px;
    width: 100%;
    flex-grow: 1;
}

.section-title-wrapper {
    margin-bottom: 36px;
    text-align: center;
}

.section-title-wrapper h3 {
    font-size: 26px;
    color: var(--color-text-primary);
    margin-bottom: 8px;
    position: relative;
    display: inline-block;
    padding-bottom: 12px;
}

.section-title-wrapper h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background-color: var(--color-accent-amber);
    border-radius: 2px;
}

.section-title-wrapper p {
    font-size: 15px;
    color: var(--color-text-muted);
}

/* Card layout */
.holidays-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

@media (max-width: 992px) {
    .holidays-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .holidays-grid {
        grid-template-columns: 1fr;
    }
}

.holiday-card {
    background-color: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
}

.holiday-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-accent-gold);
}

.card-img-wrapper {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.card-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-smooth);
}

.holiday-card:hover .card-img-wrapper img {
    transform: scale(1.08);
}

.card-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background-color: rgba(26, 37, 48, 0.85);
    color: var(--color-accent-amber);
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 50px;
    backdrop-filter: blur(4px);
    letter-spacing: 0.5px;
}

.card-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.card-body h4 {
    font-size: 20px;
    margin-bottom: 6px;
    color: var(--color-text-primary);
}

.card-body-en {
    font-size: 12px;
    font-family: var(--font-heading);
    color: var(--color-accent-gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.card-desc {
    font-size: 14px;
    color: var(--color-text-muted);
    margin-bottom: 24px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
    line-height: 1.5;
}

.card-actions {
    margin-top: auto;
}

.card-actions .btn {
    width: 100%;
}

/* Footer Section */
.main-footer {
    background-color: var(--color-bg-dark);
    color: rgba(255, 255, 255, 0.7);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 32px 24px;
    font-size: 14px;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

@media (max-width: 768px) {
    .footer-container {
        flex-direction: column;
        text-align: center;
    }
}

.footer-teacher-info {
    color: var(--color-bg-white);
    font-size: 15px;
    margin-bottom: 4px;
}

.footer-school-info {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   3. CONTENT VIEW STYLES
   ========================================================================== */
#content-view {
    background-color: var(--color-bg-primary);
}

.sticky-sub-header {
    background-color: var(--color-bg-white);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 90;
    padding: 12px 24px;
    box-shadow: var(--shadow-sm);
}

.sub-header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
}

@media (max-width: 600px) {
    .sub-header-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

.btn-back {
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    padding: 8px 18px;
    font-size: 14px;
}

.btn-back:hover {
    background-color: var(--color-bg-muted);
    border-color: var(--color-accent-amber);
    transform: translateX(-3px);
}

.current-holiday-info {
    display: flex;
    flex-direction: column;
}

#current-holiday-title {
    font-size: 22px;
    line-height: 1.2;
    color: var(--color-text-primary);
}

#current-holiday-title-en {
    font-family: var(--font-heading);
    font-size: 12px;
    color: var(--color-accent-gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Tabs */
.tabs-navigation-wrapper {
    background-color: var(--color-bg-white);
    border-bottom: 1px solid var(--color-border);
    padding: 0 24px;
}

.tabs-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    gap: 16px;
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 500;
    padding: 16px 20px;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-fast);
}

.tab-btn:hover {
    color: var(--color-text-primary);
    background-color: rgba(26, 37, 48, 0.02);
}

.tab-btn.active {
    color: var(--color-accent-amber-hover);
    border-bottom-color: var(--color-accent-amber);
}

.tab-btn .icon {
    width: 18px;
    height: 18px;
}

/* Tab Panels */
.content-view-body {
    flex-grow: 1;
}

.tab-panel {
    display: none;
    animation: panelFadeIn 0.4s ease forwards;
}

.tab-panel.active {
    display: block;
}

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

/* Lesson Tab */
.lesson-layout {
    max-width: 900px;
    margin: 40px auto;
    padding: 0 24px;
}

.lesson-main-card {
    background-color: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.lesson-banner {
    position: relative;
    height: 200px;
    display: flex;
    align-items: flex-end;
    padding: 32px 48px;
    color: var(--color-bg-white);
    background-color: var(--color-bg-dark);
}

@media (max-width: 600px) {
    .lesson-banner {
        padding: 24px;
        height: 150px;
    }
}

.lesson-banner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(0deg, rgba(26, 37, 48, 0.9) 0%, rgba(26, 37, 48, 0.3) 100%);
}

.lesson-banner-text {
    position: relative;
    z-index: 5;
}

#lesson-header-title {
    font-size: 30px;
    color: var(--color-accent-amber);
    margin-bottom: 4px;
}

#lesson-header-subtitle {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 300;
}

.lesson-rich-text {
    padding: 48px;
    font-size: 16px;
    color: var(--color-text-body);
}

@media (max-width: 600px) {
    .lesson-rich-text {
        padding: 24px;
    }
}

/* Styles for HTML elements generated inside rich text */
.lesson-section {
    margin-bottom: 36px;
}

.lesson-section h4 {
    font-size: 20px;
    color: var(--color-text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid var(--color-bg-muted);
    padding-bottom: 8px;
}

.lesson-section h4 .section-icon {
    color: var(--color-accent-amber);
    width: 22px;
    height: 22px;
}

.lesson-section p {
    margin-bottom: 14px;
    text-align: justify;
    text-indent: 32px;
}

.lesson-section ul {
    margin-left: 20px;
    margin-bottom: 16px;
    list-style-type: none;
}

.lesson-section ul li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 8px;
}

.lesson-section ul li::before {
    content: "•";
    color: var(--color-accent-amber);
    font-size: 18px;
    position: absolute;
    left: 0;
    top: -2px;
}

.highlight-box {
    background-color: var(--color-bg-muted);
    border-left: 4px solid var(--color-accent-gold);
    padding: 20px 24px;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
    margin: 24px 0;
}

.highlight-box h5 {
    font-size: 16px;
    margin-bottom: 6px;
    color: var(--color-text-primary);
}

.highlight-box p {
    margin-bottom: 0;
    text-indent: 0;
    font-style: italic;
    color: var(--color-text-muted);
    font-size: 15px;
}

/* PDF Viewer Tab */
.pdf-viewer-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 190px);
    background-color: #E5E2DB;
}

@media (max-width: 600px) {
    .pdf-viewer-layout {
        height: auto;
        min-height: 600px;
    }
}

.pdf-toolbar {
    background-color: var(--color-bg-white);
    border-bottom: 1px solid var(--color-border);
    padding: 8px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .pdf-toolbar {
        justify-content: center;
        padding: 12px;
    }
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.zoom-percent-text {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 500;
    width: 48px;
    text-align: center;
    color: var(--color-text-primary);
}

.zoom-slider {
    width: 120px;
    accent-color: var(--color-accent-amber);
    cursor: pointer;
}

@media (max-width: 480px) {
    .zoom-slider {
        display: none;
    }
}

.pdf-viewport {
    flex-grow: 1;
    overflow: auto;
    position: relative;
    padding: 30px;
    display: flex;
    box-sizing: border-box;
    width: 100%;
}

.pdf-canvas-wrapper {
    position: relative;
    margin: auto;
    transition: width 0.1s ease-out;
}

/* Grab to Pan functionality */
.pdf-viewport.zoomed {
    cursor: grab;
}

.pdf-viewport.zoomed:active {
    cursor: grabbing;
}

.mock-pdf-page {
    width: 100%;
    max-width: 800px;
    height: auto;
    min-height: 1130px; /* A4 Ratio */
    background-color: var(--color-bg-white);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    padding: 60px 70px;
    display: flex;
    flex-direction: column;
    font-size: 15px;
    color: #333333;
    pointer-events: auto;
    user-select: none; /* เพื่อไม่ให้คลุมข้อความเมื่อทำการ Pan */
}

@media (max-width: 860px) {
    /* บนหน้าจอมือถือ/แท็บเล็ตที่ไม่ซูม ให้ปรับสเกลพอดีกว้าง */
    .mock-pdf-page {
        padding: 30px;
        min-height: auto;
        aspect-ratio: 1 / 1.414; /* A4 Ratio */
    }
}

@media (max-width: 480px) {
    .mock-pdf-page {
        padding: 16px;
        font-size: 13px;
    }
}

/* Mock PDF inner styling */
.pdf-header {
    border-bottom: 2px double #C5A880;
    padding-bottom: 12px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pdf-header-title {
    font-family: var(--font-heading);
    font-size: 22px;
    color: var(--color-text-primary);
}

.pdf-header-subject {
    font-family: var(--font-heading);
    font-size: 12px;
    color: var(--color-accent-gold);
    text-transform: uppercase;
}

.pdf-meta-box {
    border: 1px solid var(--color-border);
    padding: 10px 16px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

.pdf-section-title {
    font-family: var(--font-heading);
    font-size: 16px;
    color: var(--color-text-primary);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 4px;
    margin-top: 18px;
    margin-bottom: 10px;
}

.pdf-desc-text {
    text-indent: 24px;
    margin-bottom: 12px;
    line-height: 1.5;
    text-align: justify;
}

.pdf-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.pdf-table th, .pdf-table td {
    border: 1px solid #C5A880;
    padding: 8px 12px;
    font-size: 13px;
    text-align: left;
}

.pdf-table th {
    background-color: var(--color-bg-muted);
    font-family: var(--font-heading);
    font-weight: 500;
}

.pdf-footer {
    margin-top: auto;
    border-top: 1px solid var(--color-border);
    padding-top: 12px;
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--color-text-muted);
}

/* Real PDF display */
.real-pdf-container {
    width: 100%;
    max-width: 800px;
    height: 1130px;
    background-color: var(--color-bg-white);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

@media (max-width: 860px) {
    .real-pdf-container {
        height: auto;
        aspect-ratio: 1 / 1.414; /* A4 Ratio */
    }
}

/* Worksheet Image rendering styles */
.worksheet-img-container {
    width: 100%;
    max-width: 800px;
    background-color: var(--color-bg-white);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.worksheet-img-container img {
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.pdf-instruction {
    background-color: var(--color-bg-white);
    border-top: 1px solid var(--color-border);
    padding: 8px 24px;
    text-align: center;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Poster Tab */
.poster-layout {
    max-width: 800px;
    margin: 40px auto;
    padding: 0 24px;
}

.poster-main-card {
    background-color: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.poster-image-container {
    width: 100%;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    border: 1px solid var(--color-border);
    background-color: var(--color-bg-muted);
    display: flex;
    justify-content: center;
    align-items: center;
}

.poster-image {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
}

.poster-info-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    border-top: 1px solid var(--color-border);
    padding-top: 20px;
}

@media (max-width: 640px) {
    .poster-info-actions {
        flex-direction: column;
        text-align: center;
    }
}

.poster-text h4 {
    font-size: 18px;
    color: var(--color-text-primary);
    margin-bottom: 4px;
}

.poster-text p {
    font-size: 14px;
    color: var(--color-text-muted);
}

.btn-large {
    padding: 12px 32px;
    font-size: 16px;
}

/* ==========================================================================
   4. MODAL CONFIG PANEL STYLES (TEACHER CONTROL PANEL)
   ========================================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 37, 48, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-container {
    background-color: var(--color-bg-white);
    border-radius: var(--border-radius-md);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-container.modal-sm {
    max-width: 420px;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
    20%, 40%, 60%, 80% { transform: translateX(10px); }
}

.modal-container.shake {
    animation: shake 0.5s ease-in-out;
    border: 1px solid var(--color-danger);
}


.modal-header {
    background-color: var(--color-bg-primary);
    border-bottom: 1px solid var(--color-border);
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 4px;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.btn-close:hover {
    color: var(--color-text-primary);
    background-color: var(--color-bg-muted);
}

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

.modal-footer {
    background-color: var(--color-bg-primary);
    border-top: 1px solid var(--color-border);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

@media (max-width: 480px) {
    .modal-body {
        padding: 16px;
    }
    .modal-footer {
        padding: 12px 16px;
        flex-direction: column;
        align-items: stretch;
    }
    .modal-footer .btn {
        width: 100%;
    }
    .footer-actions {
        flex-direction: column;
        width: 100%;
    }
}

.footer-actions {
    display: flex;
    gap: 12px;
}

/* Form Styling inside modal */
.form-section-title {
    font-family: var(--font-heading);
    font-size: 16px;
    color: var(--color-accent-amber-hover);
    border-bottom: 1.5px solid var(--color-accent-gold);
    padding-bottom: 4px;
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 500;
}

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

.form-group-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 580px) {
    .form-group-grid {
        grid-template-columns: 1fr;
    }
}

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

.form-group label {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary);
}

.form-group input[type="text"],
.form-group textarea {
    font-family: var(--font-body);
    font-size: 15px;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    outline: none;
    transition: var(--transition-fast);
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    border-color: var(--color-accent-amber);
    box-shadow: 0 0 0 3px rgba(229, 169, 60, 0.15);
}

/* File Upload boxes */
.file-uploads-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 640px) {
    .file-uploads-grid {
        grid-template-columns: 1fr;
    }
}

.upload-box-wrapper {
    background-color: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
}

.upload-box-wrapper.full-width {
    grid-column: 1 / -1;
}

.upload-label {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
}

.upload-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid var(--color-bg-white);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    background-color: var(--color-bg-white);
    display: flex;
    justify-content: center;
    align-items: center;
}

.upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.logo-preview-placeholder {
    font-family: var(--font-heading);
    font-size: 38px;
    font-weight: bold;
    color: var(--color-accent-amber);
}

.banner-preview {
    width: 100%;
    height: 120px;
    border-radius: var(--border-radius-sm);
}

.btn-file-upload {
    display: inline-block;
    background-color: var(--color-bg-white);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    padding: 6px 16px;
    font-family: var(--font-heading);
    font-size: 13px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: var(--transition-fast);
}

.btn-file-upload:hover {
    border-color: var(--color-accent-gold);
    background-color: var(--color-bg-muted);
}

.btn-file-upload input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* PDF uploads lists */
.section-hint {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.pdf-management-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pdf-manage-item {
    background-color: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.p-manage-name {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 500;
    min-width: 120px;
}

.p-status-label {
    font-size: 12px;
    color: var(--color-text-muted);
    background-color: var(--color-bg-white);
    padding: 4px 10px;
    border-radius: 50px;
    border: 1px dashed var(--color-border);
}

.p-status-label.has-uploaded {
    color: var(--color-success);
    border-color: var(--color-success);
    background-color: rgba(46, 125, 50, 0.05);
    font-weight: 500;
}

.btn-reset-pdf {
    font-size: 12px;
    padding: 4px 8px;
    color: var(--color-danger);
}

.btn-reset-pdf:hover {
    background-color: rgba(211, 47, 47, 0.05);
    color: var(--color-danger-hover);
}

/* Password Visibility Toggle */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.btn-toggle-pw {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    transition: var(--transition-fast);
}

.btn-toggle-pw:hover {
    color: var(--color-accent-amber-hover);
}

.btn-toggle-pw .icon {
    width: 20px;
    height: 20px;
}

/* Teacher Password Change Box */
.teacher-password-change-box {
    background-color: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    padding: 20px;
    margin-bottom: 24px;
    border-left: 4px solid var(--color-accent-gold);
}

.change-pw-title {
    display: block;
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 16px;
}

.pw-change-actions {
    display: flex;
    align-items: center;
    margin-top: 12px;
    flex-wrap: wrap;
    gap: 12px;
}

#pw-change-status {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 500;
}

/* Holiday Images Config Grid */
.holiday-images-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

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

@media (max-width: 480px) {
    .holiday-images-grid {
        grid-template-columns: 1fr;
    }
}

.h-img-upload-box {
    background-color: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    transition: var(--transition-smooth);
}

.h-img-upload-box:hover {
    border-color: var(--color-accent-gold);
    box-shadow: var(--shadow-sm);
}

.h-img-label {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
}

.h-img-preview {
    width: 100%;
    height: 100px;
    border-radius: var(--border-radius-sm);
    border: 2px solid var(--color-bg-white);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    background-color: var(--color-bg-white);
    display: flex;
    justify-content: center;
    align-items: center;
}

.h-img-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-xs-file {
    padding: 4px 10px;
    font-size: 12px;
}

/* ==========================================================================
   PRINT STYLES (สำหรับดาวน์โหลดเป็น PDF หรือพิมพ์ใบงานผ่านเบราว์เซอร์)
   ========================================================================== */
@media print {
    body, html {
        background-color: #FFFFFF !important;
        color: #000000 !important;
        font-family: 'Sarabun', 'Kanit', sans-serif !important;
        width: 210mm;
        height: 297mm;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* ซ่อนส่วนอื่นๆ ทั้งหมด */
    .view, .main-header, .sticky-sub-header, .tabs-navigation-wrapper, .pdf-toolbar, .pdf-instruction, .main-footer, .modal-overlay {
        display: none !important;
    }

    /* แสดงเฉพาะส่วนหน้าจอวิวพอร์ต PDF */
    #content-view, #tab-panel-pdf, .pdf-viewer-layout, .pdf-viewport, .pdf-canvas-wrapper {
        display: block !important;
        position: static !important;
        overflow: visible !important;
        width: 100% !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        transform: none !important;
        background: transparent !important;
    }

    /* จัดหน้ากระดาษจำลอง A4 */
    .mock-pdf-page {
        display: flex !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 297mm !important;
        padding: 20mm !important;
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        page-break-after: always;
        page-break-inside: avoid;
        background-color: #FFFFFF !important;
    }
}

/* ==========================================================================
   UPDATES FOR DOWNLOAD BUTTON & STUDY BUTTONS & ZOOM CONTAINER
   ========================================================================== */

/* Circular Download Button next to Zoom Reset button */
.btn-circle-download {
    border-radius: 50% !important;
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background-color: var(--color-accent-amber) !important;
    color: var(--color-bg-white) !important;
    border: none !important;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
    cursor: pointer;
}

.btn-circle-download:hover {
    background-color: var(--color-accent-amber-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(229, 169, 60, 0.4);
}

.btn-circle-download:active {
    transform: translateY(0);
}

.btn-circle-download .icon {
    width: 20px;
    height: 20px;
    margin: 0 !important;
}

/* Custom colors for 5 holidays study buttons */
.btn-study.btn-visakha {
    background-color: #e67d84 !important;
    border-color: #e67d84 !important;
    color: var(--color-bg-white) !important;
}
.btn-study.btn-visakha:hover {
    background-color: #d1646b !important;
    border-color: #d1646b !important;
    box-shadow: 0 4px 12px rgba(230, 125, 132, 0.4) !important;
}

.btn-study.btn-asanha {
    background-color: #4077b6 !important;
    border-color: #4077b6 !important;
    color: var(--color-bg-white) !important;
}
.btn-study.btn-asanha:hover {
    background-color: #315e93 !important;
    border-color: #315e93 !important;
    box-shadow: 0 4px 12px rgba(64, 119, 182, 0.4) !important;
}

.btn-study.btn-khao-phansa {
    background-color: #4f763b !important;
    border-color: #4f763b !important;
    color: var(--color-bg-white) !important;
}
.btn-study.btn-khao-phansa:hover {
    background-color: #3d5c2d !important;
    border-color: #3d5c2d !important;
    box-shadow: 0 4px 12px rgba(79, 118, 59, 0.4) !important;
}

.btn-study.btn-ok-phansa {
    background-color: #e78319 !important;
    border-color: #e78319 !important;
    color: var(--color-bg-white) !important;
}
.btn-study.btn-ok-phansa:hover {
    background-color: #c97112 !important;
    border-color: #c97112 !important;
    box-shadow: 0 4px 12px rgba(231, 131, 25, 0.4) !important;
}

.btn-study.btn-athami {
    background-color: #886034 !important;
    border-color: #886034 !important;
    color: var(--color-bg-white) !important;
}
.btn-study.btn-athami:hover {
    background-color: #6e4d27 !important;
    border-color: #6e4d27 !important;
    box-shadow: 0 4px 12px rgba(136, 96, 52, 0.4) !important;
}
