/**
 * COMPREHENSIVE MOBILE-FIRST RESPONSIVE STYLES
 * Global Mobistar Hardware - Complete Mobile Optimization
 * Last Updated: 2026
 */

/* ============================================
   CRITICAL BASE STYLES
   ============================================ */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    width: 100%;
    min-height: 100vh;
}

/* ============================================
   RESPONSIVE IMAGES & MEDIA
   ============================================ */
img, video, iframe, picture {
    max-width: 100%;
    height: auto;
    display: block;
}

svg {
    max-width: 100%;
    height: auto;
}

/* ============================================
   MOBILE NAVIGATION - CRITICAL FIX
   ============================================ */
@media (max-width: 1023px) {
    /* Top banner adjustments */
    .bg-\[\#FFBF00\] {
        padding: 0.5rem 1rem !important;
    }
    
    .max-w-screen-4xl {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Logo sizing */
    nav img[alt*="Logo"], 
    .svelte-1vp6alu img {
        height: 32px !important;
        max-height: 32px !important;
    }
    
    /* Hide desktop elements */
    .hidden.lg\:flex,
    .hidden.lg\:block,
    .hidden.md\:block {
        display: none !important;
    }
    
    /* Mobile menu button */
    .lg\:hidden {
        display: flex !important;
    }
    
    /* Search button mobile */
    button[aria-label="Open search"] {
        padding: 0.5rem !important;
        margin-right: 0.5rem !important;
    }
    
    /* Mobile menu toggle */
    button[aria-label="Toggle menu"] {
        padding: 0.5rem !important;
        min-width: 44px !important;
        min-height: 44px !important;
    }
}

/* ============================================
   TOUCH-FRIENDLY INTERACTIVE ELEMENTS
   ============================================ */
button, 
.btn, 
a.button, 
input[type="submit"], 
input[type="button"],
[role="button"] {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 20px;
    font-size: 16px;
    cursor: pointer;
    touch-action: manipulation;
    border: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    -webkit-user-select: none;
    user-select: none;
}

button:active, 
.btn:active,
a.button:active {
    transform: scale(0.97);
}

/* ============================================
   RESPONSIVE TYPOGRAPHY
   ============================================ */
h1 {
    font-size: clamp(1.5rem, 4vw + 1rem, 3rem);
    line-height: 1.2;
    margin: 0 0 1rem 0;
}

h2 {
    font-size: clamp(1.25rem, 3vw + 0.5rem, 2.25rem);
    line-height: 1.3;
    margin: 0 0 0.875rem 0;
}

h3 {
    font-size: clamp(1.125rem, 2.5vw + 0.25rem, 1.75rem);
    line-height: 1.4;
    margin: 0 0 0.75rem 0;
}

h4 {
    font-size: clamp(1rem, 2vw, 1.5rem);
    line-height: 1.4;
}

p {
    font-size: clamp(0.875rem, 1.5vw, 1rem);
    line-height: 1.6;
    margin: 0 0 1rem 0;
}

/* ============================================
   MOBILE HERO SECTION - CRITICAL FIX
   ============================================ */
@media (max-width: 768px) {
    .hero-container {
        min-height: 200px !important;
        height: auto !important;
    }
    
    .hero-container > div {
        height: 200px !important;
    }
    
    .hero-container img {
        object-fit: cover !important;
        width: 100% !important;
        height: 100% !important;
    }
    
    /* Hero text overlay */
    .hero-container h1 {
        font-size: 1.25rem !important;
        padding: 0 1rem !important;
    }
    
    .hero-container p {
        font-size: 0.875rem !important;
        padding: 0 1rem !important;
    }
    
    .hero-container .btn,
    .hero-container span[class*="inline-block"] {
        font-size: 0.875rem !important;
        padding: 0.5rem 1rem !important;
    }
    
    /* Hero navigation buttons */
    .hero-container button[aria-label*="slide"] {
        padding: 0.5rem !important;
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
    }
    
    .hero-container button svg {
        width: 16px !important;
        height: 16px !important;
    }
    
    /* Slide indicators */
    .hero-container button[aria-label*="Go to slide"] {
        width: 8px !important;
        height: 8px !important;
        min-width: 8px !important;
        min-height: 8px !important;
        padding: 0 !important;
    }
}

/* ============================================
   RESPONSIVE GRID SYSTEM
   ============================================ */
.grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
    width: 100%;
}

@media (min-width: 640px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
}

@media (min-width: 1024px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

@media (min-width: 1280px) {
    .grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
}

/* ============================================
   RESPONSIVE CONTAINER
   ============================================ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

@media (min-width: 640px) {
    .container {
        padding: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .container {
        padding: 2rem;
    }
}

/* ============================================
   MOBILE FORMS - PREVENT ZOOM ON IOS
   ============================================ */
input, 
textarea, 
select {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px !important; /* Prevents iOS zoom */
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background-color: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, 
textarea:focus, 
select:focus {
    outline: none;
    border-color: #064b67;
    box-shadow: 0 0 0 3px rgba(6, 75, 103, 0.1);
}

@media (max-width: 768px) {
    .form-group {
        margin-bottom: 1rem;
    }
    
    label {
        display: block;
        margin-bottom: 0.5rem;
        font-weight: 500;
        font-size: 14px;
    }
    
    form {
        width: 100%;
    }
}

/* ============================================
   MOBILE TABLES - RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
    }
    
    /* Stacked table layout */
    .responsive-table {
        display: block;
        width: 100%;
    }
    
    .responsive-table thead {
        display: none;
    }
    
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
    }
    
    .responsive-table tr {
        margin-bottom: 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 1rem;
        background: white;
    }
    
    .responsive-table td {
        text-align: right;
        padding: 0.5rem 0;
        position: relative;
        padding-left: 50%;
        border-bottom: 1px solid #f3f4f6;
    }
    
    .responsive-table td:last-child {
        border-bottom: none;
    }
    
    .responsive-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 45%;
        padding-left: 0;
        font-weight: 600;
        text-align: left;
        color: #374151;
    }
}

/* ============================================
   PRODUCT CARDS - MOBILE OPTIMIZED
   ============================================ */
.product-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
}

.product-card:active {
    transform: scale(0.98);
}

.product-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.product-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.product-card-content {
    padding: 1rem;
}

.product-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.product-card-price {
    font-size: 1.125rem;
    font-weight: 700;
    color: #064b67;
}

@media (max-width: 768px) {
    .product-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        padding: 0.5rem;
    }
}

@media (min-width: 769px) and (max-width: 1023px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

/* ============================================
   MOBILE CHECKOUT & CART
   ============================================ */
@media (max-width: 1023px) {
    .checkout-container,
    .grid.grid-cols-1.lg\:grid-cols-3 {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
    }
    
    .lg\:col-span-2 {
        width: 100% !important;
    }
    
    .cart-item {
        display: flex;
        flex-direction: row;
        gap: 1rem;
        padding: 1rem;
        border-bottom: 1px solid #e5e7eb;
        align-items: center;
    }
    
    .cart-item-image {
        width: 80px;
        height: 80px;
        flex-shrink: 0;
        border-radius: 8px;
        object-fit: cover;
    }
    
    .cart-item-details {
        flex: 1;
        min-width: 0;
    }
    
    .cart-item-title {
        font-weight: 600;
        font-size: 0.95rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-bottom: 0.25rem;
    }
    
    .cart-summary {
        position: static !important;
        width: 100% !important;
        margin-top: 1rem;
    }
    
    /* Payment methods */
    .payment-method {
        padding: 0.875rem !important;
    }
    
    .payment-method img {
        max-width: 60px !important;
    }
    
    .payment-method h3 {
        font-size: 1rem !important;
    }
    
    .payment-method p {
        font-size: 0.8rem !important;
    }
}

/* ============================================
   MOBILE MODALS & POPUPS
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 0;
}

@media (min-width: 768px) {
    .modal {
        align-items: center;
        padding: 1rem;
    }
}

.modal-content {
    background: white;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    padding: 1.5rem;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
    .modal-content {
        max-width: 600px;
        border-radius: 16px;
    }
}

@media (max-width: 768px) {
    .modal, .popup {
        padding: 0 !important;
    }
    
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
    }
}

/* ============================================
   MOBILE MENU / SIDEBAR
   ============================================ */
@media (max-width: 1023px) {
    .sidebar, 
    .filters,
    .mobile-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: white;
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 1rem;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.active, 
    .filters.active,
    .mobile-menu.open {
        left: 0;
    }
    
    .sidebar-overlay,
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        display: none;
    }
    
    .sidebar-overlay.active,
    .mobile-menu-overlay.active {
        display: block;
    }
    
    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
        border-bottom: 1px solid #e5e7eb;
        margin-bottom: 1rem;
    }
    
    .mobile-menu-items {
        padding: 0;
    }
    
    .mobile-menu-item {
        padding: 1rem;
        border-bottom: 1px solid #f3f4f6;
        font-size: 1rem;
        display: block;
        color: #374151;
        text-decoration: none;
    }
    
    .mobile-menu-item:active {
        background-color: #f9fafb;
    }
}

/* ============================================
   MOBILE SEARCH
   ============================================ */
@media (max-width: 768px) {
    .search-bar,
    section[role="search"] {
        width: 100% !important;
        padding: 0 !important;
    }
    
    .search-input,
    input[type="search"] {
        width: 100% !important;
        font-size: 16px !important;
        padding: 12px 16px !important;
    }
    
    .search-results {
        width: 100% !important;
        max-height: 60vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================
   MOBILE FOOTER
   ============================================ */
@media (max-width: 768px) {
    footer {
        padding: 2rem 1rem !important;
    }
    
    .footer-columns {
        display: flex !important;
        flex-direction: column !important;
        gap: 2rem !important;
    }
    
    .footer-column {
        width: 100% !important;
        text-align: center;
    }
}

/* ============================================
   STICKY FOOTER / BOTTOM BAR
   ============================================ */
.sticky-footer {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 1rem;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 10;
    width: 100%;
}

/* ============================================
   LOADING STATES
   ============================================ */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f4f6;
    border-top-color: #064b67;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #064b67;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1001;
    max-width: 90%;
    text-align: center;
}

/* ============================================
   MOBILE SPACING UTILITIES
   ============================================ */
@media (max-width: 768px) {
    .mobile-p-0 { padding: 0 !important; }
    .mobile-p-1 { padding: 0.5rem !important; }
    .mobile-p-2 { padding: 1rem !important; }
    .mobile-p-3 { padding: 1.5rem !important; }
    
    .mobile-m-0 { margin: 0 !important; }
    .mobile-m-1 { margin: 0.5rem !important; }
    .mobile-m-2 { margin: 1rem !important; }
    .mobile-m-3 { margin: 1.5rem !important; }
    
    .mobile-hidden { display: none !important; }
    .mobile-visible { display: block !important; }
    
    .mobile-text-center { text-align: center !important; }
    .mobile-text-left { text-align: left !important; }
    .mobile-text-right { text-align: right !important; }
    
    .mobile-full-width { width: 100% !important; }
}

/* ============================================
   MOBILE FLEXBOX UTILITIES
   ============================================ */
@media (max-width: 768px) {
    .flex-mobile-column {
        flex-direction: column !important;
    }
    
    .flex-mobile-wrap {
        flex-wrap: wrap !important;
    }
    
    .mobile-order-1 { order: 1 !important; }
    .mobile-order-2 { order: 2 !important; }
    .mobile-order-3 { order: 3 !important; }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}

*:focus-visible {
    outline: 2px solid #064b67;
    outline-offset: 2px;
}

/* ============================================
   SAFE AREA INSETS (NOTCHED DEVICES)
   ============================================ */
@supports (padding: max(0px)) {
    .safe-area-top {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    
    .safe-area-bottom {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .safe-area-left {
        padding-left: max(1rem, env(safe-area-inset-left));
    }
    
    .safe-area-right {
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* ============================================
   MOBILE LANDSCAPE MODE
   ============================================ */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-container {
        min-height: 150px !important;
    }
    
    .hero-container > div {
        height: 150px !important;
    }
    
    .modal {
        max-height: 85vh;
    }
}

/* ============================================
   VERY SMALL SCREENS (< 375px)
   ============================================ */
@media (max-width: 374px) {
    h1 {
        font-size: 1.25rem !important;
    }
    
    h2 {
        font-size: 1.125rem !important;
    }
    
    .btn, button {
        padding: 10px 16px !important;
        font-size: 14px !important;
    }
    
    .container {
        padding: 0.75rem !important;
    }
    
    .product-grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
}

/* ============================================
   TABLET SPECIFIC (768px - 1023px)
   ============================================ */
@media (min-width: 769px) and (max-width: 1023px) {
    .container {
        max-width: 720px;
    }
    
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */
@media (max-width: 768px) {
    /* Reduce animations on mobile */
    * {
        animation-duration: 0.3s !important;
        transition-duration: 0.2s !important;
    }
    
    /* Optimize scrolling */
    body, .modal-content, .sidebar {
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================
   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;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .no-print, 
    nav, 
    footer, 
    .btn, 
    button,
    .mobile-menu,
    .sidebar {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
        background: white;
    }
    
    a {
        text-decoration: underline;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */
@media (prefers-contrast: high) {
    button, .btn {
        border: 2px solid currentColor !important;
    }
    
    input, textarea, select {
        border: 2px solid currentColor !important;
    }
}
