/*
Theme Name: Flatsome Child
Theme URI: http://flatsome.uxthemes.com/
Template: flatsome
Author: UX-Themes + CP Video System
Description: Flatsome Child with CP Video System
Version: 1.0.0
*/


/* =====================================================
   แบนเนอร์เหนือเครื่องเล่นวิดีโอ
===================================================== */
.cpv-video-top-banner {
    width: 100%;
    max-width: 970px;
    margin: 0 auto 20px;
    text-align: center;
    overflow: hidden;
    border-radius: 10px;
}

.cpv-video-top-banner a {
    display: block;
    width: 100%;
    text-decoration: none;
}

.cpv-video-top-banner img {
    display: block;
    width: 100%;
    max-width: 970px;
    height: auto;
    margin: 0 auto;
    border: 0;
    border-radius: 10px;
    object-fit: cover;
}

@media screen and (max-width: 767px) {
    .cpv-video-top-banner {
        margin-bottom: 15px;
        border-radius: 6px;
    }

    .cpv-video-top-banner img {
        border-radius: 6px;
    }
}

/* =====================================================
   FIX: ป้องกันเมนูและแบนเนอร์ทับกัน
===================================================== */

/* ให้ Header และเมนูคำนวณความสูงตามเนื้อหาจริง */
.cpv-header{
    position:relative !important;
    height:auto !important;
    min-height:0 !important;
    overflow:visible !important;
    z-index:20;
}

.cpv-header > .cpv-wrap:last-child{
    position:relative !important;
    display:block !important;
    height:auto !important;
    min-height:0 !important;
    overflow:visible !important;
    clear:both !important;
    z-index:21;
    padding-bottom:18px !important;
}

/* เมนูหลายแถวต้องอยู่ใน flow ปกติ */
.cpv-header > .cpv-wrap:last-child ul,
.cpv-header .cpv-nav,
.cpv-header nav ul{
    position:relative !important;
    display:flex !important;
    flex-wrap:wrap !important;
    height:auto !important;
    overflow:visible !important;
    margin-bottom:0 !important;
}

/* บังคับเนื้อหาหลักเริ่มหลัง Header */
.cpv-main{
    position:relative !important;
    clear:both !important;
    z-index:1;
    padding-top:28px !important;
}

/* แบนเนอร์ทั่วไปต้องไม่ลอยขึ้นไปทับเมนู */
.dev888-ad-header,
.dev888-ad-header_grid,
.dev888-header-grid-inner,
.cpv-video-top-banner,
.cpv-main > .dev888-ad{
    position:relative !important;
    clear:both !important;
    top:auto !important;
    bottom:auto !important;
    left:auto !important;
    right:auto !important;
    transform:none !important;
    margin-top:0 !important;
    margin-bottom:28px !important;
    z-index:1 !important;
}

/* ถ้าเป็น Bottom Floating ให้เริ่มต่ำลงและไม่ทับ Header */
.dev888-bottom-floating{
    z-index:999 !important;
}

/* Desktop */
@media screen and (min-width:768px){
    .cpv-header > .cpv-wrap:last-child{
        padding-bottom:20px !important;
    }

    .cpv-main{
        padding-top:32px !important;
    }
}

/* Mobile */
@media screen and (max-width:767px){
    .cpv-header > .cpv-wrap:last-child{
        padding-bottom:20px !important;
    }

    .cpv-main{
        padding-top:20px !important;
    }

    .dev888-ad-header,
    .dev888-ad-header_grid,
    .dev888-header-grid-inner,
    .cpv-video-top-banner{
        width:calc(100% - 20px) !important;
        max-width:100% !important;
        margin-left:auto !important;
        margin-right:auto !important;
    }
}


/* =====================================================
   FINAL MOBILE FIX: โลโก้บน / ช่องค้นหาล่าง
===================================================== */
@media screen and (max-width: 767px){

    .cpv-header .cpv-header-inner{
        display:flex !important;
        flex-direction:column !important;
        align-items:stretch !important;
        justify-content:flex-start !important;
        width:100% !important;
        gap:18px !important;
        padding:24px 16px !important;
    }

    .cpv-header .cpv-logo-wrap{
        display:flex !important;
        order:1 !important;
        width:100% !important;
        flex:0 0 auto !important;
        justify-content:center !important;
        align-items:center !important;
        text-align:center !important;
        margin:0 !important;
    }

    .cpv-header .cpv-logo-link{
        display:block !important;
        width:auto !important;
        margin:0 auto !important;
    }

    .cpv-header .cpv-logo-image{
        display:block !important;
        width:auto !important;
        max-width:min(85vw, 300px) !important;
        max-height:190px !important;
        height:auto !important;
        margin:0 auto !important;
    }

    .cpv-header form.cpv-search{
        display:flex !important;
        order:2 !important;
        width:100% !important;
        max-width:100% !important;
        flex:0 0 auto !important;
        margin:0 !important;
        padding:0 !important;
    }

    .cpv-header form.cpv-search input[type="text"]{
        display:block !important;
        flex:1 1 auto !important;
        width:1% !important;
        min-width:0 !important;
        height:48px !important;
        margin:0 !important;
        padding:0 15px !important;
        border-radius:7px 0 0 7px !important;
    }

    .cpv-header form.cpv-search button{
        display:flex !important;
        flex:0 0 64px !important;
        width:64px !important;
        min-width:64px !important;
        height:48px !important;
        margin:0 !important;
        padding:0 !important;
        align-items:center !important;
        justify-content:center !important;
        border-radius:0 7px 7px 0 !important;
        font-size:15px !important;
    }

    /* ปิด pseudo icon เดิม เพื่อให้ข้อความค้นหาไม่เพี้ยน */
    .cpv-header form.cpv-search button::before,
    .cpv-header form.cpv-search button::after{
        content:none !important;
        display:none !important;
    }
}