/**
 * Mobile Responsive Fix
 * Fix layout issues on mobile and tablet devices
 * 
 * @package ATH_ATRAHI_DESIGN
 * @version 1.1
 */

/* ==========================================================================
   GLOBAL MOBILE FIXES
   ========================================================================== */

/* Prevent horizontal overflow */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

* {
    box-sizing: border-box;
}

/* Container fixes for mobile */
.container,
.wrapper,
main,
article,
section {
    max-width: 100%;
    overflow-x: hidden;
}

/* Images should never overflow */
img {
    max-width: 100%;
    height: auto;
}

/* ==========================================================================
   SINGLE POST - CONTENT WIDTH (DESKTOP)
   Bài viết nên rộng hơn, responsive theo màn hình
   ========================================================================== */

/* Single Post - Wider content on desktop */
body.single-post .container,
body.single .container,
.single-post-page .container {
    max-width: 95% !important;
    width: 95% !important;
}

body.single-post .post-content-wrapper .container,
body.single .post-content-wrapper .container,
.single-post-page .post-content-wrapper .container {
    max-width: 100% !important;
    width: 100% !important;
}

body.single-post .post-layout,
body.single .post-layout,
.single-post-page .post-layout {
    max-width: 100% !important;
}

body.single-post .post-main-content,
body.single .post-main-content,
.single-post-page .post-main-content {
    max-width: 100% !important;
    width: 100% !important;
}

body.single-post .entry-content,
body.single .entry-content,
.single-post-page .entry-content {
    max-width: 100% !important;
}

/* Single Post Header - Full width */
body.single-post .post-header .container,
body.single .post-header .container {
    max-width: 1200px !important;
}

/* ==========================================================================
   OTHER PAGES - FIXED WIDTH (DESKTOP)
   Các trang khác giữ kích thước cố định
   ========================================================================== */

/* Pages, Archives, etc - Keep fixed width */
body:not(.single-post):not(.single) .container {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}

/* Service pages, About, Contact - Fixed width */
body.page .container,
body.archive .container,
body.home .container {
    max-width: 1280px;
    width: 100%;
}

/* ==========================================================================
   LARGE DESKTOP (min-width: 1400px)
   ========================================================================== */

@media (min-width: 1400px) {
    /* Single post even wider on large screens */
    body.single-post .post-content-wrapper .container,
    body.single .post-content-wrapper .container {
        max-width: 1600px !important;
        width: 90% !important;
    }
    
    body.single-post .post-layout,
    body.single .post-layout {
        gap: 80px;
    }
}

/* ==========================================================================
   DESKTOP (min-width: 1200px)
   ========================================================================== */

@media (min-width: 1200px) {
    body.single-post .entry-content,
    body.single .entry-content {
        font-size: 18px;
        line-height: 1.9;
    }
}

/* Tables responsive */
table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Pre and code blocks */
pre, code {
    max-width: 100%;
    overflow-x: auto;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* iframes and embeds */
iframe, embed, object, video {
    max-width: 100%;
}

/* ==========================================================================
   SINGLE POST - MOBILE FIXES
   ========================================================================== */

/* TOC Container - Mobile */
.toc-container {
    max-width: 100%;
    overflow: hidden;
}

.toc-list {
    max-width: 100%;
    word-wrap: break-word;
}

.toc-list a {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Entry Content - Mobile */
.entry-content {
    max-width: 100%;
    overflow-x: hidden;
    word-wrap: break-word;
}

.entry-content p,
.entry-content li,
.entry-content span {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.entry-content img {
    max-width: 100% !important;
    height: auto !important;
}

/* Caption shortcode fix */
.wp-caption {
    max-width: 100% !important;
    width: auto !important;
}

.wp-caption img {
    max-width: 100%;
    height: auto;
}

.wp-caption-text {
    font-size: 14px;
    color: #666;
    text-align: center;
    padding: 10px 0;
}

/* ==========================================================================
   TABLET RESPONSIVE (max-width: 1024px)
   ========================================================================== */

@media (max-width: 1024px) {
    /* ALL PAGES - Wider on tablet */
    .container {
        max-width: 100% !important;
        width: 100% !important;
        padding-left: 24px !important;
        padding-right: 24px !important;
    }
    
    /* Post layout - single column */
    .post-layout {
        grid-template-columns: 1fr !important;
        gap: 30px !important;
    }
    
    .post-sidebar {
        display: none;
    }
    
    .post-main-content {
        max-width: 100%;
    }
}

/* ==========================================================================
   MOBILE RESPONSIVE (max-width: 768px)
   ALL PAGES FULL WIDTH
   ========================================================================== */

@media (max-width: 768px) {
    /* ALL CONTAINERS FULL WIDTH ON MOBILE */
    .container,
    body .container,
    body.single .container,
    body.single-post .container,
    body.page .container,
    body.archive .container,
    body.home .container,
    .post-content-wrapper .container,
    .post-header .container {
        max-width: 100% !important;
        width: 100% !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
    
    /* Entry content full width */
    .entry-content,
    .post-main-content,
    .post-layout {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* Post Header */
    .post-header {
        padding: 100px 0 30px;
    }
    
    .post-single-title {
        font-size: 24px !important;
        line-height: 1.3;
    }
    
    .post-meta-single {
        flex-direction: column;
        gap: 8px;
    }
    
    .meta-separator {
        display: none;
    }
    
    /* TOC Container - Mobile */
    .toc-container {
        padding: 16px;
        margin: 20px 0;
    }
    
    .toc-title {
        font-size: 16px;
        padding-bottom: 12px;
        margin-bottom: 15px;
    }
    
    .toc-list li {
        padding-left: 16px;
        margin-bottom: 8px;
    }
    
    .toc-list a {
        font-size: 13px;
        line-height: 1.5;
    }
    
    /* Entry Content */
    .entry-content {
        font-size: 15px;
        line-height: 1.7;
    }
    
    .entry-content h2 {
        font-size: 22px !important;
        margin-top: 30px;
    }
    
    .entry-content h3 {
        font-size: 18px !important;
        margin-top: 25px;
    }
    
    .entry-content h4 {
        font-size: 16px !important;
    }
    
    .entry-content ul,
    .entry-content ol {
        padding-left: 20px;
    }
    
    .entry-content blockquote {
        padding: 15px 20px;
        margin: 20px 0;
    }
    
    /* Featured Image */
    .post-featured-image {
        margin-bottom: 30px;
    }
    
    .post-featured-image .featured-img {
        border-radius: 12px;
    }
    
    /* Author Box */
    .author-box {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    
    .author-avatar {
        margin-bottom: 15px;
    }
    
    /* Post Navigation */
    .post-navigation {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .nav-prev,
    .nav-next {
        padding: 15px;
    }
    
    .nav-title {
        font-size: 14px;
    }
    
    /* Related Posts */
    .related-posts-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Tags */
    .post-tags {
        flex-wrap: wrap;
    }
    
    .tags-list {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .tag-link {
        font-size: 13px;
        padding: 5px 12px;
    }
    
    /* Share buttons */
    .post-share {
        flex-direction: column;
        gap: 10px;
    }
    
    .share-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ==========================================================================
   SMALL MOBILE (max-width: 480px)
   ========================================================================== */

@media (max-width: 480px) {
    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    
    .post-header {
        padding: 90px 0 20px;
    }
    
    .post-single-title {
        font-size: 20px !important;
    }
    
    .toc-container {
        padding: 12px;
    }
    
    .toc-title {
        font-size: 14px;
    }
    
    .toc-list a {
        font-size: 12px;
    }
    
    .entry-content {
        font-size: 14px;
    }
    
    .entry-content h2 {
        font-size: 18px !important;
    }
    
    .entry-content h3 {
        font-size: 16px !important;
    }
    
    /* Hide sidebar widgets completely */
    .sidebar-widget,
    .post-sidebar {
        display: none !important;
    }
}

/* ==========================================================================
   PRODUCT PAGES - MOBILE FIXES  
   ========================================================================== */

@media (max-width: 768px) {
    /* Product Landing Page */
    .product-landing-page .container {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
    
    .product-hero-title {
        font-size: 24px !important;
        line-height: 1.3;
    }
    
    .product-hero-section {
        padding: 30px 0 20px;
    }
    
    /* Info Cards */
    .info-cards-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }
    
    .info-card {
        padding: 16px;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    
    /* Gallery */
    .image-gallery,
    .masonry-gallery {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .gallery-item img {
        height: 120px !important;
    }
    
    /* Sticky Nav */
    .product-sticky-nav {
        display: none !important;
    }
    
    /* Section Content */
    .product-section .prose,
    .product-section .section-content {
        padding: 20px;
    }
    
    .section-title {
        font-size: 20px !important;
    }
}

@media (max-width: 480px) {
    .info-cards-grid {
        grid-template-columns: 1fr !important;
    }
    
    .image-gallery,
    .masonry-gallery {
        grid-template-columns: 1fr !important;
    }
    
    .gallery-item img {
        height: 180px !important;
    }
}

/* ==========================================================================
   ARCHIVE PAGES - MOBILE FIXES
   ========================================================================== */

@media (max-width: 768px) {
    .archive-grid,
    .blog-grid,
    .projects-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .pagination a,
    .pagination span {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* ==========================================================================
   FIX RAW SHORTCODES DISPLAY
   ========================================================================== */

/* Hide raw shortcode text if not parsed */
.entry-content [caption],
.entry-content [gallery] {
    display: block;
    background: #f5f5f5;
    padding: 10px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 12px;
    overflow-x: auto;
}

/* WordPress Gallery */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.gallery-item {
    margin: 0 !important;
}

.gallery-item img {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

@media (max-width: 480px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

/* ==========================================================================
   STICKY BUTTONS - MOBILE POSITION
   ========================================================================== */

@media (max-width: 768px) {
    .sticky-buttons,
    .social-fixed,
    .contact-fixed {
        bottom: 70px !important; /* Above mobile CTA bar */
    }
    
    .back-to-top {
        right: 16px;
        bottom: 80px;
        width: 40px;
        height: 40px;
    }
}

/* ==========================================================================
   MOBILE CTA BAR (if exists)
   ========================================================================== */

.mobile-cta-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    padding: 10px 16px;
    display: none;
}

@media (max-width: 768px) {
    .mobile-cta-bar {
        display: flex;
        justify-content: space-around;
        gap: 10px;
    }
    
    .mobile-cta-bar a {
        flex: 1;
        text-align: center;
        padding: 10px;
        border-radius: 8px;
        font-size: 13px;
        font-weight: 600;
        text-decoration: none;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .site-header,
    .site-footer,
    .post-sidebar,
    .post-navigation,
    .post-share,
    .related-posts,
    .toc-container,
    .mobile-cta-bar,
    .sticky-buttons,
    .back-to-top {
        display: none !important;
    }
    
    .post-content-wrapper {
        padding: 0 !important;
    }
    
    .entry-content {
        color: #000 !important;
    }
}

/* ==========================================================================
   VĐ5 FIX: Painpoints subtitle & content touching screen edges on mobile
   ========================================================================== */
@media (max-width: 768px) {
    .painpoints-section-modern .painpoints-content .section-subtitle-v2,
    .painpoints-section-modern .painpoints-content .section-title-v2,
    .painpoints-section-modern .section-badge-gold {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }
    
    .painpoints-section-modern .painpoints-list {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    .painpoints-section-modern .painpoints-wrapper {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}
