/**
 * Mobile Optimization 2025 - KoreaSewa
 * ====================================
 * 
 * Comprehensive mobile-first optimizations for all pages.
 * Ensures best experience on mobile devices (phones and tablets).
 * 
 * Features:
 * - Mobile-first responsive design
 * - Touch-friendly interactions
 * - Optimized typography for mobile
 * - Improved spacing and padding
 * - Better form controls
 * - Enhanced card layouts
 * - Responsive images and media
 * - Better navigation on mobile
 * 
 * Author: KoreaSewa Development Team
 * Version: 2.0.0
 * Last Updated: 2025-12-08
 */

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

/* Ensure proper box-sizing */
* {
    box-sizing: border-box;
}

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

/* Mobile-optimized body */
body {
    font-size: 16px; /* Prevent iOS zoom on input focus */
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Container improvements for mobile */
.container,
.container-fluid {
    width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
    margin-left: auto;
    margin-right: auto;
}

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

/* ============================================
   TYPOGRAPHY - MOBILE OPTIMIZED
   ============================================ */

/* Base font size - prevent iOS zoom */
body {
    font-size: clamp(16px, 4vw, 18px);
    line-height: 1.6;
}

h1 {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    line-height: 1.2;
    margin-bottom: 1rem;
}

h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    line-height: 1.3;
    margin-bottom: 0.875rem;
}

h3 {
    font-size: clamp(1.25rem, 3.5vw, 1.75rem);
    line-height: 1.4;
    margin-bottom: 0.75rem;
}

h4 {
    font-size: clamp(1.125rem, 3vw, 1.5rem);
    line-height: 1.4;
    margin-bottom: 0.625rem;
}

h5 {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

h6 {
    font-size: clamp(0.875rem, 2vw, 1rem);
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

p {
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* ============================================
   RESPONSIVE GRID IMPROVEMENTS
   ============================================ */

/* Bootstrap grid improvements for mobile */
@media (max-width: 767.98px) {
    .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .row > * {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Stack columns on mobile */
    [class*="col-"] {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    /* Full width on mobile for specific columns */
    .col-md-8,
    .col-md-6,
    .col-md-4,
    .col-lg-8,
    .col-lg-6,
    .col-lg-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ============================================
   CARDS - MOBILE OPTIMIZED
   ============================================ */

.card {
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

@media (max-width: 767.98px) {
    .card {
        margin-bottom: 0.75rem;
        border-radius: 0.375rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
        font-size: clamp(1rem, 2.5vw, 1.125rem);
    }
    
    .card-title {
        font-size: clamp(1.125rem, 3vw, 1.25rem);
        margin-bottom: 0.5rem;
    }
    
    .card-text {
        font-size: clamp(0.9375rem, 2.5vw, 1rem);
        line-height: 1.6;
    }
}

/* Card grid improvements */
.card-grid,
.card-deck {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 576px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

@media (min-width: 992px) {
    .card-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

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

.btn {
    min-height: 44px; /* iOS minimum touch target */
    min-width: 44px;
    padding: 0.625rem 1.25rem;
    font-size: clamp(0.9375rem, 2.5vw, 1rem);
    line-height: 1.5;
    border-radius: 0.375rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

@media (max-width: 767.98px) {
    .btn {
        min-height: 48px; /* Comfortable touch target */
        padding: 0.75rem 1.5rem;
        width: 100%;
        max-width: 100%;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

.btn-lg {
    min-height: 52px;
    padding: 0.875rem 1.75rem;
    font-size: clamp(1.0625rem, 3vw, 1.125rem);
}

.btn-sm {
    min-height: 36px;
    padding: 0.5rem 1rem;
    font-size: clamp(0.875rem, 2vw, 0.9375rem);
}

/* ============================================
   FORMS - MOBILE OPTIMIZED
   ============================================ */

.form-control,
.form-select {
    font-size: 16px; /* Prevent iOS zoom */
    min-height: 44px;
    padding: 0.625rem 0.875rem;
    border-radius: 0.375rem;
    width: 100%;
}

@media (max-width: 767.98px) {
    .form-control,
    .form-select {
        min-height: 48px;
        padding: 0.75rem 1rem;
        font-size: 16px; /* Critical: prevents iOS zoom */
    }
    
    .form-label {
        font-size: clamp(0.9375rem, 2.5vw, 1rem);
        margin-bottom: 0.5rem;
        font-weight: 500;
    }
    
    .form-text {
        font-size: clamp(0.875rem, 2vw, 0.9375rem);
    }
}

/* Input groups on mobile */
@media (max-width: 767.98px) {
    .input-group {
        flex-direction: column;
    }
    
    .input-group .form-control,
    .input-group .btn {
        width: 100%;
        border-radius: 0.375rem;
        margin-bottom: 0.5rem;
    }
    
    .input-group .btn:last-child {
        margin-bottom: 0;
    }
}

/* ============================================
   NAVIGATION - MOBILE OPTIMIZED
   ============================================ */

/* Navigation improvements */
.nav {
    flex-wrap: wrap;
}

.nav-link {
    min-height: 44px;
    padding: 0.625rem 1rem;
    font-size: clamp(0.9375rem, 2.5vw, 1rem);
    touch-action: manipulation;
}

@media (max-width: 767.98px) {
    .nav {
        flex-direction: column;
    }
    
    .nav-link {
        min-height: 48px;
        padding: 0.75rem 1rem;
        width: 100%;
        text-align: left;
    }
    
    .navbar-nav {
        flex-direction: column;
        width: 100%;
    }
    
    .navbar-nav .nav-link {
        padding: 0.875rem 1rem;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }
}

/* ============================================
   TABLES - MOBILE RESPONSIVE
   ============================================ */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

@media (max-width: 767.98px) {
    table {
        font-size: clamp(0.875rem, 2vw, 0.9375rem);
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.375rem;
        white-space: nowrap;
    }
    
    /* Stack table on very small screens */
    .table-stack-mobile {
        display: block;
    }
    
    .table-stack-mobile thead {
        display: none;
    }
    
    .table-stack-mobile tbody,
    .table-stack-mobile tr,
    .table-stack-mobile td {
        display: block;
        width: 100%;
    }
    
    .table-stack-mobile tr {
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 0.375rem;
        padding: 0.75rem;
    }
    
    .table-stack-mobile td {
        text-align: left;
        padding: 0.5rem 0;
        border: none;
    }
    
    .table-stack-mobile td:before {
        content: attr(data-label) ": ";
        font-weight: 600;
        display: inline-block;
        width: 40%;
    }
}

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

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

.img-fluid {
    width: 100%;
    height: auto;
}

/* Responsive images in cards */
@media (max-width: 767.98px) {
    .card-img-top {
        height: auto;
        max-height: 200px;
        object-fit: cover;
    }
}

/* ============================================
   MODALS - MOBILE OPTIMIZED
   ============================================ */

@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }
    
    .modal-content {
        height: 100%;
        border-radius: 0;
        border: none;
    }
    
    .modal-header {
        padding: 1rem;
        border-bottom: 1px solid #dee2e6;
    }
    
    .modal-body {
        padding: 1rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-footer {
        padding: 1rem;
        border-top: 1px solid #dee2e6;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .modal-footer .btn:last-child {
        margin-bottom: 0;
    }
}

/* ============================================
   BANNERS AND HERO SECTIONS
   ============================================ */

@media (max-width: 767.98px) {
    .smart-hub-banner,
    .hero-banner,
    .banner-section {
        padding: 2rem 0 !important;
        margin-bottom: 2rem !important;
    }
    
    .smart-hub-banner h2,
    .hero-banner h1,
    .banner-section h1 {
        font-size: clamp(1.5rem, 5vw, 2rem) !important;
        margin-bottom: 0.75rem !important;
    }
    
    .smart-hub-banner p,
    .hero-banner p,
    .banner-section p {
        font-size: clamp(0.9375rem, 2.5vw, 1rem) !important;
        margin-bottom: 1rem !important;
    }
    
    .smart-hub-banner .btn,
    .hero-banner .btn,
    .banner-section .btn {
        width: 100%;
        max-width: 100%;
    }
}

/* ============================================
   SECTIONS - MOBILE SPACING
   ============================================ */

section {
    padding: 2rem 0;
}

@media (max-width: 767.98px) {
    section {
        padding: 1.5rem 0;
    }
    
    .section-header {
        margin-bottom: 1.5rem;
    }
    
    .section-header h2 {
        font-size: clamp(1.5rem, 4vw, 1.75rem);
        margin-bottom: 0.5rem;
    }
    
    .section-header p {
        font-size: clamp(0.9375rem, 2.5vw, 1rem);
    }
}

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

/* Mobile-specific utilities */
.mobile-full-width {
    width: 100% !important;
    max-width: 100% !important;
}

.mobile-stack {
    flex-direction: column !important;
}

.mobile-center {
    text-align: center !important;
}

.mobile-padding {
    padding: 1rem !important;
}

@media (max-width: 767.98px) {
    .mobile-hide {
        display: none !important;
    }
    
    .mobile-show {
        display: block !important;
    }
    
    .mobile-mt-1 { margin-top: 0.5rem !important; }
    .mobile-mt-2 { margin-top: 1rem !important; }
    .mobile-mt-3 { margin-top: 1.5rem !important; }
    
    .mobile-mb-1 { margin-bottom: 0.5rem !important; }
    .mobile-mb-2 { margin-bottom: 1rem !important; }
    .mobile-mb-3 { margin-bottom: 1.5rem !important; }
    
    .mobile-p-1 { padding: 0.5rem !important; }
    .mobile-p-2 { padding: 1rem !important; }
    .mobile-p-3 { padding: 1.5rem !important; }
}

/* ============================================
   ACCESSIBILITY - MOBILE
   ============================================ */

/* Focus states for touch devices */
@media (max-width: 767.98px) {
    a:focus,
    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid #0066ff;
        outline-offset: 2px;
    }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Reduce animations on mobile for better performance */
@media (max-width: 767.98px) {
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

