/* --- Google Font --- */
@import url('/npm/apexcharts/dist/apexcharts.min.css');

/* --- CSS Variables (ตัวแปรสี) --- */
:root {
    --primary-color: #41826e;
    --white-color: #ffffff;
    --dark-grey-color: #333333;
    --light-grey-color: #f4f7f6;
    --border-color: #e0e0e0;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

/* --- Global Styles --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: 'Prompt', sans-serif;
    line-height: 1.7;
    color: var(--dark-grey-color);
    background-color: var(--white-color);
}

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

img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { color: var(--primary-color); margin-bottom: 1rem; }
.section-title { text-align: center; font-size: 2.5rem; margin-bottom: 3rem; }
.section-bg { background-color: var(--light-grey-color); }
section { padding: 80px 0; }
a { text-decoration: none; }

/* --- Header & Navbar --- */
.header {
    background-color: var(--white-color);
    box-shadow: var(--shadow);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
}

.navbar { display: flex; justify-content: space-between; align-items: center; height: 80px; }
.logo img { height: 50px; }
.nav-menu { display: flex; list-style: none; gap: 30px; }
.nav-link { text-decoration: none; color: var(--dark-grey-color); font-weight: 400; transition: color 0.3s ease; }
.nav-link:hover { color: var(--primary-color); }
.hamburger { display: none; cursor: pointer; }
.bar { display: block; width: 25px; height: 3px; margin: 5px auto; background-color: var(--dark-grey-color); transition: all 0.3s ease-in-out; }

/* --- Hero Section --- */
.hero {
    height: 100vh;
    position: relative;
    overflow: hidden;
    color: var(--white-color);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 500%;
    height: 100%;
    display: flex;
    transition: transform 0.8s ease-in-out;
    z-index: 1;
}

.slide {
    width: 20%;
    height: 100vh;
}

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

.hero::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.hero-content {
    position: relative;
    z-index: 3;
    max-width: 800px;
}

.hero-title {
    font-size: 3.5rem;
    color: var(--white-color);
    font-weight: 600;
}

.hero-subtitle {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    font-weight: 300;
}

.btn {
    display: inline-block;
    background-color: var(--primary-color);
    color: var(--white-color);
    padding: 12px 30px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.3s ease;
}

.btn:hover {
    background-color: #356a5a;
}

.slider-dots {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 3;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.dot.active {
    background-color: var(--white-color);
}

/* --- Services Section --- */
.services-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; text-align: center; }
.service-link { text-decoration: none; color: inherit; display: block; height: 100%; }
.service-item { background: var(--white-color); padding: 2rem; border-radius: 10px; box-shadow: var(--shadow); transition: transform 0.3s ease, box-shadow 0.3s ease; height: 100%; }
.service-item:hover { transform: translateY(-10px); box-shadow: 0 8px 25px rgba(0,0,0,0.15); }
.service-icon { font-size: 2.5rem; color: var(--primary-color); margin-bottom: 1rem; }

/* --- Accordion Styles --- */
.accordion { max-width: 800px; margin: 0 auto; }
.accordion-item { border-bottom: 1px solid var(--border-color); }
.accordion-item:last-child { border-bottom: none; }
.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 1.2rem 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    font-family: 'Prompt', sans-serif;
    font-weight: 600;
    color: var(--dark-grey-color);
    text-align: left;
}
.accordion-header .icon {
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--primary-color);
    transition: transform 0.3s ease;
}
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding: 0 0.5rem;
}
.accordion-content p { margin-bottom: 1rem; color: #555; }
.accordion-item.active .accordion-header .icon { transform: rotate(45deg); }
.accordion-item.active .accordion-content {
    max-height: 200px;
    padding-bottom: 1.5rem;
}
.read-more { color: var(--primary-color); font-weight: 600; }

/* --- Footer Section --- */
.footer { background-color: var(--primary-color); color: var(--white-color); padding: 50px 0 0; }
.footer-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 2rem; padding-bottom: 40px; }
.footer h4 { margin-bottom: 1rem; color: var(--white-color); font-size: 1.2rem; }
.footer p, .footer a { color: rgba(255, 255, 255, 0.8); text-decoration: none; display: block; margin-bottom: 0.5rem; transition: color 0.3s ease; }
.footer a:hover { color: var(--white-color); }
.footer ul { list-style: none; }
.footer-bottom { text-align: center; padding: 20px; border-top: 1px solid rgba(255, 255, 255, 0.2); }

/* --- Fade-in Animation on Scroll --- */
.section-fade-in { opacity: 0; transform: translateY(30px); transition: opacity 0.6s ease-out, transform 0.6s ease-out; }
.section-fade-in.visible { opacity: 1; transform: translateY(0); }

/* ======================= NEWS POPUP SLIDER STYLES ======================= */
.news-popup-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.48);
    z-index: 100000;
    justify-content: center;
    align-items: center;
}

.news-popup-box {
    background: #fff;
    color: #222;
    border-radius: 12px;
    max-width: 1000px;
    width: 90vw;
    padding: 40px 44px 32px 44px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.21);
    position: relative;
    text-align: center;
    font-size: 1.17rem;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.news-popup-close-btn {
    position: absolute;
    top: 14px;
    right: 18px;
    background: var(--primary-color, #41826e);
    color: #fff;
    border: none;
    font-size: 2.1rem;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.18s;
    z-index: 2;
}

.news-popup-close-btn:hover {
    background: #ba1e1e;
}

/* ปุ่มเลื่อนซ้าย-ขวา */
.news-popup-prev,
.news-popup-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(65, 130, 110, 0.8);
    color: white;
    border: none;
    font-size: 2rem;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.news-popup-prev:hover,
.news-popup-next:hover {
    background: rgba(65, 130, 110, 1);
}

.news-popup-prev {
    left: 15px;
}

.news-popup-next {
    right: 15px;
}

/* Container สำหรับสไลด์ */
.news-popup-slides-container {
    position: relative;
    width: 100%;
    min-height: 300px;
}

/* สไลด์แต่ละอัน */
.news-popup-slide {
    display: none;
    width: 100%;
    animation: fadeInSlide 0.5s ease-in-out;
}

.news-popup-slide.active {
    display: block;
}

.news-popup-slide h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

/* ปรับขนาดรูปใน Popup ให้เหมือนเดิม */
.news-popup-slide img {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    height: auto;
    margin: 0 auto;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.10);
}

.news-popup-slide p {
    margin: 1rem 0;
    line-height: 1.6;
}

/* จุด dots สำหรับบอกสไลด์ */
.news-popup-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.news-popup-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ccc;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.news-popup-dot.active {
    background-color: var(--primary-color);
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Popup ผู้เข้าชมเว็บ (Visitor Counter) --- */
.su-visitor-counter-popup {
    position: fixed;
    bottom: 25px;
    left: 25px;
    z-index: 10001;
    min-width: 210px;
    font-family: 'Prompt', sans-serif;
    animation: fadeIn .7s;
}

.su-visitor-counter-box {
    background: #fff;
    color: #222;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(0,0,0,.18), 0 1.5px 0 #41826e;
    padding: 14px 20px 15px 18px;
    font-size: 1.04rem;
    min-width: 170px;
    min-height: 60px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.su-visitor-counter-title {
    color: #41826e;
    font-weight: 600;
    margin-bottom: 3px;
    font-size: 1.08em;
    letter-spacing: 0.01em;
    cursor: default;
}

.su-visitor-counter-values {
    color: #222;
    letter-spacing: 0.03em;
    font-weight: 400;
}

.su-visitor-counter-values b {
    color: #19705A;
    font-size: 1.05em;
    font-weight: 700;
}

.su-visitor-counter-close-btn {
    position: absolute;
    top: 5px;
    right: 10px;
    background: #41826e;
    color: #fff;
    border: none;
    font-size: 1.3em;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    transition: background .16s;
    z-index: 2;
    padding: 0;
}

.su-visitor-counter-close-btn:hover {
    background: #ba1e1e;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(36px) scale(.95);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* ======================= EVENT TIMELINE SECTION ======================= */
.timeline-container {
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 0;
}

.timeline-container::after {
    content: '';
    position: absolute;
    width: 4px;
    background-color: var(--border-color);
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

.events-container {
    position: relative;
    z-index: 2;
}

.event-card {
    position: relative;
    background: white;
    width: 50%;
    z-index: 2;
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 3rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s, transform 0.6s, box-shadow 0.3s;
    padding: 1.5rem;
}

.event-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.event-card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.event-card:nth-of-type(odd) {
    left: 0;
    padding-right: 40px;
    text-align: right;
}

.event-card:nth-of-type(even) {
    left: 50%;
    padding-left: 40px;
    text-align: left;
}

.event-card::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: #fff;
    border: 4px solid var(--primary-color);
    top: 25px;
    border-radius: 50%;
    z-index: 3;
}

.event-card:nth-of-type(odd)::after {
    right: -10px;
}

.event-card:nth-of-type(even)::after {
    left: -10px;
}

.event-status {
    position: absolute;
    top: -12px;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 15px;
    color: white;
    z-index: 4;
    white-space: nowrap;
}

.event-card:nth-of-type(odd) .event-status {
    right: 40px;
}

.event-card:nth-of-type(even) .event-status {
    left: 40px;
}

.event-status.past {
    background-color: #6c757d;
}

.event-status.today {
    background-color: #28a745;
}

.event-status.upcoming {
    background-color: #ffc107;
    color: #333;
}

.event-status.invalid {
    background-color: #dc3545;
}

.event-date, .event-end-date, .event-location {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    color: #555;
    font-size: 0.9rem;
}

.event-card:nth-of-type(odd) .event-date,
.event-card:nth-of-type(odd) .event-end-date,
.event-card:nth-of-type(odd) .event-location {
    justify-content: flex-end;
}

.event-card:nth-of-type(even) .event-date,
.event-card:nth-of-type(even) .event-end-date,
.event-card:nth-of-type(even) .event-location {
    justify-content: flex-start;
}

.event-icon {
    font-size: 1.1rem;
}

.event-title {
    font-size: 1.25rem;
    margin: 1rem 0;
    color: var(--dark-grey-color);
}

.event-details-link {
    display: inline-block;
    margin-top: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    transition: color 0.3s;
}

.event-details-link:hover {
    color: #0056b3;
}

.event-manage-link {
    text-align: center;
    margin-top: 3rem;
}

.loading-spinner {
    text-align: center;
    color: #666;
    padding: 2rem;
    width: 100%;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.timeline-month-marker {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 3;
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    font-weight: 600;
    text-align: center;
    margin: 2rem auto;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: background-color 0.3s;
    max-width: max-content;
}

.timeline-month-marker:hover {
    background-color: #356a5a;
}

.toggle-events-btn {
    margin-left: 10px;
    font-size: 1rem;
    transition: transform 0.3s ease;
}

.event-card.hidden {
    display: none;
}

.timeline-month-marker.expanded .toggle-events-btn {
    transform: rotate(180deg);
}

/* ======================= RESPONSIVE STYLES ======================= */

@media (max-width: 768px) {
    /* Navbar */
    .hamburger { display: block; }
    .hamburger.active .bar:nth-child(2) { opacity: 0; }
    .hamburger.active .bar:nth-child(1) { transform: translateY(8px) rotate(45deg); }
    .hamburger.active .bar:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 80px;
        flex-direction: column;
        background-color: var(--white-color);
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: var(--shadow);
    }
    .nav-menu.active { left: 0; }
    .nav-menu li { padding: 1rem 0; }

    /* Hero */
    .hero-title { font-size: 2.5rem; }
    .services-grid { grid-template-columns: 1fr; }
    .section-title { font-size: 2rem; }

    /* News Popup */
    .news-popup-box {
        width: 94vw;
        padding: 32px 20px 22px 20px;
        font-size: 1.08rem;
    }

    .news-popup-slide img {
        max-width: 100%;
        max-height: 60vh;
    }

    .news-popup-prev,
    .news-popup-next {
        width: 35px;
        height: 35px;
        font-size: 1.5rem;
    }

    .news-popup-prev {
        left: 5px;
    }

    .news-popup-next {
        right: 5px;
    }

    /* Visitor Counter */
    .su-visitor-counter-popup {
        left: 4vw;
        bottom: 10px;
        min-width: 46vw;
    }

    .su-visitor-counter-box {
        padding: 11px 10px 11px 14px;
        font-size: 0.99rem;
    }

    /* Event Timeline */
    .timeline-container {
        padding-left: 0;
        padding-right: 0;
    }

    .timeline-container::after {
        left: 28px;
        transform: none;
    }

    .event-card,
    .event-card:nth-of-type(even),
    .event-card:nth-of-type(odd) {
        width: calc(100% - 45px);
        left: 38px;
        right: auto;
        text-align: left !important;
        padding: 1.2rem 1rem 1.2rem 1.3rem;
        margin-bottom: 2.2rem;
        box-sizing: border-box;
    }

    .event-card::after,
    .event-card:nth-of-type(even)::after,
    .event-card:nth-of-type(odd)::after {
        left: -30px;
        right: auto;
    }

    .event-card .event-status,
    .event-card:nth-of-type(odd) .event-status,
    .event-card:nth-of-type(even) .event-status {
        left: 16px;
        right: auto !important;
        top: -15px;
    }

    .event-card .event-date,
    .event-card .event-end-date,
    .event-card .event-location,
    .event-card:nth-of-type(odd) .event-date,
    .event-card:nth-of-type(odd) .event-end-date,
    .event-card:nth-of-type(odd) .event-location,
    .event-card:nth-of-type(even) .event-date,
    .event-card:nth-of-type(even) .event-end-date,
    .event-card:nth-of-type(even) .event-location {
        justify-content: flex-start;
        text-align: left;
    }

    .timeline-month-marker {
        margin-left: 56px;
        margin-right: 0;
        left: 0 !important;
        transform: none !important;
    }
}

@media (max-width: 520px) {
    .news-popup-box {
        width: 96vw;
        padding: 24px 15px 16px 15px;
        font-size: 1em;
    }

    .news-popup-slide img {
        max-width: 100%;
        max-height: 50vh;
    }

    .news-popup-prev,
    .news-popup-next {
        width: 30px;
        height: 30px;
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .timeline-container::after {
        left: 20px;
    }

    .event-card,
    .event-card:nth-of-type(even),
    .event-card:nth-of-type(odd) {
        width: calc(100% - 15px);
        left: 13px;
        padding-left: 0.8rem;
        padding-right: 0.5rem;
        margin-bottom: 1.6rem;
    }

    .event-card::after,
    .event-card:nth-of-type(even)::after,
    .event-card:nth-of-type(odd)::after {
        left: -16px;
    }

    .timeline-month-marker {
        margin-left: 27px;
    }

    .news-popup-box {
        padding: 20px 10px 14px 10px;
    }

    .news-popup-slide img {
        max-width: 100%;
        max-height: 45vh;
    }
}