/* Reset default margins and padding */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables for consistent theming */
:root {
    --primary-color: #ffd700;
    --primary-dark: #ffcc00;
    --text-dark: #333;
    --text-light: #555;
    --text-muted: #666;
    --bg-light: rgba(255, 255, 255, 0.95);
    --shadow-light: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 8px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 8px 16px rgba(0, 0, 0, 0.2);
    --border-radius: 10px;
    --border-radius-large: 15px;
    --transition: all 0.3s ease;
}

/* Body styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: 80px; /* Space for fixed footer */
}

/* Background fallback for slow connections */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    z-index: -1;
}

/* Navigation styles */
nav {
    background: linear-gradient(135deg, var(--primary-color) 0%, #fff 100%);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-medium);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    transition: var(--transition);
}

nav .logo img {
    max-height: 50px;
    width: auto;
    transition: var(--transition);
}

nav .logo img:hover {
    transform: scale(1.05);
}

/* Navigation menu - Desktop */
.nav-menu {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 2rem;
    margin: 0;
}

.nav-menu li {
    position: relative;
}

.nav-menu a {
    color: var(--text-dark);
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.7rem 1.2rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    position: relative;
}

.nav-menu a:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: var(--text-dark);
    transform: translateX(-50%);
    transition: width 0.3s ease;
}

.nav-menu a:hover::after {
    width: 80%;
}

/* Hamburger menu button */
.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 0.5rem;
    border: none;
    background: none;
    z-index: 1001;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background-color: var(--text-dark);
    margin: 3px 0;
    transition: var(--transition);
    border-radius: 3px;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(-45deg) translate(-5px, 6px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(45deg) translate(-5px, -6px);
}

/* Language visibility driven by data-lang attribute on <html> */
html[data-lang="en"] .lang-th { display: none; }
html[data-lang="th"] .lang-en { display: none; }

/* Language Switcher */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 1rem;
}

.lang-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 0.5rem 0.8rem;
    background-color: var(--bg-light);
    color: var(--text-dark);
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.lang-icon:hover, .lang-icon.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-dark);
    transform: translateY(-2px);
}

.lang-icon:first-child {
    margin-left: 0;
}


/* Hero section */
.hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, rgba(255, 255, 255, 0.95) 100%);
    text-align: center;
    padding: 2rem 1.5rem 1rem;
    margin-top: 80px;
    position: relative;
    overflow: hidden;
    min-height: calc(100vh - 160px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="%23ffd700" stroke-width="0.5" opacity="0.3"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.1;
}

.hero-content {
    position: relative;
    z-index: 1;
}

/* ********** START แก้ไขจุดที่ 3: Hero Text Visibility ********** */
.hero-content h1 {
    font-size: clamp(1.4rem, 3.5vw, 2.2rem);
    color: #000;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    animation: fadeInUp 0.8s ease-out;
}

.hero-content p {
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: #333;
    margin-bottom: 1rem;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.hero .btn {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #000;
    padding: 0.6rem 1.8rem;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 50px;
    box-shadow: var(--shadow-medium);
    transition: var(--transition);
    animation: fadeInUp 0.8s ease-out 0.4s both;
    position: relative;
    overflow: hidden;
}
/* ********** END แก้ไขจุดที่ 3 ********** */

.hero .btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.hero .btn:hover::before {
    left: 100%;
}

.hero .btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-heavy);
}

.hero-image {
    max-width: min(70%, 400px);
    height: auto;
    margin-top: 1rem;
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-heavy);
    animation: fadeIn 1s ease-out 0.6s both;
    transition: var(--transition);
}

.hero-image:hover {
    transform: scale(1.02);
}

/* Content sections */
.about, .events, .contact {
    max-width: 1200px;
    margin: 4rem auto 2rem;
    padding: 3rem 2rem;
    background-color: var(--bg-light);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-medium);
    backdrop-filter: blur(10px);
}

/* Push events/contact sections below fixed nav on their own pages */
.events, .contact {
    margin-top: 100px;
}

.about h2, .events h2, .contact h2 {
    color: var(--text-dark);
    font-size: clamp(2rem, 4vw, 2.5rem);
    margin-bottom: 2rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    padding-bottom: 1rem;
}

.about h2::after, .events h2::after, .contact h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    border-radius: 2px;
}

/* About styles */
.about-text {
    font-size: 1.1rem;
    color: var(--text-light);
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
}

.about-text p {
    margin-bottom: 1.5rem;
    position: relative;
    padding-left: 1rem;
}

.about-text p::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

/* Events Grid Layout */
.events {
    padding: 3rem 1.5rem;
}

/* Search and Filter Styles */
.event-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.search-input {
    flex: 1;
    min-width: 250px;
    max-width: 400px;
    padding: 0.8rem 1.2rem;
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: var(--bg-light);
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
}

.filter-select {
    padding: 0.8rem 1.2rem;
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: var(--bg-light);
    cursor: pointer;
    transition: var(--transition);
    min-width: 140px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
}

.events-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

/* Hidden class for filtered events */
.hidden {
    display: none !important;
}

.event-item {
    background: linear-gradient(135deg, #ffffff 0%, #fff9e6 100%);
    padding: 2rem;
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-light);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.event-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
}

.event-item:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-heavy);
}

.event-item h3 {
    font-size: 1.3rem;
    color: var(--text-dark);
    margin-bottom: 1rem;
    line-height: 1.3;
    position: relative;
}

.event-item .event-date {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
}

.event-item p {
    font-size: 1rem;
    color: var(--text-muted);
    margin: 0.5rem 0;
    display: flex;
    align-items: center;
}

.event-item strong {
    color: var(--text-dark);
    margin-right: 0.5rem;
    min-width: 80px;
}

.event-item .event-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.event-item .event-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary-color);
    color: var(--text-dark);
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 600;
    transition: var(--transition);
}

.event-item .event-links a:hover {
    background: var(--primary-dark);
    color: white;
    transform: translateY(-2px);
}

.event-banner {
    width: 100%;
    height: 300px;
    object-fit: contain;
    margin-top: 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.event-banner:hover {
    transform: scale(1.02);
}

/* Contact styles */
.contact {
    text-align: center;
}

.contact-info {
    max-width: 600px;
    margin: 0 auto 3rem;
}

.contact-info p {
    font-size: 1.2rem;
    color: var(--text-light);
    margin: 1.5rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.contact-info i {
    color: var(--primary-color);
    font-size: 1.4rem;
    width: 24px;
}

.contact a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.contact a:hover {
    color: var(--primary-dark);
    transform: translateY(-2px);
}

/* Contact Form */
.contact-form {
    max-width: 600px;
    margin: 0 auto 3rem;
    text-align: left;
}

.contact-form h3 {
    text-align: center;
    color: var(--text-dark);
    margin-bottom: 2rem;
    font-size: 1.5rem;
}

.contact-form-element {
    display: grid;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    color: var(--text-dark);
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.form-group input,
.form-group textarea {
    padding: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: white;
    color: var(--text-dark);
    transition: var(--transition);
    font-family: inherit;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.submit-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-dark);
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.submit-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-heavy);
}

.submit-btn:active {
    transform: translateY(-1px);
}

/* Social Links */
.contact .social-links {
    margin-top: 3rem;
}

.contact .social-links h3 {
    color: var(--text-dark);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.contact .social-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 2rem;
}

.contact .social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    color: var(--text-dark);
    border-radius: 50%;
    font-size: 1.4rem;
    transition: var(--transition);
    text-decoration: none;
}

.contact .social-links a:hover {
    background: var(--primary-dark);
    color: white;
    transform: translateY(-3px);
}

/* Footer styles */
footer {
    background: linear-gradient(135deg, var(--primary-color) 0%, #fff 100%);
    color: var(--text-dark);
    text-align: center;
    padding: 1.5rem;
    position: fixed;
    bottom: 0;
    width: 100%;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

footer p {
    font-size: 0.9rem;
    margin: 0;
}

/* Email styling (with better accessibility) */
.email {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    position: relative;
    transition: var(--transition);
}

.email:hover {
    color: var(--primary-dark);
}

.email::after {
    content: '✉';
    margin-left: 0.5rem;
    font-size: 0.8em;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Loading spinner for images */
img {
    transition: var(--transition);
}

img[data-src] {
    filter: blur(5px);
    opacity: 0.7;
}

img.loaded {
    filter: blur(0);
    opacity: 1;
}

/* ===================================
   RESPONSIVE MEDIA QUERIES
   =================================== */

/* Large Tablets - 1024px and down */
@media (max-width: 1024px) {
    .events-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }

    .hero-content h1 {
        font-size: clamp(1.8rem, 4vw, 2.5rem);
    }
}

/* Tablets - 768px and down */
@media (max-width: 768px) {
    /* Navigation */
    .hamburger {
        display: flex;
    }

    .nav-menu {
        position: fixed;
        left: -100%;
        top: 80px;
        flex-direction: column;
        background: linear-gradient(135deg, var(--primary-color) 0%, #fff 100%);
        width: 100%;
        text-align: center;
        transition: var(--transition);
        box-shadow: var(--shadow-heavy);
        padding: 2rem 0;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-menu li {
        margin: 1rem 0;
    }
    
    /* ********** START แก้ไขจุดที่ 2: Hamburger Menu Link Color ********** */
    .nav-menu.active a {
        color: #000 !important; /* ตั้งเป็นสีดำถาวรเมื่อเมนูถูกเปิดใช้งานบนอุปกรณ์ขนาดเล็ก */
    }
    /* ********** END แก้ไขจุดที่ 2 ********** */


    .lang-switcher {
        margin-left: 0;
        margin-top: 1rem;
        justify-content: center;
    }

    /* Content sections */
    .about, .events, .contact {
        margin: 3rem 1rem 2rem;
        padding: 2rem 1.5rem;
    }

    .hero {
        padding: 1.5rem 1rem 1rem;
        margin-top: 80px;
    }

    .hero-image {
        max-width: 100%;
        height: auto;
    }

    /* Events */
    .events-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .event-item {
        padding: 1.5rem;
    }

    .event-item h3 {
        font-size: 1.1rem;
    }

    .event-banner {
        height: 180px;
    }

    /* Contact */
    .contact .social-links {
        flex-wrap: wrap;
    }

    /* Footer */
    footer {
        padding: 1rem;
    }
}

/* Small Tablets - 600px and down */
@media (max-width: 600px) {
    .hero-content h1 {
        font-size: clamp(1.2rem, 4vw, 1.6rem);
    }

    .hero-content p {
        font-size: 0.85rem;
    }

    .hero .btn {
        padding: 0.5rem 1.5rem;
        font-size: 0.85rem;
    }

    .about-text {
        font-size: 1rem;
    }

    .contact p {
        font-size: 1.1rem;
        flex-direction: column;
        gap: 0.3rem;
    }

    .event-item .event-links a {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
}

/* Mobile Phones - 480px and down */
@media (max-width: 480px) {
    /* Navigation */
    nav {
        padding: 1rem;
    }

    .nav-menu {
        top: 70px;
    }

    .nav-menu li {
        margin: 0.8rem 0;
    }

    /* Contact Form Mobile */
    .form-group input,
    .form-group textarea {
        padding: 0.8rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Hero */
    .hero {
        padding: 1.5rem 1rem 0.5rem;
        margin-top: 70px;
    }

    .hero-content h1 {
        margin-bottom: 0.3rem;
    }

    .hero-content p {
        margin-bottom: 0.8rem;
    }

    /* Content */
    .about, .events, .contact {
        margin: 2rem 0.5rem 1.5rem;
        padding: 1.5rem 1rem;
    }

    .about h2, .events h2, .contact h2 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .about-text {
        font-size: 0.95rem;
        text-align: left;
    }

    .about-text p::before {
        display: none;
    }

    /* Events */
    .event-item {
        padding: 1rem;
    }

    .event-item h3 {
        font-size: 1rem;
        line-height: 1.4;
    }

    .event-item p {
        font-size: 0.9rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    .event-item strong {
        min-width: auto;
        margin-right: 0;
    }

    .event-banner {
        height: 150px;
    }

    /* Contact */
    .contact p {
        font-size: 1rem;
    }

    .contact .social-links a {
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }
}

/* Extra Small Mobile - 360px and down */
@media (max-width: 360px) {
    .hero .btn {
        padding: 0.7rem 1.5rem;
        font-size: 0.9rem;
    }

    .event-item .event-links a {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }

    .contact .social-links a {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }
}

/* Landscape orientation fixes */
@media (max-height: 600px) and (orientation: landscape) {
    .hero {
        padding: 3rem 1rem 2rem;
    }

    .nav-menu {
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .hero::before {
        opacity: 0.05;
    }
}

/* Dark mode support (if user prefers) */
@media (prefers-color-scheme: dark) {
    :root {
        --text-dark: #fff;
        --text-light: #ddd;
        --text-muted: #bbb;
        --bg-light: rgba(0, 0, 0, 0.8);
        
        /* ********** START แก้ไขจุดที่ 1: Dark Mode Form Variables ********** */
        --bg-form: #222; /* สีพื้นหลังฟอร์มที่เข้มขึ้น */
        --text-form: #fff; /* สีข้อความฟอร์มเป็นสีขาว */
        /* ********** END แก้ไขจุดที่ 1 ********** */
    }

    body {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    }

    /* ********** START แก้ไขจุดที่ 1: Search Input และ Select Filters ********** */
    .search-input,
    .filter-select {
        background: var(--bg-form); /* ใช้สีพื้นหลังฟอร์มใหม่ */
        color: var(--text-form); /* ใช้สีข้อความฟอร์มใหม่ */
        border-color: #555; /* ปรับสีขอบให้มองเห็นได้ */
    }

    .search-input::placeholder {
        color: #aaa; /* ปรับสี Placeholder ให้มองเห็นได้ */
    }
    
    .filter-select option {
        /* ตรวจสอบให้แน่ใจว่าตัวเลือกมีสีพื้นหลัง/ข้อความที่ถูกต้องใน Dropdown */
        background-color: var(--bg-form);
        color: var(--text-form);
    }
    /* ********** END แก้ไขจุดที่ 1 ********** */
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles */
@media print {
    nav, footer, .hamburger, .lang-switcher {
        display: none;
    }

    .hero {
        margin-top: 0;
        padding: 2rem 0;
    }

    body {
        background: white;
        color: black;
        padding-bottom: 0;
    }

    .about, .events, .contact {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }

    .event-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* Breadcrumb Navigation */
.breadcrumb-nav {
    padding: 10px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.breadcrumb {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 8px;
    font-size: 0.9rem;
}

.breadcrumb li {
    color: #666;
}

.breadcrumb li a {
    color: #1a73e8;
    text-decoration: none;
}

.breadcrumb li a:hover {
    text-decoration: underline;
}

.breadcrumb li + li::before {
    content: "›";
    margin-right: 8px;
    color: #999;
}