/**
 * Responsive Design Enhancements
 * Mobile-first approach with optimal user experience
 */

/* ==========================================
   1. MOBILE-FIRST BASE STYLES
   ========================================== */

/* Base mobile styles (320px and up) */
* {
    box-sizing: border-box;
}

body {
    font-size: 16px; /* Minimum readable font size on mobile */
    line-height: 1.6;
    -webkit-text-size-adjust: 100%; /* Prevent iOS font scaling */
    -ms-text-size-adjust: 100%;
}

/* Touch-friendly interactive elements */
a, button, input, select, textarea {
    min-height: 44px; /* Apple's recommended minimum touch target */
    min-width: 44px;
}

button, .btn {
    padding: 12px 24px;
    font-size: 16px; /* Prevent zoom on iOS */
}

input, select, textarea {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--color-gray-300);
    width: 100%;
}

/* ==========================================
   2. TYPOGRAPHY RESPONSIVE SCALING
   ========================================== */

/* Mobile Typography */
h1, .h1 {
    font-size: 1.75rem; /* 28px */
    line-height: 1.2;
    margin-bottom: 1rem;
}

h2, .h2 {
    font-size: 1.5rem; /* 24px */
    line-height: 1.3;
    margin-bottom: 0.875rem;
}

h3, .h3 {
    font-size: 1.25rem; /* 20px */
    line-height: 1.4;
    margin-bottom: 0.75rem;
}

h4, .h4 {
    font-size: 1.125rem; /* 18px */
    line-height: 1.4;
    margin-bottom: 0.625rem;
}

p, .text-base {
    font-size: 1rem; /* 16px */
    margin-bottom: 1rem;
}

.text-sm {
    font-size: 0.875rem; /* 14px */
}

.text-lg {
    font-size: 1.125rem; /* 18px */
}

/* ==========================================
   3. LAYOUT RESPONSIVE CONTAINERS
   ========================================== */

.container-responsive {
    width: 100%;
    margin: 0 auto;
    padding: 0 16px;
}

.row-responsive {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -8px;
}

.col-responsive {
    flex: 1;
    padding: 0 8px;
    margin-bottom: 16px;
}

/* Grid System */
.grid-responsive {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr;
}

/* ==========================================
   4. NAVIGATION RESPONSIVE BEHAVIOR
   ========================================== */

.navbar-mobile {
    background: var(--color-white);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.navbar-mobile .navbar-menu {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-mobile .navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
}

.navbar-mobile .navbar-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-gray-700);
    padding: 8px;
}

.navbar-mobile .navbar-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-white);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 20px;
    list-style: none;
    margin: 0;
}

.navbar-mobile .navbar-nav.active {
    display: block;
}

.navbar-mobile .nav-link {
    display: block;
    padding: 12px 0;
    color: var(--color-gray-700);
    text-decoration: none;
    border-bottom: 1px solid var(--color-gray-100);
    font-weight: 500;
}

.navbar-mobile .nav-link:last-child {
    border-bottom: none;
}

.navbar-mobile .nav-link.active,
.navbar-mobile .nav-link:hover {
    color: var(--color-primary);
}

/* ==========================================
   5. FORM RESPONSIVE ENHANCEMENTS
   ========================================== */

.form-responsive {
    width: 100%;
    max-width: none;
}

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

.form-row-responsive {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-control-responsive {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--color-gray-300);
    border-radius: 8px;
    transition: border-color 0.2s;
}

.form-control-responsive:focus {
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(232, 162, 57, 0.1);
}

.btn-responsive {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    border-radius: 8px;
    border: none;
    background: var(--color-primary);
    color: var(--color-white);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-responsive:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
}

.btn-responsive:active {
    transform: translateY(0);
}

/* ==========================================
   6. CARD RESPONSIVE LAYOUTS
   ========================================== */

.card-responsive {
    background: var(--color-white);
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header-responsive {
    padding: 20px;
    background: var(--color-gray-50);
    border-bottom: 1px solid var(--color-gray-200);
}

.card-body-responsive {
    padding: 20px;
}

.card-footer-responsive {
    padding: 20px;
    background: var(--color-gray-50);
    border-top: 1px solid var(--color-gray-200);
}

.cards-grid-responsive {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

/* ==========================================
   7. TABLE RESPONSIVE BEHAVIOR
   ========================================== */

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

.table-mobile {
    width: 100%;
    min-width: 600px; /* Minimum width before horizontal scroll */
    border-collapse: collapse;
}

.table-mobile th,
.table-mobile td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid var(--color-gray-200);
    font-size: 14px;
}

.table-mobile th {
    background: var(--color-gray-50);
    font-weight: 600;
    color: var(--color-gray-700);
}

/* Stack table for very small screens */
.table-stack {
    border: none;
}

.table-stack thead {
    display: none;
}

.table-stack tbody,
.table-stack tr,
.table-stack td {
    display: block;
}

.table-stack tr {
    border: 1px solid var(--color-gray-200);
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--color-white);
}

.table-stack td {
    border: none;
    padding: 8px 0;
    position: relative;
    padding-left: 120px;
}

.table-stack td:before {
    content: attr(data-label) ": ";
    position: absolute;
    left: 0;
    font-weight: 600;
    color: var(--color-gray-700);
    width: 110px;
}

/* ==========================================
   8. MODAL RESPONSIVE BEHAVIOR
   ========================================== */

.modal-responsive {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 2000;
}

.modal-content-responsive {
    background: var(--color-white);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header-responsive {
    padding: 20px;
    border-bottom: 1px solid var(--color-gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body-responsive {
    padding: 20px;
}

.modal-footer-responsive {
    padding: 20px;
    border-top: 1px solid var(--color-gray-200);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ==========================================
   9. UTILITY CLASSES FOR RESPONSIVE
   ========================================== */

/* Spacing utilities */
.p-mobile { padding: 16px; }
.px-mobile { padding-left: 16px; padding-right: 16px; }
.py-mobile { padding-top: 16px; padding-bottom: 16px; }
.pt-mobile { padding-top: 16px; }
.pb-mobile { padding-bottom: 16px; }

.m-mobile { margin: 16px; }
.mx-mobile { margin-left: 16px; margin-right: 16px; }
.my-mobile { margin-top: 16px; margin-bottom: 16px; }
.mt-mobile { margin-top: 16px; }
.mb-mobile { margin-bottom: 16px; }

/* Display utilities */
.show-mobile { display: block !important; }
.hide-mobile { display: none !important; }

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

/* Flexbox utilities */
.d-flex-mobile { display: flex; }
.flex-column-mobile { flex-direction: column; }
.flex-row-mobile { flex-direction: row; }
.justify-center-mobile { justify-content: center; }
.align-center-mobile { align-items: center; }

/* ==========================================
   10. BREAKPOINT-SPECIFIC STYLES
   ========================================== */

/* Small Mobile (up to 480px) */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    .container-responsive {
        padding: 0 12px;
    }
    
    h1, .h1 { font-size: 1.5rem; } /* 24px */
    h2, .h2 { font-size: 1.25rem; } /* 20px */
    h3, .h3 { font-size: 1.125rem; } /* 18px */
    
    .btn-responsive {
        padding: 14px;
        font-size: 15px;
    }
    
    .card-body-responsive,
    .modal-body-responsive {
        padding: 16px;
    }
    
    .table-mobile {
        font-size: 13px;
    }
    
    .table-mobile th,
    .table-mobile td {
        padding: 10px 6px;
    }
}

/* Large Mobile / Small Tablet (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .container-responsive {
        padding: 0 20px;
    }
    
    .grid-responsive {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .form-row-responsive {
        flex-direction: row;
        gap: 20px;
    }
    
    .form-row-responsive .form-group-responsive {
        flex: 1;
    }
    
    .cards-grid-responsive {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-content-responsive {
        max-width: 600px;
    }
}

/* Tablet (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .container-responsive {
        max-width: 750px;
        padding: 0 24px;
    }
    
    .grid-responsive {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
    }
    
    .cards-grid-responsive {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }
    
    .navbar-mobile .navbar-nav {
        display: flex;
        position: static;
        box-shadow: none;
        padding: 0;
        background: transparent;
        gap: 24px;
    }
    
    .navbar-mobile .navbar-toggle {
        display: none;
    }
    
    .navbar-mobile .nav-link {
        border: none;
        padding: 8px 16px;
    }
    
    .table-mobile {
        min-width: auto;
    }
    
    .hide-mobile {
        display: block !important;
    }
}

/* Desktop (1025px and up) */
@media (min-width: 1025px) {
    .container-responsive {
        max-width: 1200px;
        padding: 0 32px;
    }
    
    .grid-responsive {
        grid-template-columns: repeat(4, 1fr);
        gap: 32px;
    }
    
    .cards-grid-responsive {
        grid-template-columns: repeat(3, 1fr);
        gap: 32px;
    }
    
    .form-row-responsive {
        gap: 32px;
    }
    
    h1, .h1 { font-size: 2.5rem; } /* 40px */
    h2, .h2 { font-size: 2rem; } /* 32px */
    h3, .h3 { font-size: 1.5rem; } /* 24px */
    
    .modal-content-responsive {
        max-width: 800px;
    }
    
    /* Desktop navigation */
    .navbar-mobile {
        position: static;
    }
    
    .show-mobile {
        display: none !important;
    }
}

/* Large Desktop (1441px and up) */
@media (min-width: 1441px) {
    .container-responsive {
        max-width: 1400px;
    }
    
    .grid-responsive {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .cards-grid-responsive {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ==========================================
   11. HIGH DPI / RETINA DISPLAY SUPPORT
   ========================================== */

@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi),
       (min-resolution: 2dppx) {
    /* High DPI optimizations */
    .icon-responsive {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ==========================================
   12. ACCESSIBILITY RESPONSIVE FEATURES
   ========================================== */

/* Increase touch targets for better accessibility */
@media (hover: none) and (pointer: coarse) {
    button, .btn, a, input, select, textarea {
        min-height: 48px;
        min-width: 48px;
    }
    
    .nav-link {
        padding: 16px;
    }
}

/* Reduce motion for users who prefer it */
@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 support */
@media (prefers-contrast: high) {
    .card-responsive {
        border: 2px solid var(--color-gray-900);
    }
    
    .form-control-responsive {
        border: 2px solid var(--color-gray-900);
    }
    
    .btn-responsive {
        border: 2px solid var(--color-gray-900);
    }
}

/* Print styles */
@media print {
    .navbar-mobile,
    .floating-whatsapp,
    .back-to-top,
    .modal-responsive {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
    }
    
    .container-responsive {
        max-width: none;
        padding: 0;
    }
}