/**
 * Mobile App Experience — Android-Style Native Feel
 * ALGOPK Solar System Recommender
 * =================================================
 * This stylesheet transforms the desktop website into
 * an Android app-like experience on mobile devices.
 * All styles scoped to @media (max-width: 768px).
 * Depends on variables from main.css and classes from
 * frontend.css / products.css.
 */


/* =====================================================
   0. KEYFRAME ANIMATIONS
   ===================================================== */

@keyframes mobilePageFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes rippleEffect {
    from {
        transform: scale(0);
        opacity: 0.4;
    }
    to {
        transform: scale(2.5);
        opacity: 0;
    }
}

@keyframes slideUpSheet {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideDownSheet {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

@keyframes bottomNavBounce {
    0%   { transform: scale(1); }
    50%  { transform: scale(0.9); }
    100% { transform: scale(1); }
}


/* =====================================================
   1. PWA-FEEL GLOBAL ENHANCEMENTS
   ===================================================== */

@media (max-width: 768px) {

    /* Remove tap highlight and 300ms delay */
    html {
        -webkit-tap-highlight-color: transparent;
        -webkit-text-size-adjust: 100%;
    }

    body {
        font-size: 15px;
        line-height: 1.5;
        padding-top: 56px;
        overscroll-behavior-y: contain;
        animation: mobilePageFadeIn 0.4s ease-out;
    }

    /* Hide scrollbars for cleaner app feel */
    ::-webkit-scrollbar {
        display: none;
    }

    * {
        scrollbar-width: none;
    }

    /* Touch manipulation on interactive elements */
    a,
    button,
    input,
    select,
    textarea,
    [role="button"],
    .btn,
    .nav-link,
    .product-card,
    .filter-label,
    .pagination-btn {
        touch-action: manipulation;
    }

    /* Prevent user-select on navigation/buttons only */
    nav,
    .bottom-nav,
    .btn,
    button,
    .pagination-btn,
    .nav-link,
    .filter-section-header {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Smooth scrolling for overflow containers */
    .products-grid,
    .filters-sidebar,
    .more-menu {
        -webkit-overflow-scrolling: touch;
    }
}


/* =====================================================
   2. TYPOGRAPHY ON MOBILE
   ===================================================== */

@media (max-width: 768px) {

    h1 {
        font-size: 1.5rem;
        line-height: 1.3;
    }

    h2 {
        font-size: 1.25rem;
        line-height: 1.35;
    }

    h3 {
        font-size: 1.125rem;
        line-height: 1.4;
    }

    h4, h5, h6 {
        font-size: 1rem;
    }

    p, li, td, th, label, span {
        font-size: inherit;
        line-height: 1.5;
    }

    /* Ensure nothing is unreadably small */
    small, .text-sm, .text-xs {
        font-size: 0.8125rem;
    }
}


/* =====================================================
   3. COMPACT APP BAR (overrides .main-nav)
   ===================================================== */

@media (max-width: 768px) {

    .main-nav {
        height: 56px;
    }

    .nav-container {
        height: 56px;
        padding: 0 16px;
    }

    /* Smaller logo */
    .nav-logo-icon {
        font-size: 1.5rem;
    }

    .nav-logo-text {
        font-size: 1.125rem;
    }

    .nav-logo-tagline {
        display: none;
    }

    /* Hide desktop navigation — bottom nav replaces it */
    .nav-menu {
        display: none !important;
    }

    /* Hide old hamburger menu button */
    .mobile-menu-btn {
        display: none !important;
    }

    /* App-style logo on mobile */
    .nav-logo {
        gap: 10px;
    }

    .nav-logo-icon {
        font-size: 1.6rem !important;
        background: linear-gradient(135deg, #FEF3C7, #FDE68A);
        width: 38px;
        height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
        box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
        filter: none !important;
    }

    .nav-logo-text {
        font-size: 1.25rem !important;
        font-weight: 800;
        letter-spacing: 0.5px;
    }

    /* City badge compact */
    .city-badge {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    /* Hide language toggle on mobile — English only */
    .language-toggle {
        display: none !important;
    }

    /* Step indicator: reduce margins, horizontal scroll */
    .step-indicator {
        top: 56px;
        padding: 8px 0;
    }

    .step-indicator .container {
        padding: 0 8px !important;
        gap: 4px;
        flex-wrap: nowrap;
    }

    .steps {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 2px;
        justify-content: flex-start;
        padding: 0 4px;
        flex: 1;
    }

    .step {
        flex-shrink: 0;
        min-width: auto;
    }

    .step-label {
        font-size: 0.625rem;
        white-space: nowrap;
    }

    .step-circle {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .step-line {
        display: none !important;
    }

    /* Start Over button on mobile - compact icon-only */
    .nav-start-over {
        min-height: 36px !important;
        padding: 6px 10px !important;
        font-size: 0.7rem;
        flex-shrink: 0;
        margin-left: 4px !important;
    }

    .nav-start-over .nav-start-text {
        display: none;
    }

    .nav-start-over .nav-start-icon {
        font-size: 1.1rem;
    }

    /* ── ZERO MARGIN: Remove ALL left/right padding on mobile ── */
    .container {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .main-content .container,
    .main-content > .container,
    .step-content .container,
    .hero .container,
    .header .container,
    .page-hero .container {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .main-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Force ALL step content edge-to-edge */
    .step-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .step-content > * {
        margin-left: 0;
        margin-right: 0;
    }

    /* Hero section: edge-to-edge */
    .header {
        padding: 8px 0;
    }

    .header-content {
        padding: 0;
    }

    .hero {
        padding: 16px 0;
    }

    .hero-title {
        font-size: 1.25rem !important;
    }

    .hero-subtitle {
        font-size: 0.8125rem;
    }

    /* Feature pills: horizontal scroll, edge-to-edge */
    .feature-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        padding: 0 0 4px;
    }

    .feature-pill {
        flex-shrink: 0;
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    /* ── CITY SELECTOR: full width, edge-to-edge ── */
    .city-selector-section,
    .city-selector-wrapper {
        padding: 0 !important;
    }

    .city-search-input {
        border-radius: 10px;
    }

    /* Province tabs: wrap into rows, all visible & tappable */
    .province-tabs {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
        gap: 8px;
        padding: 0 0 8px;
        overflow: visible !important;
        position: relative;
        z-index: 10;
    }

    .province-tab {
        flex-shrink: 0;
        font-size: 0.875rem;
        padding: 10px 16px;
        white-space: nowrap;
        min-height: 40px !important;
        height: auto !important;
        border-radius: 20px;
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
        pointer-events: auto !important;
        touch-action: manipulation;
        position: relative;
        z-index: 11;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }

    /* City grid: single column full width, more visible */
    .city-grid {
        grid-template-columns: 1fr !important;
        gap: 8px;
        padding: 0;
        max-height: 50vh;
    }

    .city-card {
        padding: 14px 16px;
        border-radius: 10px;
        margin: 0;
    }

    .city-card-name {
        font-size: 0.9375rem;
        font-weight: 600;
    }

    .city-card-icon {
        font-size: 1.5rem;
    }

    /* Solar potential preview: edge-to-edge */
    .solar-potential-preview {
        padding: 8px 0;
        margin: 0;
    }

    .solar-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }

    /* Selected city display */
    .selected-city-display {
        padding: 8px 0;
    }

    /* Step content needs bottom padding for bottom nav */
    .step-content {
        padding-bottom: 80px;
    }

    /* City continue button: full width, prominent */
    .city-continue-section {
        padding: 8px 0 16px;
    }

    .btn-city-continue {
        width: 100%;
        min-height: 52px;
        font-size: 1rem;
        border-radius: 12px;
    }

    /* ── APPLIANCES: edge-to-edge ── */
    .appliance-selector-wrapper {
        padding: 0 !important;
    }

    .appliance-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
        padding: 0;
    }

    .appliance-card {
        padding: 10px 8px;
        font-size: 0.8125rem;
    }

    .appliance-card .appliance-icon {
        font-size: 1.5rem;
    }

    .appliance-card .appliance-name {
        font-size: 0.8125rem;
    }

    /* Quick presets */
    .quick-presets {
        padding: 0 0 8px;
        gap: 6px;
    }

    /* Category filters */
    .category-filters {
        padding: 0 0 8px;
    }

    /* Selected appliances panel */
    .selected-appliances {
        padding: 8px 0;
        margin: 0;
    }

    /* ── REVIEW LOAD & RECOMMENDATIONS: edge-to-edge ── */
    .load-review-section,
    .recommendations-section,
    .configurator-section {
        padding: 0 !important;
    }

    /* ── FAB WIDGETS: push ALL above bottom nav (64px + 16px gap = 80px) ── */
    .fab-widget {
        bottom: 80px !important;
        right: 16px !important;
    }

    #compare-fab {
        bottom: 80px !important;
        right: 16px !important;
    }

    #compare-panel {
        bottom: 150px !important;
        right: 12px !important;
        left: 12px !important;
        width: auto !important;
    }

    .comparison-widget {
        bottom: 80px !important;
    }

    /* Category nav FAB for recommendations */
    .fab-cat-nav {
        bottom: 80px !important;
    }
}


/* =====================================================
   4. BOTTOM NAVIGATION BAR
   ===================================================== */

/* Base styles (hidden on desktop by default) */
.bottom-nav {
    display: none;
}

@media (max-width: 768px) {

    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        background: var(--white);
        border-top: 1px solid var(--slate-200);
        box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.08);
        z-index: 10000;
        align-items: center;
        justify-content: space-around;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    /* Individual nav item */
    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        height: 100%;
        text-decoration: none;
        color: var(--slate-500);
        font-size: 0.625rem;
        font-weight: 500;
        gap: 2px;
        position: relative;
        overflow: hidden;
        transition: color 0.2s ease;
        cursor: pointer;
        background: none;
        border: none;
        padding: 0;
    }

    .bottom-nav-item .bottom-nav-icon {
        font-size: 1.25rem;
        line-height: 1;
        transition: transform 0.2s ease;
    }

    .bottom-nav-item .bottom-nav-label {
        font-size: 0.625rem;
        letter-spacing: 0.2px;
        line-height: 1;
        margin-top: 2px;
    }

    /* Active state */
    .bottom-nav-item.active {
        color: var(--primary-600);
    }

    .bottom-nav-item.active .bottom-nav-icon {
        transform: scale(1.1);
    }

    /* Tap bounce animation */
    .bottom-nav-item:active {
        animation: bottomNavBounce 0.25s ease;
    }

    /* Ripple effect via ::after */
    .bottom-nav-item::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: var(--primary-200);
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
        pointer-events: none;
    }

    .bottom-nav-item:active::after {
        animation: rippleEffect 0.5s ease-out;
    }
}


/* =====================================================
   5. MORE MENU SHEET
   ===================================================== */

/* Hidden by default */
.more-menu,
.more-menu-overlay {
    display: none;
}

@media (max-width: 768px) {

    /* Dark backdrop */
    .more-menu-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 9998;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .more-menu-overlay.active {
        display: block;
        opacity: 1;
    }

    /* Slide-up sheet */
    .more-menu {
        display: none;
        position: fixed;
        bottom: 64px;
        left: 0;
        right: 0;
        background: var(--white);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.12);
        z-index: 9999;
        padding: 8px 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .more-menu.active {
        display: block;
        transform: translateY(0);
        animation: slideUpSheet 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Drag handle indicator */
    .more-menu-handle {
        width: 36px;
        height: 4px;
        background: var(--slate-300);
        border-radius: 2px;
        margin: 8px auto 12px;
    }

    /* Menu links */
    .more-menu-item {
        display: flex;
        align-items: center;
        gap: 14px;
        height: 52px;
        padding: 0 20px;
        color: var(--slate-700);
        text-decoration: none;
        font-size: 0.9375rem;
        font-weight: 500;
        transition: background 0.15s ease;
        position: relative;
        overflow: hidden;
    }

    .more-menu-item:active {
        background: var(--slate-100);
    }

    .more-menu-item .more-menu-icon {
        font-size: 1.25rem;
        width: 24px;
        text-align: center;
        color: var(--slate-500);
    }

    /* Ripple on more-menu links */
    .more-menu-item::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 100%;
        height: 100%;
        border-radius: 0;
        background: var(--primary-100);
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
        pointer-events: none;
    }

    .more-menu-item:active::after {
        animation: rippleEffect 0.5s ease-out;
    }
}


/* =====================================================
   6. TOUCH-FRIENDLY IMPROVEMENTS
   ===================================================== */

@media (max-width: 768px) {

    /* Buttons: minimum 48px height (Android guideline) */
    button,
    .btn,
    input[type="submit"],
    input[type="button"],
    .pagination-btn {
        min-height: 48px;
        padding-left: 16px;
        padding-right: 16px;
    }

    /* Cards: proper spacing and radius */
    .card,
    .product-card,
    .filter-section,
    .contact-card,
    .stat-card {
        border-radius: 12px;
        padding: 16px;
    }

    /* Form inputs: 48px height, 16px font to prevent iOS zoom */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="search"],
    input[type="password"],
    input[type="url"],
    textarea,
    select,
    .filter-input,
    .filter-select {
        min-height: 48px;
        font-size: 16px;
        padding: 12px 14px;
        border-radius: 10px;
    }

    textarea {
        min-height: 96px;
    }

    /* Links and clickables: 44x44 minimum touch target */
    a,
    .nav-link,
    .filter-label,
    [role="button"] {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Fix inline links to not break layout */
    p a,
    li a,
    td a,
    span a {
        min-height: auto;
        display: inline;
    }
}


/* =====================================================
   7. HERO SECTIONS ON MOBILE
   ===================================================== */

@media (max-width: 768px) {

    .page-hero {
        padding: 24px 0;
    }

    .page-hero h1 {
        font-size: 1.5rem;
        margin-bottom: 6px;
    }

    .page-hero p {
        font-size: 0.875rem;
    }

    /* Remove decorative pseudo-element to save space */
    .page-hero::before {
        display: none;
    }

    .page-hero .breadcrumb {
        font-size: 0.75rem;
        margin-bottom: 10px;
    }
}


/* =====================================================
   8. PRODUCT CARDS ON MOBILE
   ===================================================== */

@media (max-width: 768px) {

    /* Products container: single column, edge-to-edge */
    .products-container {
        grid-template-columns: 1fr;
        padding: 8px 0 80px !important;
        gap: 12px;
    }

    /* Products grid: single column, tight gaps */
    .products-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Product card: full width, compact */
    .product-card {
        border-radius: 12px;
        overflow: hidden;
    }

    /* Remove hover-only effects on mobile */
    .product-card::before {
        display: none;
    }

    /* Card body tighter padding */
    .product-card-body {
        padding: 14px 16px 16px;
    }

    /* Product name: slightly smaller */
    .product-card-body .product-name {
        font-size: 1rem;
        margin-bottom: 8px;
    }

    /* Spec pills: 2-column grid */
    .product-card-body .product-specs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    /* Price prominent */
    .product-price {
        font-size: 1.25rem;
        font-weight: 700;
    }

    /* CTA button full width */
    .product-card-body .product-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .product-card-body .product-actions .btn,
    .product-card-body .product-actions a {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    /* Touch feedback on product cards */
    .product-card:active {
        transform: scale(0.98);
        transition: transform 0.15s ease;
    }

    /* Prevent horizontal scroll */
    .products-grid {
        overflow-x: hidden;
    }
}


/* =====================================================
   9. RESULTS HEADER ON MOBILE
   ===================================================== */

@media (max-width: 768px) {

    .results-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 8px 0;
    }

    .results-header select,
    .results-header .sort-select {
        width: 100%;
    }
}


/* =====================================================
   10. PAGINATION ON MOBILE
   ===================================================== */

@media (max-width: 768px) {

    .pagination {
        overflow-x: auto;
        justify-content: flex-start;
        gap: 6px;
        padding: 8px 0;
        -webkit-overflow-scrolling: touch;
    }

    .pagination-btn {
        min-width: 40px;
        min-height: 40px;
        font-size: 0.875rem;
        flex-shrink: 0;
        padding: 8px 12px;
    }
}


/* =====================================================
   11. FILTER SIDEBAR — Handled by products.css
   No styles here to avoid specificity conflicts.
   ===================================================== */


/* =====================================================
   12. FOOTER ON MOBILE
   ===================================================== */

@media (max-width: 768px) {

    footer,
    .footer,
    .site-footer {
        padding-bottom: 80px !important; /* Space for bottom nav */
        font-size: 0.875rem;
    }

    .bottom-nav-spacer {
        height: 64px;
        display: block;
    }

    /* Footer grid: single column */
    .footer .footer-grid,
    .footer .footer-columns {
        grid-template-columns: 1fr;
        gap: 0;
    }

    /* Collapsible accordion-style sections */
    .footer-section,
    .footer-col {
        border-bottom: 1px solid var(--slate-200);
        padding: 12px 0;
    }

    .footer-section:last-child,
    .footer-col:last-child {
        border-bottom: none;
    }

    .footer-section h4,
    .footer-col h4 {
        font-size: 0.9375rem;
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    /* Compact footer text */
    .footer p,
    .footer a,
    .footer li {
        font-size: 0.8125rem;
        line-height: 1.6;
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 8px;
        padding-top: 12px;
    }
}


/* =====================================================
   13. PAGE-SPECIFIC MOBILE FIXES
   ===================================================== */

@media (max-width: 768px) {

    /* --- Admin settings grid --- */
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* --- Contact page --- */
    .contact-card,
    .contact-info {
        flex-direction: column;
    }

    .contact-card {
        padding: 16px;
    }

    /* Map container */
    .map-container iframe {
        height: 250px;
        border-radius: 12px;
    }

    /* --- About page sections --- */
    .about-hero {
        padding: 40px 0 !important;
    }

    .about-hero h1 {
        font-size: 1.75rem !important;
    }

    .about-content {
        padding: 24px 0 !important;
    }

    .about-content,
    .about-section,
    .about-grid,
    .about-team,
    .about-features {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .about-section {
        padding: 16px 0;
    }

    .founder-card {
        grid-template-columns: 1fr !important;
        padding: 20px 0 !important;
    }

    .features-grid {
        grid-template-columns: 1fr !important;
    }

    .cta-section {
        border-radius: 0 !important;
        margin: 24px 0 !important;
        padding: 40px 0 !important;
    }

    /* --- Contact page hero --- */
    .contact-hero {
        padding: 40px 0 !important;
    }

    .contact-hero h1 {
        font-size: 1.75rem !important;
    }

    .contact-content {
        padding: 24px 0 !important;
    }

    .contact-grid {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
    }

    /* --- Product detail page --- */
    .product-detail-container {
        padding: 16px 0 80px !important;
    }

    .product-detail-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* --- Compare page --- */
    .compare-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- Generic containers: edge-to-edge --- */
    .container {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* --- Section spacing tighter --- */
    section,
    .section {
        padding-top: 24px;
        padding-bottom: 24px;
    }
}


/* =====================================================
   14. ANIMATIONS & TRANSITIONS
   ===================================================== */

@media (max-width: 768px) {

    /* Smooth 300ms transitions on common elements */
    .product-card,
    .card,
    .btn,
    .bottom-nav-item,
    .filter-section,
    .more-menu-item {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Cards: subtle press feedback */
    .card:active,
    .stat-card:active {
        transform: scale(0.98);
    }

    /* Prevent pull-to-refresh on inner scrollables */
    .products-grid,
    .filters-sidebar,
    .more-menu,
    .compare-table-wrapper {
        overscroll-behavior: contain;
    }

    /* Subtle entrance for cards in a grid */
    .products-grid .product-card {
        animation: mobilePageFadeIn 0.35s ease-out both;
    }

    .products-grid .product-card:nth-child(1)  { animation-delay: 0.03s; }
    .products-grid .product-card:nth-child(2)  { animation-delay: 0.06s; }
    .products-grid .product-card:nth-child(3)  { animation-delay: 0.09s; }
    .products-grid .product-card:nth-child(4)  { animation-delay: 0.12s; }
    .products-grid .product-card:nth-child(5)  { animation-delay: 0.15s; }
    .products-grid .product-card:nth-child(6)  { animation-delay: 0.18s; }
}


/* =====================================================
   15. FORM ENHANCEMENTS ON MOBILE
   ===================================================== */

@media (max-width: 768px) {

    /* Form groups stack properly */
    .form-group,
    .form-row {
        flex-direction: column;
        gap: 12px;
    }

    .form-row > * {
        width: 100%;
    }

    /* Search inputs */
    .search-input,
    .search-bar input {
        height: 48px;
        font-size: 16px;
        border-radius: 12px;
        padding: 12px 16px;
    }

    /* Checkbox / radio larger touch targets */
    input[type="checkbox"],
    input[type="radio"] {
        width: 22px;
        height: 22px;
        margin-right: 10px;
    }

    .filter-label {
        padding: 10px 0;
        gap: 10px;
    }
}


/* =====================================================
   16. MODALS & DIALOGS ON MOBILE
   ===================================================== */

@media (max-width: 768px) {

    .modal,
    .dialog {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0;
        border-radius: 16px 16px 0 0;
        bottom: 0;
        top: auto;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-content,
    .dialog-content {
        padding: 20px 16px;
    }

    .modal-header,
    .dialog-header {
        padding: 16px;
    }
}


/* =====================================================
   17. TABLES ON MOBILE
   ===================================================== */

@media (max-width: 768px) {

    .table-responsive,
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }

    table {
        min-width: 500px;
    }

    th, td {
        padding: 10px 12px;
        font-size: 0.8125rem;
        white-space: nowrap;
    }
}


/* =====================================================
   18. NOTIFICATION / TOAST STYLES
   ===================================================== */

@media (max-width: 768px) {

    .toast,
    .notification,
    .alert-popup {
        left: 12px;
        right: 12px;
        bottom: 80px; /* Above bottom nav */
        width: auto;
        border-radius: 12px;
    }
}


/* =====================================================
   19. UTILITY SPACING OVERRIDES
   ===================================================== */

@media (max-width: 768px) {

    /* Tighter section gaps */
    .gap-lg { gap: 16px; }
    .gap-xl { gap: 20px; }
    .gap-2xl { gap: 24px; }

    /* No horizontal overflow anywhere */
    main,
    .main-content,
    .page-content {
        overflow-x: hidden;
    }

    /* Image containers responsive */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Badges compact */
    .badge,
    .tag,
    .chip {
        font-size: 0.6875rem;
        padding: 4px 8px;
        border-radius: 6px;
    }
}


/* =====================================================
   20. LANDSCAPE MOBILE ADJUSTMENTS
   ===================================================== */

@media (max-width: 768px) and (orientation: landscape) {

    /* Shorter bottom nav in landscape */
    .bottom-nav {
        height: 48px;
    }

    .bottom-nav-item .bottom-nav-icon {
        font-size: 1rem;
    }

    .bottom-nav-item .bottom-nav-label {
        font-size: 0.5625rem;
    }

    /* Compact app bar in landscape */
    .main-nav,
    .nav-container {
        height: 48px;
    }

    body {
        padding-top: 48px;
    }

    /* Shorter hero in landscape */
    .page-hero {
        padding: 16px;
    }

    .page-hero h1 {
        font-size: 1.25rem;
    }

    /* Filter sheet shorter */
    .filters-sidebar {
        height: 75vh;
        max-height: 75vh;
    }
}


/* =====================================================
   21. DARK MODE SUPPORT (if using prefers-color-scheme)
   ===================================================== */

@media (max-width: 768px) and (prefers-color-scheme: dark) {

    .bottom-nav {
        background: var(--slate-900);
        border-top-color: var(--slate-700);
    }

    .bottom-nav-item {
        color: var(--slate-400);
    }

    .bottom-nav-item.active {
        color: var(--primary-300);
    }

    .more-menu {
        background: var(--slate-900);
    }

    .more-menu-handle {
        background: var(--slate-600);
    }

    .more-menu-item {
        color: var(--slate-200);
    }

    .more-menu-item:active {
        background: var(--slate-800);
    }

    .filters-sidebar {
        background: var(--slate-900);
    }

    .filter-header {
        background: var(--slate-900);
        border-bottom-color: var(--slate-700);
    }
}


/* =====================================================
   22. SMALL PHONE ADJUSTMENTS (≤360px)
   ===================================================== */

@media (max-width: 360px) {

    body {
        font-size: 14px;
    }

    .nav-logo-text {
        font-size: 1rem;
    }

    .bottom-nav {
        height: 56px;
    }

    .bottom-nav-item .bottom-nav-icon {
        font-size: 1.125rem;
    }

    .bottom-nav-item .bottom-nav-label {
        font-size: 0.5625rem;
    }

    .page-hero {
        padding: 20px 0;
    }

    .page-hero h1 {
        font-size: 1.25rem;
    }

    .products-container {
        padding: 8px 0 80px !important;
    }

    .product-card-body {
        padding: 12px;
    }

    /* Spec pills single column on tiny screens */
    .product-card-body .product-specs {
        grid-template-columns: 1fr;
    }

    .container {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}


/* =====================================================
   23. AD SLOTS
   ===================================================== */

/* Desktop: center ads, subtle background */
.algopk-ad-slot {
    text-align: center;
    overflow: hidden;
    margin: 16px auto;
    max-width: 100%;
}

.algopk-ad-slot img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: inline-block;
}

.algopk-ad-slot.ad-slot-header {
    margin: 8px auto 0;
    padding: 0 16px;
}

.algopk-ad-slot.ad-slot-footer {
    margin: 0 auto 16px;
    padding: 0 16px;
}

.algopk-ad-slot.ad-slot-sidebar {
    margin: 16px auto;
}

.algopk-ad-slot.ad-slot-between {
    margin: 24px auto;
}

/* Inline ads between products */
.algopk-ad-inline {
    text-align: center;
    margin: 12px 0;
    grid-column: 1 / -1;
}

.algopk-ad-inline img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

@media (max-width: 768px) {

    .algopk-ad-slot {
        margin: 8px auto;
        padding: 0 8px;
    }

    .algopk-ad-slot.ad-slot-header {
        margin: 4px auto 0;
    }

    .algopk-ad-slot img {
        border-radius: 6px;
    }

    .algopk-ad-inline {
        margin: 8px 0;
    }
}
