/*
 * MyDent Responsive Fixes
 * Covers: 320px – 1920px
 * Strategy: Mobile-first overrides on top of Bootstrap 5 + Canvas theme
 * DO NOT add hardcoded widths — use max-width + percentage + flex/grid
 */

/* ============================================================
   GLOBAL BASE RESETS
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Single page scrollbar only — overflow-x:hidden on BOTH html+body creates dual vertical bars */
html {
    overflow-x: clip;
    overflow-y: scroll;
    max-width: 100%;
}
body {
    overflow-x: clip;
    overflow-y: visible;
    max-width: 100%;
}

img, video, iframe, svg {
    max-width: 100%;
    height: auto;
}

/* ============================================================
   TYPOGRAPHY — RESPONSIVE CLAMP
   ============================================================ */
h1 {
    font-size: clamp(1.6rem, 5vw, 3rem);
    word-break: break-word;
}

h2 {
    font-size: clamp(1.3rem, 4vw, 2.25rem);
    word-break: break-word;
}

h3 {
    font-size: clamp(1.1rem, 3.5vw, 1.75rem);
}

h4 {
    font-size: clamp(1rem, 3vw, 1.5rem);
}

p, .paragraph {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Prevent long emails/phones from breaking layout */
a[href^="mailto:"],
a[href^="tel:"],
.footer-info__contact-label {
    word-break: break-all;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* ============================================================
   SECTION PADDING — MOBILE REDUCTION
   ============================================================ */
@media (max-width: 767.98px) {
    .p-t-100 { padding-top: 40px !important; }
    .p-b-100 { padding-bottom: 40px !important; }
    .p-t-50  { padding-top: 25px !important; }
    .p-b-50  { padding-bottom: 25px !important; }
    .p-t-30  { padding-top: 15px !important; }
    .mt-5.mt-lg-0 { margin-top: 16px !important; }
}

@media (min-width: 768px) and (max-width: 1023.98px) {
    .p-t-100 { padding-top: 60px !important; }
    .p-b-100 { padding-bottom: 60px !important; }
}

/* ============================================================
   HEADER / NAVIGATION
   ============================================================ */
header {
    position: sticky;
    top: 0;
    z-index: 1030;
}

/* Ensure logo never overflows — keep brand mark prominent */
.front-app-logo {
    max-height: 64px !important;
    max-width: 220px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
}

@media (max-width: 991.98px) {
    .front-app-logo {
        max-height: 52px !important;
        max-width: 180px !important;
    }
}

@media (max-width: 991.98px) {
    /* Stack header-btn-grp correctly when nav collapses */
    .header-btn-grp {
        flex-wrap: wrap;
        gap: 6px !important;
        padding: 8px 0;
        justify-content: center;
    }

    .header-btn-grp .btn {
        font-size: 0.8rem;
        padding: 5px 10px;
    }

    /* Hamburger aligned right */
    .navbar-toggler {
        margin-left: auto;
    }

    /* Collapsed nav full-width */
    .navbar-collapse {
        width: 100%;
        background: #fff;
        padding: 12px 0;
        border-top: 1px solid #eee;
    }

    .navbar-nav .nav-link {
        padding: 8px 16px !important;
        border-bottom: 1px solid #f5f5f5;
    }
}

@media (max-width: 575.98px) {
    .header-btn-grp .btn {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
}

/* ============================================================
   FLOATING ACTION BUTTONS (WhatsApp / Phone / Appointment)
   ============================================================ */
.floating-action-btns,
.whatsapp-float,
.phone-float,
.appointment-float,
[class*="floating-btn"],
[id*="floating"],
[id*="whatsapp-btn"],
[id*="whatsappBtn"] {
    position: fixed !important;
    right: 15px !important;
    z-index: 999 !important;
    /* iOS safe area */
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Stack them vertically — bottom up */
.whatsapp-float,
[id="whatsappFloat"],
a[href*="wa.me"],
a[href*="whatsapp"] {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 155px) !important;
}

.phone-float,
[id="phoneFloat"],
a[href^="tel:"].floating,
a.float-phone {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 95px) !important;
}

.appointment-float,
[id="appointmentFloat"],
a.float-appointment {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 35px) !important;
}

@media (max-width: 767.98px) {
    .whatsapp-float,
    [id="whatsappFloat"],
    a[href*="wa.me"],
    a[href*="whatsapp"] {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 140px) !important;
        right: 12px !important;
    }

    .phone-float,
    [id="phoneFloat"] {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 85px) !important;
        right: 12px !important;
    }

    .appointment-float,
    [id="appointmentFloat"] {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 30px) !important;
        right: 12px !important;
    }

    /* Shrink FABs on mobile */
    .whatsapp-float img,
    .phone-float img,
    .appointment-float img,
    [id*="Float"] img {
        width: 48px !important;
        height: 48px !important;
    }
}

/* ============================================================
   HOMEPAGE — HERO SECTION
   ============================================================ */
.hero-section {
    overflow-x: hidden;
}

@media (max-width: 767.98px) {
    .hero-section .hero-content {
        text-align: center;
        padding: 0 12px;
    }

    .hero-section video {
        width: 100% !important;
        max-height: 260px !important;
        border-radius: 12px !important;
        margin-top: 20px;
    }

    .hero-section .btn {
        width: auto;
        min-width: 140px;
    }
}

/* ============================================================
   DENTAL ISSUES SCROLLABLE CARDS
   ============================================================ */
#scrollCards {
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* Prevent overflowing parent */
    max-width: 100%;
    padding-left: 8px !important;
    padding-right: 8px !important;
}

#scrollCards::-webkit-scrollbar {
    display: none;
}

/* Cards inside scrollable row */
#scrollCards > a > div,
#scrollCards > div {
    flex-shrink: 0;
}

@media (max-width: 767.98px) {
    #scrollCards > a > div,
    #scrollCards > div {
        min-width: 240px !important;
        max-width: 240px !important;
    }

    #scrollCards > a > div video,
    #scrollCards > div video,
    #scrollCards > div img {
        height: 260px !important;
        width: 100% !important;
        object-fit: cover !important;
    }

    /* Scroll arrows hide on mobile (swipe replaces them) */
    #scrollLeft,
    #scrollRight {
        display: none !important;
    }
}

/* ============================================================
   COMPARISON TABLE (clear aligners vs braces)
   ============================================================ */
.table-responsive {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 575.98px) {
    .table-responsive table th,
    .table-responsive table td {
        font-size: 0.8rem;
        padding: 8px 6px !important;
    }
}

/* ============================================================
   PRICING CARDS SECTION
   ============================================================ */
.aligner-container {
    flex-wrap: wrap;
}

.aligner-text,
.aligner-right {
    min-width: 0 !important;
    width: 100%;
}

@media (max-width: 767.98px) {
    .aligner-cards {
        flex-direction: column !important;
    }

    .aligner-cards .card {
        border-radius: 8px !important;
        transform: none !important;
        margin-bottom: 12px;
        min-width: 0 !important;
        width: 100%;
    }
}

/* ============================================================
   TESTIMONIALS / DOCTOR CARDS
   ============================================================ */
@media (max-width: 767.98px) {
    .slick-slide {
        padding: 0 8px;
    }

    .front-testimonial-card,
    .doctor-card {
        margin: 0 auto;
        max-width: 100%;
    }
}

/* ============================================================
   FOOTER
   ============================================================ */
footer.bg-primary {
    padding: 40px 0 0;
}

footer .container > .row {
    row-gap: 24px;
}

footer .col-lg-4,
footer .col-md-6 {
    padding: 0 16px;
}

/* Contact block */
.footer-info__block {
    flex-wrap: nowrap;
    gap: 10px;
}

.footer-info__footer-icon {
    min-width: 36px;
    flex-shrink: 0;
}

/* Quick links */
footer ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

footer ul li a {
    display: block;
    padding: 4px 0;
    white-space: normal;
    word-break: break-word;
}

/* Subscribe form */
.subscribe-form .input-group {
    flex-wrap: nowrap;
    max-width: 100%;
}

.subscribe-form .form-control {
    min-width: 0;
    flex: 1 1 auto;
}

/* Copyright row */
footer .border-top-primary {
    border-top: 1px solid rgba(255,255,255,0.2) !important;
}

footer .footer-social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

@media (max-width: 767.98px) {
    footer.bg-primary {
        padding: 30px 0 0;
    }

    /* Stack all 3 footer columns */
    footer .col-lg-4,
    footer .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
        order: unset !important;
    }

    /* Subscribe column first on mobile */
    footer .col-lg-4.col-12.order-0 {
        order: -1 !important;
    }

    /* Copyright text wraps properly */
    footer p.text-white {
        font-size: 0.82rem;
        text-align: center !important;
    }

    /* Subscribe input stacks nicely */
    .subscribe-form .input-group {
        max-width: 320px;
        margin: 0 auto;
    }

    footer h5 {
        margin-bottom: 12px !important;
        padding-bottom: 0 !important;
    }
}

/* ============================================================
   CART PAGE
   ============================================================ */
.cart-page {
    margin-top: 70px;
    overflow-x: hidden;
}

@media (max-width: 767.98px) {
    .cart-page {
        margin-top: 60px;
        padding: 16px 0 !important;
    }

    /* Table overflow container */
    .cart-page .table-responsive {
        margin: 0 -8px;
    }

    /* Qty input */
    .cart-page input[type="number"] {
        width: 60px !important;
    }

    /* Order summary full width */
    .cart-page .col-lg-4 {
        margin-top: 20px;
    }

    /* Continue shopping button */
    .cart-page .btn-outline-primary.rounded-pill {
        font-size: 0.85rem;
        padding: 8px 14px;
    }
}

/* ============================================================
   CHECKOUT PAGE
   ============================================================ */
.checkout-page {
    overflow-x: hidden;
}

@media (max-width: 767.98px) {
    .checkout-page {
        padding: 16px 0 !important;
    }

    .checkout-page h1 {
        font-size: 1.6rem;
    }

    /* Shipping form inputs full-width */
    .checkout-page .col-md-6,
    .checkout-page .col-md-4 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Order summary sticky top override */
    .checkout-page .sticky-top {
        position: relative !important;
        top: auto !important;
    }

    /* Payment method options */
    .checkout-page .form-check {
        padding: 12px !important;
    }

    /* Place order button */
    .checkout-page .btn.w-100.rounded-pill {
        font-size: 1rem;
        padding: 14px 0 !important;
        /* ensure not covered by FABs */
        margin-bottom: 80px;
    }

    /* Card padding reduction */
    .checkout-page .card-body.p-6 {
        padding: 16px !important;
    }
}

@media (max-width: 374.98px) {
    .checkout-page .btn.w-100.rounded-pill {
        font-size: 0.9rem;
    }
}

/* ============================================================
   APPOINTMENT PAGE
   ============================================================ */
.book-appointment-page {
    overflow-x: hidden;
}

.book-appointment-section .appointment-form {
    padding: 0 8px;
}

.book-appointment-form {
    padding: 20px !important;
    width: 100%;
    overflow-x: hidden;
}

@media (max-width: 767.98px) {
    .book-appointment-form {
        padding: 16px !important;
        border-radius: 12px !important;
    }

    /* All form cols full width */
    .book-appointment-form .col-lg-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Time slot grid */
    .front-slot-data {
        flex-wrap: wrap;
        gap: 8px;
    }

    .front-slot-data .slot-item,
    .front-slot-data button {
        font-size: 0.78rem;
        padding: 6px 10px !important;
    }

    /* Confirm booking button */
    #saveBtn {
        width: 100%;
        padding: 12px 0;
    }

    /* Patient account checkbox */
    .book-appointment-form .form-check {
        margin-left: 0 !important;
        width: 100%;
        justify-content: flex-start !important;
    }
}

/* ============================================================
   SELECT2 DROPDOWNS
   ============================================================ */
.select2-container {
    width: 100% !important;
}

/* ============================================================
   PRODUCTS / ECOM PAGE
   ============================================================ */
.product-card {
    width: 100%;
    max-width: 100%;
}

@media (max-width: 767.98px) {
    .medical-ecom-section .row > [class*="col-"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media (max-width: 374.98px) {
    .medical-ecom-section .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ============================================================
   MODAL/DIALOG WIDTH
   ============================================================ */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 8px !important;
        max-width: calc(100vw - 16px) !important;
    }

    .modal-body {
        padding: 16px !important;
    }
}

/* ============================================================
   BLOG SCROLL SECTION
   ============================================================ */
.scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.9);
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 16px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-btn.left  { left: -12px; }
.scroll-btn.right { right: -12px; }

@media (max-width: 575.98px) {
    .scroll-btn {
        display: none !important;
    }
}

/* ============================================================
   BEFORE/AFTER SECTIONS (SMILE JOURNEY)
   ============================================================ */
@media (max-width: 767.98px) {
    .col-md-4.mb-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Cards with fixed height — allow height to be auto on mobile */
    .card[style*="height: 320px"] {
        height: auto !important;
        min-height: 260px;
    }

    .card[style*="height: 320px"] video {
        height: 160px !important;
    }
}

/* ============================================================
   GENERAL UTILITIES
   ============================================================ */
/* Ensure Bootstrap .container doesn't overflow on very small screens */
@media (max-width: 374.98px) {
    .container, .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

/* Prevent overflow from py-10 and py-8 */
@media (max-width: 767.98px) {
    .py-10 { padding-top: 32px !important; padding-bottom: 32px !important; }
    .py-8  { padding-top: 24px !important; padding-bottom: 24px !important; }
    .mb-8  { margin-bottom: 24px !important; }
    .mb-6  { margin-bottom: 16px !important; }
    .p-6   { padding: 16px !important; }
}

/* ============================================================
   PREVENT OVERFLOW FROM INLINE STYLES
   ============================================================ */
[style*="min-width: 300px"] {
    min-width: min(300px, 85vw) !important;
}

[style*="min-width: 180px"] {
    min-width: min(180px, 45vw) !important;
}

/* ============================================================
   IOS SAFE AREA — BOTTOM NAVIGATION PADDING
   ============================================================ */
body {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ============================================================
   PRINT RESET
   ============================================================ */
@media print {
    header, footer, .floating-action-btns, .whatsapp-float, .phone-float, .appointment-float {
        display: none !important;
    }
}
