/* ==========================================================================
   THÁI DƯƠNG ANH - MODERN RESPONSIVE & MOBILE UX ENHANCEMENT ENGINE v2.0
   ========================================================================== */

/* 1. Global Box Sizing & Fluid Container */
*, *:before, *:after {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    font-size: 15px;
    line-height: 1.6;
}

img, video, iframe, embed, object {
    max-width: 100% !important;
    height: auto !important;
}

#wrapper {
    width: 100% !important;
    max-width: 1000px !important;
    margin: 0 auto !important;
    padding: 0 10px !important;
    background: #fff;
}

/* 2. Responsive Header & Branding */
#header {
    width: 100% !important;
    height: auto !important;
}

#branding {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
}

#branding .logo {
    flex: 1 1 auto;
    min-width: 250px;
}

#branding .logo .blog-name a {
    font-size: 26px;
    font-weight: 700;
    color: #c90000;
    text-decoration: none;
}

#branding div[align="center"] {
    flex: 0 1 auto;
    padding: 5px 0 !important;
}

#branding img {
    max-height: 80px;
    width: auto;
}

/* 3. Navigation Bar & Responsive Menu */
.mobile-nav-toggle {
    display: none;
    width: 100%;
    background: #c90000;
    color: #fff;
    padding: 12px 16px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-align: left;
    margin-bottom: 8px;
}

.mobile-nav-toggle:after {
    content: " ☰";
    float: right;
    font-size: 18px;
}

.mobile-nav-toggle.active:after {
    content: " ✕";
}

/* 4. Desktop & Tablet 2-Column Grid Layout (> 768px) */
@media screen and (min-width: 769px) {
    #main {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 300px !important;
        grid-template-rows: auto 1fr;
        grid-template-areas: 
            "content primary"
            "content secondary" !important;
        column-gap: 20px !important;
        row-gap: 15px !important;
        width: 100% !important;
        max-width: 1000px !important;
        margin: 0 auto !important;
    }

    #container {
        grid-area: content !important;
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
        margin: 0 !important;
    }

    #content {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
        margin: 0 !important;
    }

    #primary {
        grid-area: primary !important;
        width: 300px !important;
        float: none !important;
        margin: 0 !important;
    }

    #secondary {
        grid-area: secondary !important;
        width: 300px !important;
        float: none !important;
        margin: 0 !important;
    }

    .main-aside {
        width: 300px !important;
        float: none !important;
    }

    .main-aside .widgetcontainer {
        margin-bottom: 20px;
    }

    .main-aside img {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* 5. Mobile Single Column Layout (<= 768px) */
@media screen and (max-width: 768px) {
    .mobile-nav-toggle {
        display: block;
    }

    #nav {
        background: transparent !important;
        height: auto !important;
    }

    #nav #nav-content {
        display: none;
        background: #222;
        border-radius: 6px;
        padding: 10px 0;
        margin-bottom: 15px;
    }

    #nav #nav-content.mobile-open {
        display: block !important;
    }

    #nav ul.sf-menu {
        float: none !important;
        width: 100% !important;
        display: block !important;
    }

    #nav ul.sf-menu > li {
        float: none !important;
        width: 100% !important;
        border-bottom: 1px solid #333;
    }

    #nav ul.sf-menu > li > a {
        display: block !important;
        padding: 12px 16px !important;
        color: #fff !important;
        font-size: 15px !important;
        font-weight: 600 !important;
    }

    #nav ul.sf-menu ul.sub-menu {
        position: static !important;
        display: block !important;
        width: 100% !important;
        background: #333 !important;
        box-shadow: none !important;
        padding-left: 15px !important;
    }

    #nav ul.sf-menu ul.sub-menu li a {
        padding: 10px 16px !important;
        color: #ddd !important;
        font-size: 14px !important;
        border-bottom: 1px solid #444 !important;
    }

    #nav .quick-nav {
        display: none !important;
    }

    /* Main Container & Sidebars Stacking */
    #main {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        margin: 0 !important;
    }

    #container {
        width: 100% !important;
        float: none !important;
        order: 1 !important;
        margin: 0 0 20px 0 !important;
    }

    #content {
        width: 100% !important;
        padding: 0 !important;
    }

    #primary {
        width: 100% !important;
        float: none !important;
        order: 2 !important;
        margin: 0 0 20px 0 !important;
    }

    #secondary {
        width: 100% !important;
        float: none !important;
        order: 3 !important;
        margin: 0 0 20px 0 !important;
    }

    .main-aside {
        width: 100% !important;
        float: none !important;
    }

    /* Slideshow */
    #featured-slideshow {
        height: auto !important;
        min-height: 220px !important;
    }

    .featured-slideshow-inner img {
        width: 100% !important;
        height: auto !important;
        min-height: 180px !important;
        object-fit: cover !important;
    }

    .featured-entry {
        position: relative !important;
        bottom: 0 !important;
        background: rgba(0,0,0,0.85) !important;
        padding: 10px !important;
        width: 100% !important;
    }

    /* Post Content Images */
    .entry-content {
        font-size: 15px !important;
        line-height: 1.7 !important;
        word-wrap: break-word !important;
    }

    .entry-content p {
        margin-bottom: 16px !important;
    }

    .entry-content img {
        display: block !important;
        margin: 12px auto !important;
        border-radius: 6px !important;
    }

    /* Tables scrollable */
    .entry-content table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
    }
}

/* 6. PERFECT FLEX GRID FOR .posts-default (SỰ KIỆN NỔI BẬT & CHUYÊN MỤC) */
.posts-default,
#index-featured1 .posts-default,
#index-featured2 .posts-default,
#index-featured3 .posts-default,
ul.posts-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 15px !important;
    width: 100% !important;
    margin: 0 0 25px 0 !important;
    padding: 0 !important;
}

.posts-default > div.clearfix,
.posts-default > div,
.posts-default > ul {
    display: contents !important;
}

.posts-default .entry,
#index-featured1 .posts-default .entry,
#index-featured2 .posts-default .entry,
#index-featured3 .posts-default .entry,
ul.posts-grid li {
    flex: 0 0 calc((100% - 30px) / 3) !important;
    width: calc((100% - 30px) / 3) !important;
    max-width: calc((100% - 30px) / 3) !important;
    margin: 0 !important;
    float: none !important;
    clear: none !important;
    background: #fff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 6px !important;
    padding: 8px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05) !important;
    box-sizing: border-box !important;
}

.posts-default .entry-thumbnails,
#index-featured1 .posts-default .entry-thumbnails {
    width: 100% !important;
    height: 120px !important;
    margin: 0 0 6px 0 !important;
    position: relative !important;
    overflow: hidden !important;
    border-radius: 4px !important;
}

.posts-default .entry-thumbnails-link {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

.posts-default .entry-thumbnails img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

.posts-default .entry-title {
    font-size: 14px !important;
    font-weight: 700 !important;
    margin: 4px 0 0 0 !important;
    line-height: 1.4 !important;
}

.posts-default .entry-title a {
    color: #0b519c !important;
    text-decoration: none !important;
}

.posts-default .entry-title a:hover {
    color: #c90000 !important;
}

/* Tablet view (2 columns dàn đều 100% không để lại khoảng trống) */
@media screen and (max-width: 900px) and (min-width: 521px) {
    .posts-default .entry,
    #index-featured1 .posts-default .entry,
    #index-featured2 .posts-default .entry,
    #index-featured3 .posts-default .entry,
    ul.posts-grid li {
        flex: 0 0 calc((100% - 15px) / 2) !important;
        width: calc((100% - 15px) / 2) !important;
        max-width: calc((100% - 15px) / 2) !important;
    }
}

/* Mobile view (2 columns hoặc 1 column) */
@media screen and (max-width: 520px) {
    .posts-default,
    #index-featured1 .posts-default,
    #index-featured2 .posts-default,
    #index-featured3 .posts-default,
    ul.posts-grid {
        gap: 10px !important;
    }
    .posts-default .entry,
    #index-featured1 .posts-default .entry,
    #index-featured2 .posts-default .entry,
    #index-featured3 .posts-default .entry,
    ul.posts-grid li {
        flex: 0 0 calc((100% - 10px) / 2) !important;
        width: calc((100% - 10px) / 2) !important;
        max-width: calc((100% - 10px) / 2) !important;
        padding: 6px !important;
    }
    .posts-default .entry-thumbnails {
        height: 95px !important;
    }
    .posts-default .entry-title {
        font-size: 13px !important;
    }
}

@media screen and (max-width: 360px) {
    .posts-default .entry,
    #index-featured1 .posts-default .entry,
    #index-featured2 .posts-default .entry,
    #index-featured3 .posts-default .entry,
    ul.posts-grid li {
        flex: 0 0 100% !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* 7. Floating Mobile Contact Bar (Sticky Call / Zalo / Facebook CTA) */
.mobile-bottom-bar {
    display: none;
}

@media screen and (max-width: 768px) {
    body {
        padding-bottom: 60px !important;
    }

    .mobile-bottom-bar {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 54px !important;
        background: #ffffff !important;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.15) !important;
        z-index: 99999 !important;
        border-top: 2px solid #c90000 !important;
    }

    .mobile-bottom-btn {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-decoration: none !important;
        color: #333 !important;
        font-size: 11px !important;
        font-weight: 600 !important;
        border-right: 1px solid #eee !important;
        padding: 4px 0 !important;
    }

    .mobile-bottom-btn:last-child {
        border-right: none !important;
    }

    .mobile-bottom-btn.btn-call {
        background: #c90000 !important;
        color: #fff !important;
    }

    .mobile-bottom-btn.btn-zalo {
        background: #0088cc !important;
        color: #fff !important;
    }

    .mobile-bottom-btn.btn-fb {
        background: #1877f2 !important;
        color: #fff !important;
    }

    .mobile-bottom-icon {
        font-size: 16px !important;
        margin-bottom: 2px !important;
    }
}
