/* style.css */

/* --- Universal Box-Sizing and Basic Body Resets --- */
* {
    box-sizing: border-box; /* Crucial for consistent element sizing */
    margin: 0;
    padding: 0;
}

/* Body styles are now defined globally here */
body {
    font-family: 'Netflix Sans', Arial, sans-serif; /* Fallback to Arial if Netflix Sans is not loaded */
    background-color: #141414; /* Main Netflix dark background */
    color: #e5e5e5; /* Default text color */
    overflow-x: hidden; /* Prevent horizontal scrollbar on body */
    min-height: 100vh; /* Ensure body takes at least full viewport height */
    display: flex; /* Use flex for body to allow main content to grow */
    flex-direction: column; /* Stack children vertically */
}

/* --- Global Link and List Styles --- */
a {
    color: #e5e5e5; /* Default link color */
    text-decoration: none; /* Remove underline */
    transition: color 0.3s ease; /* Smooth color transition on hover */
}

a:hover {
    color: #fff; /* Lighter color on hover */
}

ul {
    list-style: none; /* Remove bullet points from lists */
    margin: 0;
    padding: 0;
}

/* --- Main Content Area Styles (Used in index.php, movie_detail.php, series.php, etc.) --- */
.content-area { /* Generic class for main content to push below header */
    padding-top: 100px; /* Adjust based on fixed header height */
    flex-grow: 1; /* Allow content area to expand vertically */
    padding-bottom: 50px; /* Space above footer */
}

/* Specific content rows on index.php */
.content-rows {
    padding: 30px 50px;
    position: relative;
    margin-top: -100px; /* Overlap with hero section */
    z-index: 10;
    flex-grow: 1; /* Allow content rows to take space */
}

.movie-category {
    margin-bottom: 40px;
}

.movie-category h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: #fff;
}

.movie-carousel {
    display: flex;
    overflow-x: scroll;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 15px;
    position: relative;
    /* Hide scrollbar */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.movie-carousel::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.movie-card {
    flex: 0 0 auto; /* Do not grow or shrink, keep base width */
    width: 250px; /* Base width for movie cards */
    margin-right: 10px;
    position: relative;
    cursor: pointer;
    border-radius: 5px;
    overflow: hidden;
    display: block; /* Ensure it behaves as a block for full click area */
    transition: transform 0.3s ease, z-index 0.3s ease, box-shadow 0.3s ease;
}

.movie-card img {
    width: 100%;
    height: auto; /* Maintain aspect ratio */
    object-fit: cover; /* Cover the area, crop if needed */
    aspect-ratio: 2/3; /* Standard poster aspect ratio */
    border-radius: 5px;
    display: block; /* Remove extra space below image */
    transition: transform 0.3s ease;
    background-color: #333; /* Placeholder background for missing images */
}

.movie-card:hover {
    transform: scale(1.1); /* Slightly enlarge on hover */
    z-index: 50; /* Bring to front on hover */
    box-shadow: 0 0 15px rgba(0,0,0,0.7);
}

.movie-card:hover img {
    transform: scale(1.05); /* Enlarge image slightly within card */
}

.movie-card .movie-info { /* Nested movie-info within movie-card */
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.8);
    padding: 10px;
    transform: translateY(100%); /* Start hidden below the card */
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important; /* Will be set to 0 initially by transform, then 1 on hover */
}

.movie-card:hover .movie-info {
    transform: translateY(0); /* Slide up on hover */
    opacity: 1; /* Fully visible on hover */
}

.movie-card .movie-info h3 {
    font-size: 1.1rem;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff; /* Ensure title is white */
}

.movie-card .movie-info p {
    font-size: 0.9rem;
    color: #ccc; /* Lighter gray for description */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* Netflix Footer Styles are in footer.php */

/* --- Responsive Adjustments (General) --- */
@media (max-width: 1200px) {
    .netflix-header,
    .content-rows {
        padding-left: 30px;
        padding-right: 30px;
    }
}

@media (max-width: 768px) {
    .content-rows {
        padding: 20px;
        margin-top: -50px; /* Adjust overlap for mobile */
    }
    .movie-category h2 {
        font-size: 1.5rem;
    }
    .movie-card {
        width: 180px; /* Adjust width for mobile cards */
    }
    .netflix-footer {
        padding: 30px 20px;
    }
    .netflix-footer .footer-links ul {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .movie-card {
        width: 150px; /* Further adjust width for very small screens */
    }
    .netflix-footer .footer-links ul {
        grid-template-columns: 1fr;
    }
}

/* --- FOOTER STYLES --- */
.netflix-footer {
    background-color: #000; /* พื้นหลังสีดำสนิท */
    color: #808080; /* สีเทาอ่อนสำหรับข้อความ */
    padding: 40px 50px;
    margin-top: 50px; /* ระยะห่างจากเนื้อหาด้านบน */
    font-size: 0.9em;
    flex-shrink: 0; /* ป้องกันไม่ให้ footer ย่อขนาดเมื่อเนื้อหามีน้อย */
}

.netflix-footer .footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.netflix-footer .footer-links {
    margin-bottom: 30px;
}

.netflix-footer .footer-links ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap; /* ให้ลิงก์ขึ้นบรรทัดใหม่ได้ */
    justify-content: center;
    gap: 15px 20px; /* ระยะห่างระหว่างลิงก์ */
}

.netflix-footer .footer-links a {
    color: #808080;
    text-decoration: none;
    transition: color 0.3s ease;
}

.netflix-footer .footer-links a:hover {
    color: #e5e5e5; /* สีเทาอ่อนขึ้นเมื่อ hover */
}

.netflix-footer .footer-social {
    margin-bottom: 30px;
}

.netflix-footer .footer-social a {
    color: #fff; /* ไอคอนโซเชียลสีขาว */
    font-size: 1.5em;
    margin: 0 10px;
    text-decoration: none;
    transition: color 0.3s ease;
}

.netflix-footer .footer-social a:hover {
    color: #e50914; /* สีแดง Netflix เมื่อ hover */
}

.netflix-footer .footer-copyright p {
    margin: 5px 0;
    line-height: 1.5;
}

/* Responsive adjustments for footer */
@media (max-width: 768px) {
    .netflix-footer {
        padding: 30px 20px;
    }
    .netflix-footer .footer-links ul {
        flex-direction: column; /* ลิงก์เรียงเป็นคอลัมน์ในมือถือ */
        align-items: center;
    }
    .netflix-footer .footer-links li {
        width: 100%; /* ให้ลิงก์เต็มความกว้าง */
    }
}

/* ปรับ Body ให้เนื้อหาหลักอยู่ระหว่าง Header และ Footer */
/* ควรอยู่ใน style.css หรือใน <style> ของ header.php */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
/* เพิ่ม main เพื่อให้เนื้อหาหลักดัน footer ลงไป */
main {
    flex: 1; /* ทำให้ main ขยายเต็มที่เพื่อดัน footer ไปด้านล่าง */
    padding-top: 80px; /* ปรับให้เนื้อหาหลักหลบ header fixed */
}
/* --- NEW: Ad specific CSS --- */
/* Basic styling for all ad containers */
.ad-container {
    margin: 20px auto; /* จัดกลางพร้อมระยะห่างแนวตั้ง */
    max-width: 900px; /* ความกว้างสูงสุดสำหรับแบนเนอร์ทั่วไป */
    text-align: center;
    background-color: #1a1a1a; /* พื้นหลังสีดำสำหรับโฆษณา */
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
    overflow: hidden; /* ซ่อนเนื้อหาที่เกินขอบ */
    position: relative; /* สำหรับตำแหน่งปุ่มปิด */
    pointer-events: auto; /* รับ Event ได้ตามปกติ */
    visibility: visible; /* มองเห็นได้ตามปกติ */
    transition: all 0.3s ease-out; /* สำหรับการเปลี่ยนแปลงคุณสมบัติอื่น ๆ */
}
.ad-container img, .ad-container video {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}
.ad-container p {
    margin-top: 10px;
    color: #ccc;
    font-size: 0.9em;
}

/* 1. Specific styles for homepage_top_fixed_banner */
.ad-location-homepage_top_fixed_banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-width: 100vw;
    z-index: 1001 !important; /* เพิ่ม !important ให้ z-index สูงสุด */
    background-color: rgba(0,0,0,0.95) !important; /* เพิ่ม !important ให้ background-color ด้วย */
    padding: 10px 20px;
    box-sizing: border-box;
    text-align: center;
    border-bottom: 1px solid #333;
    display: block; /* เริ่มต้นแสดงผลเป็น block */
    pointer-events: auto; /* รับ Event ได้เมื่อแสดง */
    visibility: visible; /* มองเห็นได้เมื่อแสดง */
    transition: all 0.3s ease-out; /* เพื่อให้ซ่อน/แสดงผลมี transition สวยงาม */
}

/* Style for the close button */
.ad-close-button {
    position: absolute;
    top: 5px;
    right: 10px;
    font-size: 1.5em;
    color: #fff;
    background: transparent;
    border: none;
    cursor: pointer;
    line-height: 1;
    padding: 0 5px;
    z-index: 1002 !important; /* ให้ปุ่มอยู่บนโฆษณาเสมอ (และสูงกว่าตัวโฆษณา) */
    opacity: 0.7;
    transition: opacity 0.3s ease;
    pointer-events: auto; /* สำคัญ: ปุ่มต้องคลิกได้เสมอ */
}
.ad-close-button:hover {
    opacity: 1;
    color: #e50914;
}

/* Class to hide the ad container - ใช้ display: none!important เพื่อซ่อนแบบเด็ดขาด */
.ad-hidden {
    display: none !important; /* <--- นี่คือคุณสมบัติสำคัญที่สุดที่ต้องทำงาน */
    /* เมื่อใช้ display: none จะทำให้องค์ประกอบถูกลบออกจาก Document Flow และไม่กินพื้นที่ */
    /* ดังนั้น คุณสมบัติที่เกี่ยวข้องกับการซ่อนแบบ transform/opacity/height/padding จะไม่จำเป็น */
    /* หรืออาจจะทำให้เกิดความขัดแย้งได้ถ้ามี transition ที่ยาวกว่า */

    /* คุณสามารถลบคุณสมบัติเหล่านี้ออกได้เมื่อใช้ display: none!important; */
    /* transform: translateY(-100%) !important; */
    /* opacity: 0 !important; */
    /* pointer-events: none !important; */
    /* height: 0 !important; */
    /* padding-top: 0 !important; */
    /* padding-bottom: 0 !important; */
    /* border-bottom: none !important; */
    /* visibility: hidden !important; */
}

/* Adjust body padding-top dynamically with JavaScript to prevent content hiding */
body {
    padding-top: var(--homepage-fixed-banner-height, 0px);
}

/* --- NEW: Ad specific CSS --- */
/* ... (โค้ด CSS ส่วนบนของคุณ) ... */

/* Specific styles for fixed bottom right ad */
.ad-location-fixed_bottom_right {
    position: fixed !important; /* บังคับให้เป็น fixed */
    bottom: 20px !important;    /* บังคับตำแหน่งขอบล่าง */
    right: 20px !important;     /* บังคับตำแหน่งขอบขวา */
    z-index: 9999 !important;   /* บังคับ z-index ให้สูงมาก (สูงกว่า Modal แต่ไม่สูงเท่า Overlay) */
    max-width: 300px;
    background-color: rgba(0,0,0,0.85);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.6);
    /* ตรวจสอบว่าไม่มี transform หรือ filter ใน parent ที่มาขัดขวาง fixed position */
}

/* ... (โค้ด CSS ส่วนล่างของคุณ) ... */