/**
 * RESPONSIVE CSS FRAMEWORK
 * Mobile-first responsive utilities for hyperlocal marketplace
 * Breakpoints: Mobile (320px+), Tablet (768px+), Desktop (1024px+)
 */

/* ========================================
   VIEWPORT & BASE RESET
   ======================================== */

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* ========================================
   RESPONSIVE CONTAINERS
   ======================================== */

.container-responsive {
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 768px) {
    .container-responsive {
        padding-left: 20px;
        padding-right: 20px;
        max-width: 750px;
    }
}

@media (min-width: 1024px) {
    .container-responsive {
        padding-left: 30px;
        padding-right: 30px;
        max-width: 1200px;
    }
}

/* ========================================
   RESPONSIVE GRID SYSTEM
   ======================================== */

.row-responsive {
    display: flex;
    flex-wrap: wrap;
    margin-left: -10px;
    margin-right: -10px;
}

.col-responsive {
    flex: 1;
    padding-left: 10px;
    padding-right: 10px;
    min-width: 0;
}

/* Mobile: Full width */
.col-12 { width: 100%; }
.col-6 { width: 50%; }
.col-4 { width: 33.333%; }
.col-3 { width: 25%; }

/* Tablet and up */
@media (min-width: 768px) {
    .col-md-12 { width: 100%; }
    .col-md-6 { width: 50%; }
    .col-md-4 { width: 33.333%; }
    .col-md-3 { width: 25%; }
    .col-md-2 { width: 16.666%; }
}

/* Desktop and up */
@media (min-width: 1024px) {
    .col-lg-12 { width: 100%; }
    .col-lg-6 { width: 50%; }
    .col-lg-4 { width: 33.333%; }
    .col-lg-3 { width: 25%; }
    .col-lg-2 { width: 16.666%; }
}

/* ========================================
   MOBILE NAVIGATION
   ======================================== */

.mobile-nav-toggle {
    display: block;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
}

@media (min-width: 1024px) {
    .mobile-nav-toggle {
        display: none;
    }
}

.sidebar-responsive {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: #fff;
    transition: left 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar-responsive.active {
    left: 0;
}

@media (min-width: 1024px) {
    .sidebar-responsive {
        position: relative;
        left: 0;
        width: 260px;
        box-shadow: none;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

@media (min-width: 1024px) {
    .sidebar-overlay {
        display: none !important;
    }
}

/* ========================================
   RESPONSIVE TABLES
   ======================================== */

.table-responsive-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile: Convert table to cards */
@media (max-width: 767px) {
    .table-to-cards {
        display: block;
    }
    
    .table-to-cards thead {
        display: none;
    }
    
    .table-to-cards tbody,
    .table-to-cards tr,
    .table-to-cards td {
        display: block;
        width: 100%;
    }
    
    .table-to-cards tr {
        margin-bottom: 15px;
        border: 1px solid #eee;
        border-radius: 8px;
        padding: 15px;
        background: #fff;
    }
    
    .table-to-cards td {
        text-align: left !important;
        padding: 8px 0;
        border: none;
    }
    
    .table-to-cards td:before {
        content: attr(data-label);
        font-weight: 600;
        display: inline-block;
        width: 120px;
        color: #666;
    }
}

/* ========================================
   RESPONSIVE MODALS
   ======================================== */

@media (max-width: 767px) {
    .modal-responsive .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    
    .modal-responsive {
        padding: 0 !important;
    }
}

/* ========================================
   TOUCH-FRIENDLY BUTTONS
   ======================================== */

.btn-touch {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 20px;
    font-size: 16px;
}

@media (max-width: 767px) {
    .btn-mobile-full {
        width: 100%;
        display: block;
    }
}

/* ========================================
   RESPONSIVE TYPOGRAPHY
   ======================================== */

.h1-responsive {
    font-size: 24px;
    line-height: 1.2;
}

.h2-responsive {
    font-size: 20px;
    line-height: 1.3;
}

.h3-responsive {
    font-size: 18px;
    line-height: 1.4;
}

@media (min-width: 768px) {
    .h1-responsive { font-size: 32px; }
    .h2-responsive { font-size: 26px; }
    .h3-responsive { font-size: 22px; }
}

@media (min-width: 1024px) {
    .h1-responsive { font-size: 40px; }
    .h2-responsive { font-size: 32px; }
    .h3-responsive { font-size: 26px; }
}

/* ========================================
   RESPONSIVE FORMS
   ======================================== */

.form-responsive input,
.form-responsive select,
.form-responsive textarea {
    width: 100%;
    padding: 12px 15px;
    font-size: 16px; /* Prevents zoom on iOS */
    border: 1px solid #ddd;
    border-radius: 6px;
}

.form-responsive label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.form-group-responsive {
    margin-bottom: 15px;
}

@media (min-width: 768px) {
    .form-row-responsive {
        display: flex;
        gap: 15px;
    }
    
    .form-row-responsive .form-group-responsive {
        flex: 1;
    }
}

/* ========================================
   RESPONSIVE CARDS
   ======================================== */

.card-responsive {
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

@media (min-width: 768px) {
    .card-responsive {
        padding: 20px;
    }
}

/* ========================================
   RESPONSIVE PRODUCT GRID
   ======================================== */

.product-grid-responsive {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

@media (min-width: 768px) {
    .product-grid-responsive {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
}

@media (min-width: 1024px) {
    .product-grid-responsive {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Display utilities */
.hide-mobile { display: none; }
@media (min-width: 768px) {
    .hide-mobile { display: block; }
}

.show-mobile { display: block; }
@media (min-width: 768px) {
    .show-mobile { display: none; }
}

.hide-desktop { display: block; }
@media (min-width: 1024px) {
    .hide-desktop { display: none; }
}

.show-desktop { display: none; }
@media (min-width: 1024px) {
    .show-desktop { display: block; }
}

/* Spacing utilities */
.p-mobile-0 { padding: 0 !important; }
.p-mobile-10 { padding: 10px !important; }
.p-mobile-15 { padding: 15px !important; }

.m-mobile-0 { margin: 0 !important; }
.m-mobile-10 { margin: 10px !important; }
.m-mobile-15 { margin: 15px !important; }

/* Text alignment */
.text-mobile-center { text-align: center; }
.text-mobile-left { text-align: left; }

@media (min-width: 768px) {
    .text-md-left { text-align: left; }
    .text-md-center { text-align: center; }
    .text-md-right { text-align: right; }
}

/* Flex utilities */
.flex-mobile-column {
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .flex-md-row {
        flex-direction: row;
    }
}

/* ========================================
   STICKY ELEMENTS (Mobile)
   ======================================== */

.sticky-mobile-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    padding: 15px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 100;
}

@media (min-width: 768px) {
    .sticky-mobile-bottom {
        position: relative;
        box-shadow: none;
    }
}

/* ========================================
   RESPONSIVE IMAGES
   ======================================== */

.img-responsive {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ========================================
   MOBILE DRAWER/FILTER
   ======================================== */

.drawer-mobile {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    max-height: 80vh;
    overflow-y: auto;
    transition: bottom 0.3s ease;
    z-index: 1001;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.2);
}

.drawer-mobile.active {
    bottom: 0;
}

@media (min-width: 768px) {
    .drawer-mobile {
        position: relative;
        bottom: auto;
        border-radius: 8px;
        max-height: none;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
}

/* ========================================
   RESPONSIVE SPACING
   ======================================== */

.section-spacing {
    padding: 20px 0;
}

@media (min-width: 768px) {
    .section-spacing {
        padding: 40px 0;
    }
}

@media (min-width: 1024px) {
    .section-spacing {
        padding: 60px 0;
    }
}

/* ========================================
   MOBILE-OPTIMIZED SCROLLING
   ======================================== */

.scroll-horizontal-mobile {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.scroll-horizontal-mobile::-webkit-scrollbar {
    display: none;
}
