/* ================================================================
   MOBILE BROWSER OPTIMIZATION - Khonza WebApp
   Comprehensive mobile-first responsive enhancements
   ================================================================ */

/* ================================================================
   MOBILE BOTTOM NAVIGATION BAR
   Fixed bottom nav for quick access on mobile devices
   ================================================================ */

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--vaal-secondary) 0%, #1a4d38 100%);
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    padding: 0.4rem 0;
    padding-bottom: calc(0.4rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.15);
    border-top: 2px solid var(--vaal-primary);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
    padding: 0.35rem 0.5rem;
    min-width: 56px;
    min-height: 48px;
    border-radius: 8px;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    border: none;
    background: none;
    cursor: pointer;
}

.mobile-nav-item i {
    font-size: 1.2rem;
    margin-bottom: 0.15rem;
    transition: transform 0.2s ease;
}

.mobile-nav-item:hover,
.mobile-nav-item:focus,
.mobile-nav-item.active {
    color: var(--vaal-accent);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.1);
}

.mobile-nav-item.active i {
    transform: scale(1.15);
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
    }

    /* Add padding to body so content isn't hidden behind bottom nav */
    body {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    /* Adjust footer margin for bottom nav */
    footer {
        margin-bottom: 0 !important;
        padding-bottom: calc(1rem + 64px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* ================================================================
   TOUCH-FRIENDLY TARGETS
   Minimum 44x44px tap targets per Apple HIG / WCAG 2.5.5
   ================================================================ */

@media (max-width: 768px) {
    /* Ensure all interactive elements meet minimum size */
    a, button, .btn, .nav-link,
    input[type="submit"], input[type="button"],
    .form-check-label, .dropdown-item {
        min-height: 44px;
    }

    .btn {
        padding: 0.625rem 1rem;
        font-size: 1rem;
    }

    .btn-sm {
        padding: 0.5rem 0.875rem;
        font-size: 0.9rem;
        min-height: 40px;
    }

    .btn-lg {
        padding: 0.875rem 1.5rem;
        font-size: 1.1rem;
    }

    /* Larger dropdown items */
    .dropdown-item {
        padding: 0.75rem 1.25rem;
    }

    /* Larger form check inputs */
    .form-check-input {
        width: 1.25em;
        height: 1.25em;
        margin-top: 0.1em;
    }

    .form-check-label {
        padding-left: 0.25rem;
        display: flex;
        align-items: center;
    }
}

/* ================================================================
   MOBILE FORM OPTIMIZATIONS
   Better inputs for touch, proper font sizes to prevent zoom
   ================================================================ */

@media (max-width: 768px) {
    /* Prevent iOS zoom on focus: inputs must be >= 16px */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"],
    textarea,
    select,
    .form-control,
    .form-select {
        font-size: 16px !important;
        padding: 0.75rem 1rem;
        border-radius: 8px;
    }

    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.375rem;
    }

    /* Better textarea sizing */
    textarea.form-control {
        min-height: 100px;
    }

    /* Stacked form groups on mobile */
    .input-group {
        flex-wrap: wrap;
    }

    .input-group .form-control {
        border-radius: 8px !important;
        margin-bottom: 0.5rem;
    }

    .input-group .btn {
        border-radius: 8px !important;
        width: 100%;
    }

    /* Search bar in hero - stack vertically */
    .hero-content .input-group {
        flex-direction: column;
        max-width: 100% !important;
    }

    .hero-content .input-group .form-control {
        border-radius: 8px !important;
        width: 100%;
    }

    .hero-content .input-group .btn {
        border-radius: 8px !important;
        width: 100%;
        margin-top: 0.5rem;
    }

    /* Mobile-friendly form cards */
    .card .card-body form .mb-3 {
        margin-bottom: 1rem !important;
    }
}

/* ================================================================
   HERO SECTION MOBILE OPTIMIZATION
   Fix parallax issues, better sizing, readable text
   ================================================================ */

@media (max-width: 768px) {
    .hero-section {
        height: auto !important;
        min-height: 350px;
        /* Disable fixed attachment - broken on iOS/mobile */
        background-attachment: scroll !important;
        margin-bottom: 1.5rem;
        padding: 2rem 0;
    }

    .hero-content {
        padding: 1.5rem 1rem;
        max-width: 100%;
    }

    .hero-content h1 {
        font-size: 1.6rem !important;
        line-height: 1.3;
        margin-bottom: 0.75rem;
    }

    .hero-content p {
        font-size: 0.95rem !important;
        margin-bottom: 1rem;
        line-height: 1.5;
    }

    /* Stack CTA buttons vertically */
    .hero-content .btn-lg {
        display: block;
        width: 100%;
        margin: 0 auto;
        max-width: 300px;
    }

    /* Hide decorative SVGs on small screens */
    .hero-bridge-silhouette {
        display: none;
    }
}

@media (max-width: 400px) {
    .hero-section {
        min-height: 300px;
    }

    .hero-content h1 {
        font-size: 1.4rem !important;
    }

    .hero-content p {
        font-size: 0.9rem !important;
    }
}

/* ================================================================
   CARD LAYOUTS - MOBILE GRID
   Better card display on small screens
   ================================================================ */

@media (max-width: 768px) {
    /* Service cards in a 2-column grid on tablets */
    .row.g-4 > [class*="col-md-4"] {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Category cards: 2-column grid */
    .row.g-4 > .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .card {
        margin-bottom: 0.75rem;
    }

    .card:hover {
        transform: none; /* Disable hover lift on touch devices */
    }

    .service-card:hover {
        transform: none;
    }

    .category-card:hover {
        transform: none;
    }

    /* Smaller card padding */
    .card-body {
        padding: 1rem;
    }

    .service-card-body {
        padding: 1rem;
    }

    .service-card-header {
        padding: 0.875rem 1rem;
    }

    /* Adjust service card image height */
    .service-card .card-img-top,
    .service-card [class*="card-img-top"] {
        height: 160px !important;
    }

    /* Category card icon sizing */
    .category-card .card-body [style*="width: 80px"] {
        width: 60px !important;
        height: 60px !important;
    }

    .category-card .card-title {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    /* Single column on very small phones */
    .row.g-4 > [class*="col-md-4"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Keep category cards in 2-column */
    .row.g-4 > .col-md-3.col-sm-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .row.g-4 {
        --bs-gutter-x: 0.75rem;
        --bs-gutter-y: 0.75rem;
    }
}

/* ================================================================
   TABLE RESPONSIVENESS
   Horizontal scroll wrapper for tables on mobile
   ================================================================ */

@media (max-width: 768px) {
    .table-responsive-wrapper,
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }

    .table {
        min-width: 600px;
    }

    .table thead th {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .table tbody td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }

    /* Stack table on very small screens */
    .table-mobile-stack thead {
        display: none;
    }

    .table-mobile-stack tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--vaal-border);
        border-radius: 8px;
        padding: 0.75rem;
        background: white;
    }

    .table-mobile-stack tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px solid var(--vaal-border);
    }

    .table-mobile-stack tbody td:last-child {
        border-bottom: none;
    }

    .table-mobile-stack tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--vaal-text-dark);
        flex: 0 0 40%;
    }
}

/* ================================================================
   SIDEBAR NAVIGATION - MOBILE ENHANCEMENTS
   Smoother transitions, swipe support, better touch targets
   ================================================================ */

@media (max-width: 768px) {
    .sidebar-nav {
        width: 85%;
        max-width: 320px;
        will-change: transform;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-nav .nav-link {
        padding: 1rem 1.25rem;
        font-size: 1rem;
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    .sidebar-nav .nav-link i {
        font-size: 1.15rem;
        min-width: 28px;
    }

    .sidebar-header {
        padding: 1.25rem;
    }

    .sidebar-close {
        font-size: 1.75rem;
        padding: 0.5rem;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Smooth backdrop animation */
    .sidebar-backdrop {
        transition: background-color 0.3s ease;
    }
}

/* ================================================================
   TOP BRAND BAR - MOBILE
   ================================================================ */

@media (max-width: 768px) {
    .top-brand-bar {
        padding: 0.5rem 0.75rem;
        position: sticky;
        top: 0;
        z-index: 998;
    }

    .brand-logo {
        font-size: 1.25rem;
    }

    .menu-toggle {
        font-size: 1.35rem;
        padding: 0.5rem;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ================================================================
   SECTION HEADERS - MOBILE
   ================================================================ */

@media (max-width: 768px) {
    .section-header {
        margin-bottom: 1.5rem;
        padding: 1rem 0;
    }

    .section-header h2 {
        font-size: 1.5rem;
    }

    .section-header h2::after {
        width: 60px;
        height: 3px;
    }

    .section-header p {
        font-size: 0.9rem;
        margin-top: 1rem;
    }

    .container-section {
        padding: 1.5rem 0;
    }
}

/* ================================================================
   FOOTER - MOBILE OPTIMIZATION
   ================================================================ */

@media (max-width: 768px) {
    footer {
        padding: 2rem 0 1rem;
        margin-top: 2rem;
    }

    footer .row > div {
        margin-bottom: 1.5rem !important;
        text-align: center;
    }

    footer h5 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    footer p {
        font-size: 0.8rem;
    }

    footer .list-unstyled li {
        padding: 0.375rem 0;
    }

    footer .list-unstyled a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .footer-bottom {
        font-size: 0.75rem;
        padding-top: 1rem;
        margin-top: 1rem;
    }

    /* Hide decorative SVGs in footer on mobile */
    .footer-local-badge svg {
        display: none;
    }

    .footer-local-badge span {
        font-size: 0.85rem;
    }

    /* Social icons - larger touch targets */
    footer .fab {
        font-size: 1.5rem !important;
        padding: 0.5rem;
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* ================================================================
   MODAL - MOBILE FULL SCREEN
   ================================================================ */

@media (max-width: 576px) {
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        min-height: 100vh;
    }

    .modal-content {
        border-radius: 0;
        min-height: 100vh;
    }

    .modal-body {
        padding: 1.25rem;
    }

    .modal-footer {
        padding: 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }
}

/* ================================================================
   PAGINATION - MOBILE
   ================================================================ */

@media (max-width: 576px) {
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
    }

    .page-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        min-width: 40px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ================================================================
   BADGES - MOBILE SIZING
   ================================================================ */

@media (max-width: 576px) {
    .badge {
        font-size: 0.7rem;
        padding: 0.35rem 0.65rem;
    }
}

/* ================================================================
   ALERTS - MOBILE
   ================================================================ */

@media (max-width: 576px) {
    .alert {
        padding: 0.75rem;
        font-size: 0.875rem;
        margin-bottom: 0.75rem;
        border-radius: 0;
        margin-left: -0.75rem;
        margin-right: -0.75rem;
    }
}

/* ================================================================
   CONTAINER PADDING - MOBILE
   ================================================================ */

@media (max-width: 768px) {
    .container,
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .container-fluid.my-5 {
        margin-top: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }
}

/* ================================================================
   SERVICES BROWSE PAGE - MOBILE FILTER COLLAPSE
   ================================================================ */

@media (max-width: 991px) {
    /* Make filters collapsible on tablet/mobile */
    .col-lg-3 .card.sticky-top {
        position: relative !important;
        top: auto !important;
    }
}

@media (max-width: 768px) {
    .col-lg-3 .card .card-body {
        max-height: none !important;
    }

    /* Filter card - initially collapsed appearance */
    .col-lg-3 .card .card-header {
        cursor: pointer;
        position: relative;
    }

    .col-lg-3 .card .card-header::after {
        content: '\f078';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.8rem;
    }
}

/* ================================================================
   "WHY CHOOSE" SECTION - MOBILE
   ================================================================ */

@media (max-width: 768px) {
    .row.g-4 > .col-md-4.text-center {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .col-md-4.text-center [style*="width: 70px"] {
        width: 56px !important;
        height: 56px !important;
    }

    .col-md-4.text-center h5 {
        font-size: 1.1rem;
        margin-bottom: 0.375rem;
    }

    .col-md-4.text-center p {
        font-size: 0.875rem;
        max-width: 280px;
        margin-left: auto;
        margin-right: auto;
    }

    /* Hide decorative mini SVGs on mobile */
    .col-md-4.text-center svg.local-icon {
        display: none;
    }
}

/* ================================================================
   BREADCRUMBS - MOBILE
   ================================================================ */

@media (max-width: 576px) {
    .breadcrumb {
        font-size: 0.8rem;
        padding: 0.5rem 0;
        flex-wrap: nowrap;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .breadcrumb-item + .breadcrumb-item::before {
        padding: 0 0.25rem;
    }
}

/* ================================================================
   REVIEW ITEMS - MOBILE
   ================================================================ */

@media (max-width: 576px) {
    .review-item {
        padding: 1rem;
        border-left-width: 3px;
    }

    .review-author {
        font-size: 0.9rem;
    }

    .review-text {
        font-size: 0.85rem;
    }

    .review-date {
        font-size: 0.8rem;
    }
}

/* ================================================================
   WHATSAPP & CTA BUTTONS - MOBILE FLOATING
   ================================================================ */

@media (max-width: 768px) {
    .btn-whatsapp {
        font-size: 0.9rem;
        padding: 0.625rem 1rem;
    }

    /* Full-width action buttons on mobile */
    .d-flex.justify-content-between .btn,
    .d-flex.gap-2 .btn {
        flex: 1;
    }
}

/* ================================================================
   IMAGES - MOBILE RESPONSIVE
   ================================================================ */

img {
    max-width: 100%;
    height: auto;
}

@media (max-width: 576px) {
    .card-img-top {
        height: 180px !important;
        object-fit: cover;
    }
}

/* ================================================================
   LOADING STATES - MOBILE
   ================================================================ */

@media (max-width: 768px) {
    .spinner-border {
        width: 2rem;
        height: 2rem;
    }
}

/* ================================================================
   SMOOTH SCROLLING & PERFORMANCE
   ================================================================ */

/* Optimise scroll performance on mobile */
.main-content {
    -webkit-overflow-scrolling: touch;
}

/* Prevent horizontal scroll */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Better scrollbar for mobile webkit */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }

    ::-webkit-scrollbar-track {
        background: transparent;
    }

    ::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.15);
        border-radius: 4px;
    }
}

/* ================================================================
   SAFE AREA INSETS (iPhone X+ notch/home indicator)
   ================================================================ */

@supports (padding: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: calc(0.4rem + env(safe-area-inset-bottom));
    }

    body {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .top-brand-bar {
        padding-top: env(safe-area-inset-top);
    }
}

/* ================================================================
   LANDSCAPE MODE ADJUSTMENTS
   ================================================================ */

@media (max-width: 768px) and (orientation: landscape) {
    .hero-section {
        min-height: 250px;
    }

    .hero-content h1 {
        font-size: 1.3rem !important;
    }

    .hero-content p {
        font-size: 0.85rem !important;
        margin-bottom: 0.5rem;
    }

    .mobile-bottom-nav {
        padding: 0.25rem 0;
    }

    .mobile-nav-item {
        min-height: 40px;
    }

    .mobile-nav-item i {
        font-size: 1rem;
    }

    .mobile-nav-item span {
        font-size: 0.6rem;
    }
}

/* ================================================================
   DARK MODE MOBILE SUPPORT
   ================================================================ */

@media (prefers-color-scheme: dark) and (max-width: 768px) {
    .mobile-bottom-nav {
        background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
        border-top-color: var(--vaal-primary);
    }

    .mobile-nav-item {
        color: rgba(255, 255, 255, 0.6);
    }

    .mobile-nav-item.active,
    .mobile-nav-item:hover {
        color: var(--vaal-accent);
    }
}

/* ================================================================
   PRINT - HIDE MOBILE ELEMENTS
   ================================================================ */

@media print {
    .mobile-bottom-nav {
        display: none !important;
    }
}

/* ================================================================
   PULL-TO-REFRESH INDICATOR (styled but JS-powered)
   ================================================================ */

.pull-to-refresh {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--vaal-primary), var(--vaal-accent), var(--vaal-secondary));
    z-index: 9999;
    animation: pullRefreshSlide 1.5s ease-in-out infinite;
}

.pull-to-refresh.active {
    display: block;
}

@keyframes pullRefreshSlide {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0); }
    100% { transform: translateX(100%); }
}

/* ================================================================
   SKELETON LOADING PLACEHOLDERS
   ================================================================ */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5rem;
    width: 100%;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-card {
    height: 200px;
    border-radius: 10px;
}

@keyframes skeletonShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ================================================================
   SWIPE INDICATOR (visual hint for swipeable sidebar)
   ================================================================ */

@media (max-width: 768px) {
    .swipe-hint {
        position: fixed;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 4px;
        height: 60px;
        background: var(--vaal-primary);
        border-radius: 0 4px 4px 0;
        opacity: 0;
        transition: opacity 0.3s ease;
        z-index: 997;
        pointer-events: none;
    }

    .swipe-hint.visible {
        opacity: 0.4;
    }
}
