/**
 * Responsive Fixes for Vietnam Y Quan
 * Fixes layout issues on smaller screens and improves mobile UX
 */

/* ==========================================
   HEADER FIX - Prevent header overlap
   ========================================== */

/* Fix for header overlapping content */
/* Target the main content div that comes after header */
#content {
    margin-top: 0;
}

/* Fix header transparency on mobile */
@media (max-width: 991px) {

    header,
    header.transparent {
        background: transparent !important;
        position: absolute !important;
        top: 0;
        width: 100%;
        box-shadow: none !important;
    }

    /* Ensure topbar is transparent too */
    #topbar {
        background: transparent !important;
        border-bottom: none !important;
    }
}


/* Add top margin/padding to first section after subheader */
#subheader+section,
section#subheader+section {
    margin-top: 0 !important;
}

/* For blog single pages - add padding to blog-read div */
.blog-read,
#postDetail {
    padding-top: 20px;
    position: relative;
    z-index: 1;
}

/* Fix blog post title overlapping TOC */
.blog-read h1,
.blog-read h2:first-child,
#postDetail h1,
#postDetail h2:first-child {
    position: relative !important;
    z-index: 2 !important;
    margin-bottom: 30px !important;
    padding: 20px 0 !important;
    background: transparent !important;
}

/* AGGRESSIVE FIX: Force TOC and content to stack properly */
/* On smaller screens, force everything to be block and full width */
@media (max-width: 1200px) {

    /* Force all columns in blog area to stack */
    .blog-read .col-lg-3,
    .blog-read .col-lg-4,
    .blog-read .col-lg-8,
    .blog-read .col-lg-9,
    #postDetail .col-lg-3,
    #postDetail .col-lg-4,
    #postDetail .col-lg-8,
    #postDetail .col-lg-9 {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
        display: block !important;
        margin-bottom: 20px !important;
    }

    /* Force TOC to be full width and stack */
    .post-toc,
    .widget {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
        display: block !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* Ensure TOC doesn't overlap with title */
.post-toc {
    position: relative !important;
    z-index: 3 !important;
    margin-top: 20px !important;
    clear: both !important;
    display: block !important;
    width: 100% !important;
}

/* Fix sticky TOC positioning */
.toc-sticky {
    position: static !important;
    top: auto !important;
}

/* Ensure proper spacing for all blog content */
.blog-read>*,
#postDetail>* {
    position: relative;
    clear: both;
}

/* Ensure subheader itself has proper top spacing and sizing */
/* Ensure subheader itself has proper top spacing and sizing */
/* Ensure subheader itself has proper top spacing and sizing */
#subheader {
    margin-top: 0 !important;
    /* Allow header to overlay */
    padding-top: 100px !important;
    /* Space content down */
    height: auto !important;
    /* Force auto height to fit content */
    min-height: 300px;
    /* Minimum height for aesthetics */
    padding-bottom: 60px !important;
    /* Add space at bottom */
    overflow: visible !important;
    /* Allow content to be seen */
    display: block;
}

/* Mobile adjustments */
@media (max-width: 991px) {
    #subheader {
        margin-top: 0 !important;
        padding-top: 100px !important;
        padding-bottom: 60px !important;
    }
}

@media (max-width: 767px) {
    #subheader {
        margin-top: 0 !important;
        padding-top: 100px !important;
        /* More top padding for mobile */
        padding-bottom: 60px !important;
        height: auto !important;
    }

    /* Make TOC not sticky on mobile */
    .toc-sticky {
        position: static !important;
        max-height: none !important;
    }
}



/* ==========================================
   TYPOGRAPHY RESPONSIVE
   ========================================== */

/* Scale down large headings on mobile */
@media (max-width: 767px) {

    /* Reduce very large headings in subheader on mobile */
    #subheader h1 {
        font-size: 28px !important;
        /* Smaller size for mobile */
        line-height: 1.3 !important;
    }

    /* Fix blog post title on mobile */
    .blog-read h1,
    #postDetail h1 {
        font-size: 24px !important;
        /* Significantly smaller */
        line-height: 1.3 !important;
        margin-bottom: 15px !important;
    }

    h1 {
        font-size: 28px !important;
        line-height: 1.2;
    }

    h2 {
        font-size: 1.75rem !important;
        line-height: 1.3;
    }

    h3 {
        font-size: 1.5rem !important;
    }

    h4 {
        font-size: 1.25rem !important;
    }

    h5,
    h6 {
        font-size: 1.1rem !important;
    }
}

@media (max-width: 575px) {
    h1 {
        font-size: 1.75rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    h3 {
        font-size: 1.3rem !important;
    }
}

/* ==========================================
   TABLE OF CONTENTS (TOC) RESPONSIVE
   ========================================== */

/* TOC on small screens */
@media (max-width: 991px) {
    .post-toc {
        position: static !important;
        top: auto !important;
        margin-bottom: 20px;
    }

    .toc-sticky {
        position: static !important;
        max-height: none !important;
    }
}

/* TOC text wrap */
.post-toc a {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* ==========================================
   LAYOUT & SPACING
   ========================================== */

/* Container padding on mobile */
@media (max-width: 767px) {
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }

    section {
        padding: 40px 0 !important;
    }
}

/* Reduce section padding on mobile */
@media (max-width: 575px) {
    section {
        padding: 30px 0 !important;
    }

    .contentblock {
        padding: 12px !important;
    }
}

/* ==========================================
   NAVIGATION RESPONSIVE
   ========================================== */

/* Mobile menu improvements */
@media (max-width: 991px) {
    #mainmenu {
        background: rgba(0, 0, 0, 0.8) !important;
        /* Dark glass effect */
        backdrop-filter: blur(10px);
        padding: 20px;
        border-radius: 0 0 10px 10px;
    }

    #mainmenu li {
        display: block;
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    #mainmenu li a {
        padding: 12px 0;
        display: block;
        color: #fff !important;
        /* White text */
        text-align: center;
        /* Center align for better mobile look */
    }

    .submenu {
        position: static !important;
        display: none;
        padding-left: 20px;
    }

    .submenu li {
        border-bottom: 1px dotted #ddd;
    }
}

/* ==========================================
   IMAGES & MEDIA RESPONSIVE
   ========================================== */

/* Ensure all images are responsive */
img {
    max-width: 100%;
    height: auto;
}

.post-text img,
.contentblock img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 10px auto;
}

/* Course card images */
.course-thumb {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* ==========================================
   FORMS RESPONSIVE
   ========================================== */

@media (max-width: 767px) {

    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    textarea {
        font-size: 16px !important;
        /* Prevent zoom on iOS */
    }

    .modal-dialog {
        margin: 10px;
    }

    .modal-content {
        border-radius: 10px;
    }
}

/* ==========================================
   BUTTONS RESPONSIVE
   ========================================== */

@media (max-width: 575px) {
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }

    .btn-lg {
        padding: 12px 24px;
    }
}

/* ==========================================
   TABLES RESPONSIVE
   ========================================== */

@media (max-width: 767px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ==========================================
   CARDS & CONTENT BLOCKS
   ========================================== */

/* Course cards on mobile */
@media (max-width: 575px) {
    .course-card {
        margin-bottom: 20px;
    }

    .card-cta {
        padding: 12px;
    }
}

/* Content wrapper */
@media (max-width: 991px) {
    .content-wrapper {
        padding: 0 15px;
    }
}

/* ==========================================
   FIX SPECIFIC OVERLAP ISSUES
   ========================================== */

/* Prevent content from being hidden under header */
@media (max-width: 991px) {
    #subheader {
        margin-top: 80px;
    }
}

@media (max-width: 767px) {
    #subheader {
        margin-top: 70px;
    }
}

/* Fix text overlapping in blog single */
.post-content {
    position: relative;
    z-index: 1;
}

.post-content h1,
.post-content h2,
.post-content h3 {
    position: relative;
    z-index: 2;
    background: #fff;
    padding: 10px 0;
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */

/* Hide on mobile */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 767px) {
    .show-mobile {
        display: block !important;
    }
}

/* Text alignment on mobile */
@media (max-width: 767px) {
    .text-mobile-center {
        text-align: center !important;
    }
}

/* ==========================================
   COURSE SIDEBAR RESPONSIVE
   ========================================== */

@media (max-width: 991px) {
    .course-sidebar-content {
        position: static !important;
        margin-top: 30px;
    }
}

/* ==========================================
   FOOTER RESPONSIVE
   ========================================== */

@media (max-width: 767px) {
    footer .widget {
        margin-bottom: 30px;
    }

    footer .col-lg-3,
    footer .col-md-6 {
        margin-bottom: 20px;
    }
}

/* ==========================================
   FIX Z-INDEX ISSUES
   ========================================== */

/* Ensure proper stacking */
header {
    z-index: 1002;
}

.modal {
    z-index: 1050;
}

.modal-backdrop {
    z-index: 1040;
}

#completePhoneModal {
    z-index: 2000;
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {

    header,
    footer,
    .modal,
    #btn-extra {
        display: none !important;
    }

    body {
        padding-top: 0 !important;
    }

    .post-content {
        max-width: 100%;
    }
}

/* ==========================================
   NEW RESPONSIVE TOC STYLES
   ========================================== */

/* 1. Desktop ToC Styles */
.toc-sidebar {
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding-right: 15px;
    scrollbar-width: thin;
}

.post-toc-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    border-bottom: 2px solid #8BC34A;
    /* Brand color */
    padding-bottom: 5px;
    color: #333;
}

.post-toc-list,
.post-toc-list ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.post-toc-list ul {
    padding-left: 15px;
}

.post-toc-list li {
    margin-bottom: 8px;
}

.post-toc-list a {
    color: #666;
    text-decoration: none;
    font-size: 14px;
    display: block;
    transition: all 0.3s;
    border-left: 3px solid transparent;
    padding-left: 10px;
    line-height: 1.4;
}

.post-toc-list a:hover {
    color: #8BC34A;
    padding-left: 15px;
}

.post-toc-list a.active {
    color: #8BC34A;
    /* Brand color */
    border-left-color: #8BC34A;
    font-weight: 600;
    background-color: rgba(139, 195, 74, 0.1);
    padding: 5px 10px;
}

/* 2. Mobile Toggle Button (Floating) */
#mobile-toc-toggle {
    position: fixed;
    bottom: 30px;
    right: 20px;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background-color: #8BC34A;
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s, background-color 0.3s;
}

#mobile-toc-toggle:hover {
    transform: scale(1.1);
    background-color: #7CB342;
}

/* 3. Mobile ToC Bottom Sheet */
#mobile-toc-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    z-index: 10000;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.2);
    transform: translateY(101%);
    /* Hide completely */
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

#mobile-toc-container.show {
    transform: translateY(0);
}

.mobile-toc-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9f9f9;
    border-radius: 20px 20px 0 0;
}

.mobile-toc-header h5 {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

#mobile-toc-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0 5px;
    color: #666;
    transition: color 0.3s;
}

#mobile-toc-close:hover {
    color: #000;
}

.mobile-toc-body {
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 4. Overlay */
#mobile-toc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    backdrop-filter: blur(2px);
}

#mobile-toc-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Adjustments for Layout Columns */
@media (max-width: 991px) {
    .toc-sidebar {
        display: none !important;
        /* Hide desktop ToC explicitly just in case */
    }

    /* Ensure content is full width on mobile */
    .blog-read,
    .widget {
        width: 100%;
    }
}