/* ==========================================================================
   1. VARIABLES, RESET & ACCESSIBILITY
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;600;700&family=IBM+Plex+Sans+Thai:wght@300;400;600;700&display=swap');

:root {
    --at-red: #ED2939; 
    --at-white: #FFFFFF;
    --at-light-gray: #F8F9FA;
    --at-dark: #333333;
    --at-text: #4A4A4A;
    --at-text-light: #6c757d;
    --shadow: 0 4px 15px rgba(0,0,0,0.1);
    --font-primary: 'Prompt', 'IBM Plex Sans Thai', sans-serif;
}

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

html, body {
    max-width: 100%;
    overflow-x: hidden; /* ป้องกันการเลื่อนซ้าย-ขวาในระดับราก */
}

body {
    font-family: var(--font-primary);
    color: var(--at-text);
    margin: 0;
    line-height: 1.6;
    background-color: #fdfdfd;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   2. COMMON CLASSES
   ========================================================================== */
.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 20px; 
    width: 100%;
}


h1, h2, h3, h4 { font-weight: 700; color: #1E293B; margin-top: 0; }
.section-padding { padding: 60px 0; }
.section-title { text-align: center; font-size: 2.2rem; margin-bottom: 40px; } 


/* ==========================================================================
   3. HEADER & NAVIGATION (Desktop & Mobile Unified)
   ========================================================================== */
header {
    background: var(--at-white);
    border-bottom: 3px solid var(--at-red);
    padding: 0.8rem 0;
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 9999;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

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

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--at-red);
    text-decoration: none;
    white-space: nowrap;
}
.logo span { color: var(--at-dark); }

/* Desktop Navigation */
nav ul {
    list-style: none;
    display: flex;
    gap: 15px;
    margin: 0;
    padding: 0;
    align-items: center;
}

nav a {
    text-decoration: none;
    color: var(--at-dark);
    font-weight: 400;
    padding: 8px 12px;
    transition: 0.3s;
}
nav a:hover { color: var(--at-red); }

/* Language Selectors */
.lang-container {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
}
.lang-link { text-decoration: none; color: var(--at-text); }
.lang-link.active { color: var(--at-red); font-weight: 600; }
.divider { color: #ccc; padding: 0 2px; }

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}
.menu-toggle .bar { width: 30px; height: 3px; background: var(--at-dark); transition: 0.3s; }

/* ==========================================================================
   4. HERO & BENTO GRID
   ========================================================================== */
.hero {
    background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('your-image-path.jpg');
    background-size: cover;
    background-position: center;
    color: white;
    padding: 80px 20px;
    text-align: center;
    min-height: 350px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.hero h1 { font-size: 3rem; color: white; margin-bottom: 20px; }

.hero-btns { display: flex; justify-content: center; gap: 15px; }
.btn-at {
    padding: 12px 25px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: 0.3s;
}
.btn-red { background: var(--at-red); color: white !important; border: 2px solid var(--at-red); }
.btn-red:hover { background: transparent; color: white !important; }

/* Bento Grid */
.bento-grid {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 250px);
    margin: 40px 0;
}
.bento-item { 
    position: relative; 
    border-radius: 12px; 
    overflow: hidden; 
    background-size: cover; 
    background-position: center;
    text-decoration: none;
}
.bento-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    padding: 20px; color: white;
}

/* ==========================================================================
   5. FILTER BAR
   ========================================================================== */
.filter-bar {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 30px 0;
}
.btn-filter {
    padding: 8px 20px;
    border-radius: 50px;
    border: 1.5px solid var(--at-red);
    color: var(--at-red);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: 0.3s;
}
.btn-filter:hover, .btn-filter.active { background: var(--at-red); color: white !important; }

/* ==========================================================================
   6. CARDS & GRID
   ========================================================================== */
.article-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); 
    gap: 25px; 
}

.card { 
    background: white; 
    border-radius: 12px; 
    overflow: hidden; 
    box-shadow: var(--shadow); 
    transition: 0.3s; 
    position: relative; /* สำคัญ: เพื่อให้ Badge อิงตำแหน่งกับตัว Card */
}

.card:hover { transform: translateY(-5px); }

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

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

/* เติมส่วนที่หายไปตรงนี้ครับ */
.card-badge { 
    position: absolute; 
    top: 15px; 
    left: 15px; 
    background: var(--at-red); 
    color: white !important; 
    padding: 5px 15px; 
    border-radius: 50px; 
    font-size: 0.75rem; 
    font-weight: 600; 
    z-index: 10; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.card-body { padding: 20px; }

/* ==========================================================================
   7. PLANNER BOX (Form)
   ========================================================================== */
.planner-box {
    background: #fff;
    padding: 2.5rem;
    border-radius: 15px;
    border-left: 10px solid var(--at-red);
    box-shadow: var(--shadow);
    margin: 40px 0;
}
.form-grid { display: flex; gap: 15px; align-items: flex-end; }
.input-group { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.planner-box input {
    height: 50px;
    padding: 0 15px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    width: 100%;
}

/* ==========================================================================
   8. FOOTER & COOKIE
   ========================================================================== */
footer { background: var(--at-dark); color: white; padding: 60px 0 30px; }
footer h4 { color: white; margin-bottom: 20px; }
footer a { color: rgba(255,255,255,0.8); text-decoration: none; }

.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #ffffff;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    padding: 20px 0;
    display: none; /* จะแสดงผลเมื่อไม่มีค่าใน localStorage เท่านั้น */
    border-top: 3px solid var(--at-red);
}

.cookie-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
}

.cookie-text p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--at-text);
    line-height: 1.5;
}

.cookie-text a {
    color: var(--at-red);
    text-decoration: underline;
    font-weight: 600;
}

.cookie-buttons {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.cookie-btn {
    padding: 10px 22px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    white-space: nowrap;
}

.cookie-btn.accept {
    background-color: var(--at-red);
    color: white !important;
}

.cookie-btn.accept:hover {
    background-color: #c1121f;
    transform: translateY(-2px);
}

.cookie-btn.reject {
    background-color: #f1f5f9;
    color: #475569 !important;
}

.cookie-btn.reject:hover {
    background-color: #e2e8f0;
}

/* --- Cookie Mobile Responsive --- */
@media (max-width: 768px) {
    .cookie-banner {
        padding: 25px 0;
    }
    
    .cookie-content {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }
    
    .cookie-buttons {
        width: 100%;
        justify-content: center;
        gap: 10px;
    }
    
    .cookie-btn {
        flex: 1; /* ให้ปุ่มกางเท่ากันบนมือถือ */
        padding: 12px 15px;
    }
}

/* ==========================================================================
   9. MOBILE RESPONSIVE (Unified Fixes)
   ========================================================================== */
@media (max-width: 768px) {
    /* ป้องกันจอเลื่อนซ้ายขวาเด็ดขาด */
    .container { padding: 0 15px; }

    /* Header Mobile */
    .menu-toggle { display: flex; }
    .desktop-lang { display: none; }
    
    nav#main-nav {
        display: none;
        position: absolute;
        top: 100%; left: 0; width: 100%;
        background: white;
        flex-direction: column;
        box-shadow: 0 5px 10px rgba(0,0,0,0.1);
    }
    nav#main-nav.active { display: block; }
    nav ul { flex-direction: column; gap: 0; }
    nav ul li { width: 100%; border-bottom: 1px solid #eee; }
    nav ul li a { display: block; padding: 15px 20px; }
    
    .mobile-lang-item { display: block !important; padding: 15px; text-align: center; background: #f9f9f9; }

    /* Hero & Bento */
    .hero { padding: 40px 15px; min-height: 250px; }
    .hero h1 { font-size: 1.8rem; }
    .hero-btns { flex-direction: column; align-items: center; }
    .btn-at { width: 100%; max-width: 280px; }

    .bento-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    .bento-item { min-height: 200px; grid-column: span 1 !important; grid-row: span 1 !important; }

    /* Filter Bar Scrollable */
    .filter-bar {
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 10px 0;
        margin: 20px 0;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .filter-bar::-webkit-scrollbar { display: none; }
    .btn-filter { flex: 0 0 auto; }

    /* Planner Form Mobile */
    .form-grid { flex-direction: column; }
    .planner-box { padding: 1.5rem; border-left-width: 5px; }
    
    /* Cookie Mobile */
    .cookie-content { flex-direction: column; text-align: center; gap: 15px; }
}