/**
 * Responsive Design System
 * Kidai Kari - Mobile & Desktop Views
 *
 * Breakpoints:
 * - Mobile: < 768px
 * - Tablet: 768px - 1024px
 * - Desktop: > 1024px
 */

/* ============================================================================
   ROOT VARIABLES FOR RESPONSIVE DESIGN
   ============================================================================ */

:root {
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Font Sizes - Mobile First */
    --font-xs: 0.75rem;
    --font-sm: 0.875rem;
    --font-base: 1rem;
    --font-lg: 1.125rem;
    --font-xl: 1.25rem;
    --font-2xl: 1.5rem;
    --font-3xl: 2rem;

    /* Container Widths */
    --container-mobile: 100%;
    --container-tablet: 720px;
    --container-desktop: 1140px;
    --container-wide: 1320px;

    /* Z-index layers */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

/* ============================================================================
   GLOBAL RESPONSIVE UTILITIES
   ============================================================================ */

/* Container */
.container {
    width: 100%;
    max-width: var(--container-mobile);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

@media (min-width: 768px) {
    .container {
        max-width: var(--container-tablet);
        padding: 0 var(--spacing-lg);
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: var(--container-desktop);
        padding: 0 var(--spacing-xl);
    }
}

@media (min-width: 1440px) {
    .container {
        max-width: var(--container-wide);
    }
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 calc(var(--spacing-md) * -1);
}

.col {
    flex: 1;
    padding: 0 var(--spacing-md);
}

/* Mobile: Full width columns */
@media (max-width: 767px) {
    .col {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Tablet: 2 columns */
@media (min-width: 768px) and (max-width: 1023px) {
    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* Desktop: 3-4 columns */
@media (min-width: 1024px) {
    .col-lg-3 {
        flex: 0 0 25%;
        max-width: 25%;
    }

    .col-lg-4 {
        flex: 0 0 33.333%;
        max-width: 33.333%;
    }

    .col-lg-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* ============================================================================
   RESPONSIVE TEXT
   ============================================================================ */

/* Responsive Font Sizes */
@media (min-width: 768px) {
    :root {
        --font-base: 1.125rem;
        --font-lg: 1.25rem;
        --font-xl: 1.5rem;
        --font-2xl: 2rem;
        --font-3xl: 2.5rem;
    }
}

@media (min-width: 1024px) {
    :root {
        --font-base: 1.25rem;
        --font-lg: 1.5rem;
        --font-xl: 1.75rem;
        --font-2xl: 2.25rem;
        --font-3xl: 3rem;
    }
}

/* Text Alignment */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

@media (max-width: 767px) {
    .text-mobile-center {
        text-align: center;
    }
}

/* ============================================================================
   RESPONSIVE SPACING
   ============================================================================ */

/* Padding */
.p-0 { padding: 0; }
.p-1 { padding: var(--spacing-sm); }
.p-2 { padding: var(--spacing-md); }
.p-3 { padding: var(--spacing-lg); }
.p-4 { padding: var(--spacing-xl); }

/* Margin */
.m-0 { margin: 0; }
.m-1 { margin: var(--spacing-sm); }
.m-2 { margin: var(--spacing-md); }
.m-3 { margin: var(--spacing-lg); }
.m-4 { margin: var(--spacing-xl); }

/* Mobile spacing adjustments */
@media (max-width: 767px) {
    .p-mobile-1 { padding: var(--spacing-sm); }
    .p-mobile-2 { padding: var(--spacing-md); }
    .m-mobile-1 { margin: var(--spacing-sm); }
    .m-mobile-2 { margin: var(--spacing-md); }
}

/* ============================================================================
   DISPLAY UTILITIES
   ============================================================================ */

/* Hide on mobile */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    .hide-tablet {
        display: none !important;
    }
}

/* Hide on desktop */
@media (min-width: 1024px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 767px) {
    .show-mobile {
        display: block !important;
    }
}

/* Show only on desktop */
.show-desktop {
    display: none !important;
}

@media (min-width: 1024px) {
    .show-desktop {
        display: block !important;
    }
}

/* ============================================================================
   RESPONSIVE BUTTONS
   ============================================================================ */

.btn {
    padding: 0.75rem 1.5rem;
    font-size: var(--font-base);
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

@media (max-width: 767px) {
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: var(--font-sm);
    }

    .btn-block-mobile {
        width: 100%;
        display: block;
    }
}

/* ============================================================================
   RESPONSIVE CARDS
   ============================================================================ */

.card {
    background: white;
    border-radius: 1rem;
    padding: var(--spacing-lg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

@media (max-width: 767px) {
    .card {
        padding: var(--spacing-md);
        border-radius: 0.75rem;
    }
}

/* ============================================================================
   RESPONSIVE MODALS
   ============================================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: var(--z-modal-backdrop);
}

.modal-overlay.active {
    display: flex;
}

.modal-container {
    background: white;
    border-radius: 1rem;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 767px) {
    .modal-container {
        max-width: 100%;
        border-radius: 1rem 1rem 0 0;
        margin-top: auto;
        max-height: 85vh;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
}

/* ============================================================================
   RESPONSIVE NAVIGATION
   ============================================================================ */

/* Bottom Navigation - Mobile */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: var(--z-fixed);
}

@media (min-width: 1024px) {
    .bottom-nav {
        display: none; /* Hide bottom nav on desktop */
    }

    /* Show sidebar navigation on desktop */
    .sidebar-nav {
        display: block;
    }
}

@media (max-width: 1023px) {
    .sidebar-nav {
        display: none; /* Hide sidebar on mobile/tablet */
    }
}

/* ============================================================================
   RESPONSIVE IMAGES
   ============================================================================ */

img {
    max-width: 100%;
    height: auto;
}

.img-responsive {
    width: 100%;
    height: auto;
    display: block;
}

/* Product Images */
.product-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 0.5rem;
}

@media (min-width: 768px) {
    .product-image {
        aspect-ratio: 4 / 3;
    }
}

/* ============================================================================
   RESPONSIVE FORMS
   ============================================================================ */

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: var(--font-base);
    border: 1px solid #ddd;
    border-radius: 0.5rem;
}

@media (max-width: 767px) {
    .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 0.625rem 0.875rem;
    }
}

/* ============================================================================
   RESPONSIVE TABLES
   ============================================================================ */

@media (max-width: 767px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }
}

/* ============================================================================
   TOUCH TARGETS (Mobile Optimization)
   ============================================================================ */

@media (max-width: 767px) {
    /* Minimum touch target size: 44x44px (iOS guidelines) */
    a, button, .clickable {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* ============================================================================
   RESPONSIVE EMBEDS (iframes, videos, maps)
   ============================================================================ */

.responsive-map-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    overflow: hidden;
}

.responsive-map-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

@media (max-width: 767px) {
    .responsive-map-container {
        padding-top: 75%; /* 4:3 aspect ratio on mobile */
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .responsive-map-container {
        padding-top: 66.67%; /* 3:2 aspect ratio on tablet */
    }
}

/* ============================================================================
   SAFE AREA PADDING (iOS Notch Support)
   ============================================================================ */

@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));
    }

    .bottom-nav {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    .no-print,
    .bottom-nav,
    .modal-overlay,
    .floating-btn {
        display: none !important;
    }

    body {
        background: white;
    }

    .container {
        max-width: 100%;
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid #F59E0B;
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================================
   LANDSCAPE MODE (Mobile)
   ============================================================================ */

@media (max-width: 767px) and (orientation: landscape) {
    .modal-container {
        max-height: 70vh;
    }

    .profile-header {
        padding: 0.5rem 1rem;
    }
}

/* ============================================================================
   HIGH DPI DISPLAYS
   ============================================================================ */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize for retina displays */
    .icon {
        image-rendering: -webkit-optimize-contrast;
    }
}
