/* ============================================
   MOBILE.CSS – Tối Ưu Mobile cho Trường Thịnh AD
   Áp dụng cho: index.html, dich-vu.html, du-an.html,
                bang-gia.html, gioi-thieu.html, lien-he.html
   ============================================ */

/* ---- GLOBAL MOBILE FIXES ---- */
*, *::before, *::after {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: 100px !important;
}

section[id], h2[id], h3[id], article[id], [id] {
    scroll-margin-top: 100px !important;
}

body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* ---- TOUCH TARGETS ---- */
a, button, input, select, textarea, label {
    min-height: 44px; /* Apple HIG: min 44px touch target */
}

input[type="range"] {
    min-height: 24px; /* Slider không cần 44px */
}

/* ---- PULSE RING ANIMATION (Float Button) ---- */
@keyframes pulse-ring {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 14px rgba(217, 119, 6, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); }
}
.pulse-ring {
    animation: pulse-ring 2s cubic-bezier(0.455, 0.03, 0.515, 0.955) infinite;
}

/* ---- STICKY MOBILE BOTTOM BAR ---- */
.mobile-cta-bar {
    display: none;
}

@media (max-width: 767px) {
    /* Show mobile bottom CTA bar - Impeccable Floating Dock Style */
    .mobile-cta-bar {
        display: flex;
        position: fixed;
        bottom: 10px;
        left: 10px;
        right: 10px;
        z-index: 60;
        background: rgba(15, 23, 42, 0.92);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.14);
        box-shadow: 0 16px 40px -6px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
        padding: 7px 8px;
        gap: 6px;
        border-radius: 20px;
        margin-bottom: env(safe-area-inset-bottom);
    }

    .mobile-cta-bar a {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        padding: 9px 6px;
        border-radius: 14px;
        font-weight: 800;
        font-size: 11.5px;
        min-height: 44px;
        text-decoration: none;
        transition: transform 0.15s ease, opacity 0.15s ease;
    }

    .mobile-cta-bar a:active {
        transform: scale(0.96);
        opacity: 0.9;
    }

    .mobile-cta-bar .cta-zalo {
        background: #0068ff;
        color: #fff;
        box-shadow: 0 4px 12px rgba(0, 104, 255, 0.35);
    }

    .mobile-cta-bar .cta-call {
        background: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
        color: #fff;
        box-shadow: 0 4px 14px rgba(217, 119, 6, 0.45);
    }

    .mobile-cta-bar .cta-quote {
        background: #ffffff;
        color: #0f172a;
        box-shadow: 0 4px 12px rgba(255, 255, 255, 0.25);
    }

    .mobile-cta-bar .cta-loban {
        background: #1e293b;
        color: #fbbf24;
        border: 1px solid rgba(217, 119, 6, 0.6);
    }

    /* Add bottom padding to body so content isn't hidden under bar */
    body {
        padding-bottom: calc(74px + env(safe-area-inset-bottom));
    }

    /* Hide the original floating buttons on mobile */
    .floating-cta-desktop {
        display: none !important;
    }

    /* ---- HERO SECTION MOBILE ---- */
    #trang-chu {
        padding-top: 28px !important;
        padding-bottom: 40px !important;
    }

    #trang-chu h1 {
        font-size: 1.75rem !important; /* 28px */
        line-height: 1.2 !important;
    }

    #trang-chu .grid.lg\:grid-cols-12 {
        gap: 28px !important;
    }

    /* Hero action buttons – stack vertically */
    #trang-chu .flex.flex-wrap.gap-4 {
        flex-direction: column;
        gap: 10px !important;
    }

    #trang-chu .flex.flex-wrap.gap-4 a {
        width: 100%;
        justify-content: center;
        padding: 14px 20px !important;
        font-size: 14px !important;
    }

    /* Stats bar: 2 col on mobile */
    #trang-chu .grid.grid-cols-2.md\:grid-cols-4 {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    /* Hero form card: reduce padding */
    #trang-chu .glass-card.rounded-3xl {
        padding: 20px !important;
    }

    /* ---- COST ESTIMATOR SECTION ---- */
    #du-toan .grid.lg\:grid-cols-12 {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
    }

    #du-toan .lg\:col-span-7,
    #du-toan .lg\:col-span-5 {
        width: 100% !important;
    }

    /* Material selector: 1 col on mobile */
    #material-selector {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* ---- SERVICES GRID ---- */
    #dich-vu .grid.md\:grid-cols-2.lg\:grid-cols-3 {
        grid-template-columns: 1fr;
    }

    /* ---- BEFORE/AFTER SECTION ---- */
    .grid.lg\:grid-cols-12.gap-12 > div {
        /* This is too broad - only target the before/after */
    }

    /* Before/After slider height */
    #before-after-container {
        height: 240px !important;
    }

    /* ---- PORTFOLIO FILTER BUTTONS ---- */
    #portfolio-filters {
        gap: 6px !important;
        justify-content: flex-start !important;
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    #portfolio-filters::-webkit-scrollbar {
        display: none;
    }

    #portfolio-filters button {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 10px 14px !important;
    }

    /* Portfolio grid: 1 col on very small screens */
    #portfolio-grid {
        grid-template-columns: 1fr;
    }

    /* ---- WORKFLOW STEPS ---- */
    #quy-trinh .grid.sm\:grid-cols-2.lg\:grid-cols-5 {
        grid-template-columns: 1fr 1fr;
        gap: 12px !important;
    }

    /* ---- PRICE TABLE ---- */
    #bao-gia .overflow-x-auto {
        /* Add visual hint that table is scrollable */
        position: relative;
    }

    /* Price table: make it scrollable with indicator */
    #bao-gia table {
        font-size: 12px;
    }

    #bao-gia table th,
    #bao-gia table td {
        padding: 10px 8px !important;
    }

    /* ---- TESTIMONIALS ---- */
    .grid.md\:grid-cols-3 {
        grid-template-columns: 1fr !important;
    }

    /* ---- CTA BANNER ---- */
    section .flex.flex-wrap.justify-center.gap-4 a {
        padding: 14px 24px !important;
        font-size: 13px !important;
    }

    /* ---- SECTION HEADINGS ---- */
    .text-3xl.sm\:text-4xl {
        font-size: 1.6rem !important; /* Slightly smaller on mobile */
    }

    .text-3xl.sm\:text-5xl {
        font-size: 1.75rem !important;
    }

    /* ---- MODAL: Full screen on mobile ---- */
    #consult-modal > div {
        border-radius: 20px !important;
        margin: 12px !important;
        max-height: calc(100vh - 24px);
        overflow-y: auto;
    }

    /* ---- CONTACT BANNER ---- */
    .bg-\[\#0f172a\].rounded-2xl.p-6 .flex.flex-wrap.gap-3 {
        flex-direction: column;
        width: 100%;
    }

    .bg-\[\#0f172a\].rounded-2xl.p-6 .flex.flex-wrap.gap-3 a {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    /* ---- FOOTER ---- */
    footer .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-4 {
        grid-template-columns: 1fr !important;
        gap: 28px !important;
    }
}

/* ---- SMALL PHONES (320px - 375px) ---- */
@media (max-width: 375px) {
    #trang-chu h1 {
        font-size: 1.5rem !important;
    }

    .font-heading.font-extrabold.text-2xl {
        font-size: 1.3rem !important;
    }

    #quy-trinh .grid {
        grid-template-columns: 1fr !important;
    }
}

/* ---- TABLET (768px - 1023px) ---- */
@media (min-width: 768px) and (max-width: 1023px) {
    #trang-chu h1 {
        font-size: 2.5rem !important;
    }

    #trang-chu .grid.lg\:grid-cols-12 {
        grid-template-columns: 1fr 1fr;
        gap: 32px;
    }

    #material-selector {
        grid-template-columns: 1fr 1fr !important;
    }

    #du-toan .grid.lg\:grid-cols-12 {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Portfolio: 2 cols on tablet */
    #portfolio-grid {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* ---- SCROLL TABLE INDICATOR (ALL SCREENS) ---- */
.table-scroll-wrapper {
    position: relative;
    overflow: hidden;
}

.table-scroll-wrapper::after {
    content: '← Vuốt ngang để xem →';
    display: none;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.85);
    color: #fbbf24;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 8px 8px 0 0;
    white-space: nowrap;
    z-index: 5;
    pointer-events: none;
}

@media (max-width: 1023px) {
    .table-scroll-wrapper::after {
        display: block;
    }
}

/* ---- IMAGE PERFORMANCE ---- */
img {
    max-width: 100%;
    height: auto;
}

/* ---- SAFE AREA SUPPORT (iPhone notch) ---- */
@supports (padding: max(0px)) {
    .mobile-cta-bar {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
}

/* ---- FOCUS STYLES FOR ACCESSIBILITY ---- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #d97706;
    outline-offset: 2px;
}

/* ---- SCROLL SNAP FOR PORTFOLIO FILTER (Mobile) ---- */
@media (max-width: 767px) {
    #portfolio-filters {
        scroll-snap-type: x mandatory;
    }

    #portfolio-filters button {
        scroll-snap-align: start;
    }
}

/* ---- ANIMATION PERFORMANCE ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
