/* =====================================================
 * TAPMERCHANT — GLOBAL RESPONSIVE FIXES
 * File: css/responsive.css
 * Description: Comprehensive mobile-first responsive
 *              overrides for ALL pages. Ensures centered
 *              content, proper touch targets, and clean
 *              layouts on every screen size.
 * ===================================================== */

/* -----------------------------------------------------
 * GLOBAL MOBILE FOUNDATION
 * ----------------------------------------------------- */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Ensure all images are responsive */
img, svg, video, canvas {
    max-width: 100%;
    height: auto;
}

/* Ensure all containers are centered */
.tm-container,
.tm-container-narrow,
.tm-container-wide {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* -----------------------------------------------------
 * TOUCH TARGETS — minimum 44px for mobile
 * ----------------------------------------------------- */
@media (max-width: 768px) {
    a, button, .tm-btn, input, select, textarea,
    [role="button"], .tm-nav-link, .tm-set-row,
    .tm-dash-action, .tm-cat-option, .tm-method-btn,
    .tm-numpad-btn, .tm-tx-filter-btn, .tm-an-period-btn,
    .hc-period-btn, .ga-period-btn, .at-pill, .m-pill {
        min-height: 44px;
        min-width: 44px;
    }
}

/* -----------------------------------------------------
 * TABLET BREAKPOINT (max 1024px)
 * ----------------------------------------------------- */
@media (max-width: 1024px) {
    /* Grids collapse to 2 columns */
    .tm-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .tm-grid-3 { grid-template-columns: repeat(2, 1fr); }

    /* Admin sidebar collapses */
    .adm-sidebar,
    .hc-sidebar,
    .ga-sidebar,
    .at-sidebar,
    .m-sidebar,
    .im-sidebar,
    .al-sidebar,
    .as-sidebar {
        transform: translateX(-100%);
        transition: transform 300ms ease;
    }
    .adm-sidebar.is-open,
    .hc-sidebar.is-open,
    .ga-sidebar.is-open,
    .at-sidebar.is-open,
    .m-sidebar.is-open,
    .im-sidebar.is-open,
    .al-sidebar.is-open,
    .as-sidebar.is-open {
        transform: translateX(0);
    }

    /* Admin main content full width */
    .adm-main,
    .hc-main,
    .ga-main,
    .at-main,
    .m-main,
    .im-main,
    .al-main,
    .as-main {
        margin-left: 0;
    }

    /* Show hamburger buttons */
    .adm-hamburger,
    .hc-hamburger,
    .ga-hamburger,
    .at-hamburger,
    .m-hamburger,
    .im-hamburger,
    .al-hamburger,
    .as-hamburger {
        display: block !important;
    }

    /* Admin stats 2 columns */
    .adm-stats,
    .hc-stats,
    .ga-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Admin grids single column */
    .adm-grid-2,
    .adm-grid-3,
    .hc-grid-2,
    .hc-grid-3,
    .ga-grid-2,
    .ga-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* -----------------------------------------------------
 * MOBILE BREAKPOINT (max 768px)
 * ----------------------------------------------------- */
@media (max-width: 768px) {

    /* ---- Typography scaling ---- */
    h1, .tm-hero-title { font-size: clamp(1.75rem, 6vw, 2.5rem) !important; }
    h2 { font-size: clamp(1.375rem, 5vw, 1.75rem) !important; }
    h3 { font-size: clamp(1.125rem, 4vw, 1.375rem) !important; }

    /* ---- Containers full width with padding ---- */
    .tm-container,
    .tm-container-narrow,
    .tm-container-wide {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    /* ---- All grids single column ---- */
    .tm-grid-4,
    .tm-grid-3,
    .tm-grid-2 {
        grid-template-columns: 1fr !important;
    }

    /* ---- Landing page hero ---- */
    .tm-hero-inner {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
        text-align: center;
    }
    .tm-hero-copy {
        order: 1;
    }
    .tm-hero-visual {
        order: 2;
        min-height: 380px !important;
    }
    .tm-hero-cta {
        justify-content: center;
        flex-direction: column;
        align-items: center;
    }
    .tm-hero-cta .tm-btn {
        width: 100%;
        max-width: 320px;
    }
    .tm-hero-trust {
        grid-template-columns: 1fr !important;
        text-align: left;
    }
    .tm-hero-sub {
        margin-left: auto;
        margin-right: auto;
    }
    .tm-hero-phone {
        width: 220px !important;
        height: 440px !important;
        transform: rotate(0) !important;
    }
    .tm-hero-card {
        display: none !important;
    }

    /* ---- Stats strip ---- */
    .tm-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    .tm-stat-value {
        font-size: 1.75rem !important;
    }

    /* ---- Features ---- */
    .tm-features-grid {
        grid-template-columns: 1fr !important;
    }
    .tm-feature-card-lg {
        grid-column: span 1 !important;
    }

    /* ---- Steps ---- */
    .tm-steps {
        grid-template-columns: 1fr !important;
    }

    /* ---- Categories ---- */
    .tm-categories {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    /* ---- Showcase ---- */
    .tm-showcase {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
    }
    .tm-showcase .tm-section-title {
        text-align: center !important;
    }

    /* ---- Testimonials ---- */
    .tm-testimonials {
        grid-template-columns: 1fr !important;
    }

    /* ---- Pricing ---- */
    .tm-pricing {
        grid-template-columns: 1fr !important;
        max-width: 400px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* ---- CTA ---- */
    .tm-cta-box {
        padding: 48px 20px !important;
        border-radius: 20px !important;
    }
    .tm-cta-buttons {
        flex-direction: column;
        align-items: center;
    }
    .tm-cta-buttons .tm-btn {
        width: 100%;
        max-width: 320px;
    }

    /* ---- Footer ---- */
    .tm-footer-grid {
        grid-template-columns: 1fr !important;
        gap: 28px !important;
        text-align: center;
    }
    .tm-footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 8px !important;
    }

    /* ---- Auth pages ---- */
    .tm-auth-shell {
        grid-template-columns: 1fr !important;
    }
    .tm-auth-aside {
        min-height: 200px !important;
        max-height: 260px !important;
    }
    .tm-auth-aside-list {
        display: none !important;
    }
    .tm-auth-aside-footer {
        display: none !important;
    }
    .tm-auth-form-wrap {
        padding: 24px 20px 48px !important;
    }

    /* ---- Dashboard ---- */
    .tm-dash-actions {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .tm-dash-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .tm-dash-hero-amount {
        font-size: 2.25rem !important;
    }

    /* ---- Payment screen ---- */
    .tm-numpad-btn {
        height: 56px !important;
        font-size: 1.375rem !important;
    }
    .tm-amount-value {
        font-size: 2.5rem !important;
    }
    .tm-method-selector {
        flex-direction: row !important;
    }
    .tm-method-btn {
        font-size: 0.6875rem !important;
        padding: 10px 4px !important;
    }

    /* ---- Transaction list ---- */
    .tm-tx-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }
    .tm-tx-summary {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ---- Analytics ---- */
    .tm-an-summary {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .tm-an-bar-chart {
        height: 100px !important;
    }
    .tm-an-heatmap {
        grid-template-columns: repeat(6, 1fr) !important;
    }
    .tm-an-heat-labels {
        grid-template-columns: repeat(6, 1fr) !important;
    }

    /* ---- Settings ---- */
    .tm-set-row {
        flex-wrap: wrap;
    }

    /* ---- Onboarding ---- */
    .tm-cat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .tm-onboard-actions {
        flex-direction: column !important;
    }
    .tm-onboard-actions .tm-btn {
        width: 100%;
    }

    /* ---- Admin pages ---- */
    .adm-stats,
    .hc-stats,
    .ga-stats {
        grid-template-columns: 1fr !important;
    }
    .adm-quick-links {
        grid-template-columns: 1fr !important;
    }
    .adm-topbar,
    .hc-topbar,
    .ga-topbar,
    .at-topbar,
    .m-topbar,
    .im-topbar,
    .al-topbar,
    .as-topbar {
        padding: 12px 16px !important;
    }
    .adm-content,
    .hc-content,
    .ga-content,
    .at-content,
    .m-content,
    .im-content,
    .al-content,
    .as-content {
        padding: 16px !important;
    }

    /* Admin tables scroll */
    .adm-table,
    .at-table,
    .m-table,
    .hc-table,
    .ga-table,
    .um-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Admin search bars stack */
    .m-search-bar,
    .at-search-bar {
        flex-direction: column !important;
    }

    /* Admin filter pills scroll */
    .at-filters,
    .m-filter-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Admin image grid */
    .im-grid {
        grid-template-columns: 1fr !important;
    }

    /* Admin settings */
    .as-setting-row {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    .as-setting-input,
    .as-setting-input.wide {
        width: 100% !important;
        text-align: left !important;
    }
    .as-plans {
        grid-template-columns: 1fr !important;
    }

    /* Admin modals */
    .m-modal,
    .im-modal {
        max-width: 100% !important;
        margin: 10px !important;
        border-radius: 14px !important;
    }

    /* ---- User Manual ---- */
    .um-layout {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    .um-toc {
        display: none !important;
    }
    .um-toc.is-open {
        display: block !important;
    }
    .um-toc-toggle {
        display: block !important;
    }
    .um-features {
        grid-template-columns: 1fr !important;
    }
    .um-header h1 {
        font-size: 2rem !important;
    }
    .um-header-nav {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* ---- Bottom nav ---- */
    .tm-dash-nav,
    .tm-tx-nav,
    .tm-an-nav,
    .tm-set-nav {
        padding: 6px 0 !important;
    }
    .tm-dash-nav-item,
    .tm-tx-nav-item,
    .tm-an-nav-item,
    .tm-set-nav-item {
        font-size: 0.5625rem !important;
        padding: 4px 6px !important;
    }
    .tm-dash-nav-pay,
    .tm-tx-nav-pay,
    .tm-an-nav-pay,
    .tm-set-nav-pay {
        width: 48px !important;
        height: 48px !important;
        margin-top: -16px !important;
    }

    /* ---- Toast notifications ---- */
    .tm-toast-container {
        left: 12px !important;
        right: 12px !important;
        max-width: none !important;
    }

    /* ---- Modals ---- */
    .tm-modal {
        max-width: 100% !important;
        margin: 12px !important;
        border-radius: 14px !important;
    }
}

/* -----------------------------------------------------
 * SMALL MOBILE (max 480px)
 * ----------------------------------------------------- */
@media (max-width: 480px) {

    /* Even tighter spacing */
    .tm-section {
        padding: 48px 0 !important;
    }
    .tm-hero {
        padding: 40px 0 60px !important;
    }

    /* Stats single column */
    .tm-stats-grid,
    .tm-dash-actions,
    .tm-dash-stats,
    .tm-an-summary {
        grid-template-columns: 1fr !important;
    }

    /* Categories 2 columns still */
    .tm-categories {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Phone mockup smaller */
    .tm-hero-phone {
        width: 180px !important;
        height: 360px !important;
    }
    .tm-hero-visual {
        min-height: 300px !important;
    }
    .tm-slot-hero-amount {
        font-size: 1.75rem !important;
        margin-top: 30px !important;
    }

    /* Numpad */
    .tm-numpad {
        gap: 6px !important;
        padding: 8px 12px 16px !important;
    }
    .tm-numpad-btn {
        height: 52px !important;
        font-size: 1.25rem !important;
        border-radius: 10px !important;
    }

    /* Amount display */
    .tm-amount-value {
        font-size: 2rem !important;
    }
    .tm-amount-display {
        padding: 24px 16px 12px !important;
    }

    /* Payment result */
    .tm-result-amount {
        font-size: 2rem !important;
    }

    /* Transaction detail */
    .tm-td-hero-amount {
        font-size: 2rem !important;
    }

    /* Onboarding */
    .tm-cat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    .tm-cat-option {
        padding: 10px 6px !important;
        font-size: 0.75rem !important;
    }

    /* Stepper */
    .tm-stepper {
        padding: 20px 16px 10px !important;
    }
    .tm-step-dot {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.75rem !important;
    }

    /* Admin stat values smaller */
    .adm-stat-value,
    .hc-stat-value,
    .ga-stat-value {
        font-size: 1.5rem !important;
    }

    /* Hide secondary info on very small screens */
    .tm-hero-note {
        display: none !important;
    }
}

/* -----------------------------------------------------
 * VERY SMALL MOBILE (max 360px)
 * ----------------------------------------------------- */
@media (max-width: 360px) {
    html {
        font-size: 14px;
    }
    .tm-hero-phone {
        width: 160px !important;
        height: 320px !important;
    }
    .tm-numpad-btn {
        height: 48px !important;
        font-size: 1.125rem !important;
    }
    .tm-categories {
        grid-template-columns: 1fr !important;
    }
}

/* -----------------------------------------------------
 * LANDSCAPE MOBILE
 * ----------------------------------------------------- */
@media (max-height: 500px) and (orientation: landscape) {
    .tm-hero {
        padding: 20px 0 40px !important;
    }
    .tm-hero-visual {
        display: none !important;
    }
    .tm-auth-aside {
        display: none !important;
    }
    .tm-dash-nav,
    .tm-tx-nav,
    .tm-an-nav,
    .tm-set-nav {
        display: none !important;
    }
}

/* -----------------------------------------------------
 * LARGE SCREENS (min 1400px)
 * ----------------------------------------------------- */
@media (min-width: 1400px) {
    .tm-container {
        max-width: 1200px;
    }
    .adm-content,
    .hc-content,
    .ga-content {
        max-width: 1200px;
        margin: 0 auto;
    }
}

/* -----------------------------------------------------
 * PRINT STYLES
 * ----------------------------------------------------- */
@media print {
    .tm-dash-nav,
    .tm-tx-nav,
    .tm-an-nav,
    .tm-set-nav,
    .adm-sidebar,
    .hc-sidebar,
    .ga-sidebar,
    .at-sidebar,
    .m-sidebar,
    .im-sidebar,
    .al-sidebar,
    .as-sidebar,
    .tm-theme-toggle,
    .tm-announce,
    .tm-sandbox-banner,
    .tm-dash-sandbox,
    .adm-hamburger,
    .hc-hamburger,
    .ga-hamburger,
    .at-hamburger,
    .m-hamburger,
    .im-hamburger,
    .al-hamburger,
    .as-hamburger,
    .um-back-top,
    .um-toc-toggle,
    .tm-toast-container {
        display: none !important;
    }

    .adm-main,
    .hc-main,
    .ga-main,
    .at-main,
    .m-main,
    .im-main,
    .al-main,
    .as-main {
        margin-left: 0 !important;
    }

    body {
        background: white !important;
        color: black !important;
    }
}

/* -----------------------------------------------------
 * ACCESSIBILITY: REDUCED MOTION
 * ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* -----------------------------------------------------
 * HIGH CONTRAST MODE
 * ----------------------------------------------------- */
@media (prefers-contrast: high) {
    .tm-btn-primary {
        border: 2px solid #000;
    }
    .tm-card,
    .tm-feature-card,
    .tm-step,
    .tm-testimonial,
    .tm-price-card {
        border-width: 2px;
        border-color: var(--tm-text);
    }
}

/* =====================================================
 * END OF responsive.css
 * ===================================================== */