/* styles.css */

/* 1. Global Styles & Variables */
:root {
    --font-primary: 'Sarabun', 'Noto Sans Thai', sans-serif;
    --font-display: 'Sarabun', sans-serif;

    /* Light Theme */
    --color-background: #f8f9fa;
    --color-surface: #ffffff;
    --color-text-primary: #212529;
    --color-text-secondary: #6c757d;
    --color-border: #dee2e6;
    --color-primary: #007bff;
    --color-primary-hover: #0056b3;
    --color-accent: #17a2b8;
    --color-success: #28a745;
    --color-danger: #dc3545;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --color-background: #121212;
    --color-surface: #1e1e1e;
    --color-text-primary: #e0e0e0;
    --color-text-secondary: #a0a0a0;
    --color-border: #444444;
    --color-primary: #4dabf7;
    --color-primary-hover: #74c0fc;
    --color-accent: #38d9a9;
    --color-success: #40c057;
    --color-danger: #f06595;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px; /* Offset for sticky header */
}

body {
    font-family: var(--font-primary);
    background-color: var(--color-background);
    color: var(--color-text-primary);
    line-height: 1.7;
    font-size: 16px;
    transition: background-color 0.3s, color 0.3s;
}

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

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    margin-bottom: 0.75em;
    line-height: 1.3;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; color: var(--color-primary); }
h3 { font-size: 1.5rem; }

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

.hidden { display: none !important; }

/* 2. Header & Navigation */
.site-header {
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 0;
    transition: background-color 0.3s, border-color 0.3s;
}

.sticky-top {
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--color-text-primary);
}
.logo-link:hover { text-decoration: none; }

/* --- UPDATED CODE FOR LOGO --- */
.logo-img {
    max-height: 40px; /* Changed from height to max-height */
    width: auto;      /* Let width adjust automatically */
    height: auto;     /* Let height adjust to maintain aspect ratio */
}
/* --- END OF UPDATE --- */


.nav-menu {
    display: flex;
    list-style: none;
    gap: 25px;
}
.nav-menu a {
    color: var(--color-text-secondary);
    font-weight: 500;
    padding: 5px 0;
    position: relative;
}
.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--color-primary);
    transition: width 0.3s;
}
.nav-menu a:hover, .nav-menu a.active {
    color: var(--color-text-primary);
}
.nav-menu a:hover::after, .nav-menu a.active::after {
    width: 100%;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-container {
    position: relative;
}

#search-box {
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 8px 15px 8px 35px;
    background-color: var(--color-background);
    color: var(--color-text-primary);
    width: 200px;
    transition: all 0.3s;
}
#search-box:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}
.icon-search {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
}

.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-button:hover { color: var(--color-text-primary); }
.icon { width: 24px; height: 24px; }

#theme-toggle .icon-moon { display: none; }
[data-theme="dark"] #theme-toggle .icon-sun { display: none; }
[data-theme="dark"] #theme-toggle .icon-moon { display: block; }

.lang-switcher button {
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text-secondary);
}
.lang-switcher button.active {
    color: var(--color-primary);
    font-weight: 700;
}

/* 3. Sections & Content */
.content-section {
    padding: 60px 0;
}
.alt-bg {
    background-color: var(--color-surface);
}
.content-section h2 {
    text-align: center;
    margin-bottom: 1rem;
}
.content-section > .container > p {
    text-align: center;
    max-width: 700px;
    margin: 0 auto 40px auto;
    color: var(--color-text-secondary);
}

.official-warning {
    background-color: var(--color-danger);
    color: white;
    text-align: center;
    padding: 10px;
    font-weight: 500;
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 80px 0;
}
.hero-section .subtitle {
    font-size: 1.25rem;
    color: var(--color-text-secondary);
    margin-bottom: 40px;
}
.cta-button {
    background-color: var(--color-primary);
    color: white;
    padding: 12px 30px;
    border-radius: 50px;
    font-weight: 700;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s, transform 0.2s;
    border: none;
    cursor: pointer;
}
.cta-button:hover {
    background-color: var(--color-primary-hover);
    transform: translateY(-2px);
    color: white;
    text-decoration: none;
}
.secondary-button {
    background-color: var(--color-surface);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
    padding: 10px 25px;
    border-radius: 50px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}
.secondary-button:hover {
    background-color: var(--color-primary);
    color: white;
}

.key-facts {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 40px;
}
.key-fact-card {
    background-color: var(--color-surface);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    min-width: 200px;
    text-align: left;
}
.key-fact-card h4 {
    color: var(--color-accent);
    margin-bottom: 10px;
}
.key-fact-card p {
    font-size: 1.2rem;
    font-weight: 700;
}

/* Criteria Section */
.criteria-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}
.criteria-card {
    background-color: var(--color-surface);
    padding: 25px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--color-primary);
}
.criteria-card h3 {
    margin-top: 0;
}
.criteria-card ul {
    list-style: none;
    padding-left: 0;
}
.criteria-card ul li {
    padding-left: 20px;
    position: relative;
    margin-bottom: 10px;
}
.criteria-card ul li::before {
    content: '✓';
    color: var(--color-success);
    position: absolute;
    left: 0;
}
.criteria-card .timeline-item {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--color-border);
    padding: 5px 0;
}

/* Blueprint Section */
.chart-container-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}
.chart-wrapper {
    background-color: var(--color-surface);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    position: relative; 
}
.chart-wrapper.full-width {
    grid-column: 1 / -1;
    height: 450px; 
}
.chart-wrapper h3 {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 1.2rem;
}
.blueprint-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background-color: var(--color-surface);
    box-shadow: var(--shadow-sm);
    border-radius: 8px;
    overflow: hidden;
}
.blueprint-table th, .blueprint-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}
.blueprint-table thead th {
    background-color: var(--color-background);
    font-weight: 700;
}
.blueprint-table tbody tr:last-child td {
    border-bottom: none;
}
.blueprint-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}
.print-section-btn {
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
.print-section-btn:hover {
    background-color: var(--color-background);
    border-color: var(--color-text-secondary);
}

/* Quiz Section */
.quiz-container {
    max-width: 800px;
    margin: 0 auto;
}
.quiz-setup-card, .quiz-results-card {
    background-color: var(--color-surface);
    padding: 30px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    text-align: center;
}
.quiz-setup-card .form-group {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.quiz-setup-card label {
    font-weight: 500;
}
select {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background-color: var(--color-background);
    color: var(--color-text-primary);
}
#quiz-main {
    background-color: var(--color-surface);
    padding: 30px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}
.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}
.question-stem {
    font-size: 1.2rem;
    margin-bottom: 25px;
}
.choices-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.choice-item {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
}
.choice-item:hover {
    border-color: var(--color-primary);
    background-color: var(--color-background);
}
.choice-item.selected {
    border-color: var(--color-primary);
    background-color: rgba(0, 123, 255, 0.1);
}
.choice-item.correct {
    border-color: var(--color-success);
    background-color: rgba(40, 167, 69, 0.1);
}
.choice-item.incorrect {
    border-color: var(--color-danger);
    background-color: rgba(220, 53, 69, 0.1);
}
.rationale {
    margin-top: 20px;
    padding: 15px;
    background-color: var(--color-background);
    border-left: 4px solid var(--color-accent);
    border-radius: 4px;
}
#quiz-navigation {
    text-align: right;
    margin-top: 30px;
}
.quiz-results-summary {
    margin: 20px 0;
    font-size: 1.2rem;
}
.quiz-results-actions {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

/* 4. Components */
/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 30px;
}
.tab-link {
    padding: 10px 20px;
    cursor: pointer;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    margin-bottom: -1px; /* Overlap border */
}
.tab-link.active {
    border-color: var(--color-primary);
    color: var(--color-text-primary);
    font-weight: 700;
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

/* Accordion */
.accordion-item {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    margin-bottom: 10px;
    overflow: hidden;
}
.accordion-header {
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    padding: 15px 20px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.accordion-header::after {
    content: '+';
    font-size: 1.5rem;
    color: var(--color-text-secondary);
    transition: transform 0.3s;
}
.accordion-header.active::after {
    transform: rotate(45deg);
}
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}
.accordion-content-inner {
    padding: 0 20px 20px 20px;
    border-top: 1px solid var(--color-border);
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}
input[type="text"], input[type="email"], textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background-color: var(--color-background);
    color: var(--color-text-primary);
}
input.invalid, textarea.invalid {
    border-color: var(--color-danger);
}
.error-message {
    color: var(--color-danger);
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-text-primary);
    color: var(--color-surface);
    padding: 15px 25px;
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}
.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -10px);
}

/* Back to Top Button */
.back-to-top-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s, transform 0.3s;
}
.back-to-top-btn:hover {
    background-color: var(--color-primary-hover);
}
.back-to-top-btn.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

/* 5. Footer */
.site-footer {
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    padding: 30px 0;
    text-align: center;
    font-size: 0.9rem;
}

/* 6. Utility & Other */
.updates-contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}
.update-item {
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px dashed var(--color-border);
}
.update-item:last-child {
    border-bottom: none;
}
.update-date {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}
mark {
    background-color: #ffc107;
    padding: 2px 4px;
    border-radius: 3px;
}
[data-theme="dark"] mark {
    background-color: #fcc419;
    color: #000;
}

/* 7. Responsive Design */
@media (max-width: 992px) {
    .nav-menu {
        display: none; /* Simple hide for this version, can be replaced with a hamburger menu */
    }
    .chart-container-grid {
        grid-template-columns: 1fr;
    }
    .updates-contact-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    .main-nav { flex-direction: column; gap: 15px; }
    .nav-controls { width: 100%; justify-content: space-between; }
    #search-box { width: 150px; }
    .key-facts { flex-direction: column; align-items: center; }
    .chart-wrapper.full-width {
        height: 350px; /* Adjust height for smaller screens */
    }
}

/* 8. Print Styles */
@media print {
    body {
        background-color: #fff;
        color: #000;
        font-size: 12pt;
    }
    .site-header, .site-footer, .back-to-top-btn, .cta-button, .no-print,
    .official-warning, #hero, .quiz-setup-card, .quiz-results-actions,
    .nav-controls, .tabs, .filter-controls, .updates-contact-grid form,
    .print-section-btn {
        display: none !important;
    }
    
    .content-section {
        padding: 20px 0;
        page-break-before: always;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    a {
        text-decoration: none;
        color: #000;
    }
    
    a[href^="http"]::after {
        content: " (" attr(href) ")";
    }

    .chart-wrapper, .criteria-card, .accordion-item {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    .printable-area {
        display: block !important;
    }

    #quiz-results.printable-area h3, #quiz-results.printable-area #quiz-results-summary {
        display: block;
    }
}
