/**
 * Mobile Responsive CSS
 * Media queries e otimizações responsivas
 */

/* ===== BASE RESPONSIVE SETTINGS ===== */
html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #1f2937;
    background-color: #f9fafb;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* ===== MOBILE FIRST APPROACH ===== */
/* Base styles (mobile) */
.establishments-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem;
}

.mobile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    padding: 1rem;
    margin: 1rem 0;
}

.mobile-carousel-card {
    width: calc(100vw - 4rem);
    min-width: calc(100vw - 4rem);
    max-width: calc(100vw - 4rem);
}

/* ===== SMALL DEVICES (576px and up) ===== */
@media (min-width: 576px) {
    .mobile-carousel-card {
        width: 20rem;
        min-width: 18rem;
        max-width: 22rem;
    }
    
    .establishments-grid {
        padding: 1.5rem;
    }
    
    .mobile-stats {
        padding: 1.5rem;
        gap: 1rem;
    }
}

/* ===== MEDIUM DEVICES (768px and up) ===== */
@media (min-width: 768px) {
    html {
        font-size: 17px;
    }
    
    .establishments-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
        padding: 2rem;
    }
    
    .mobile-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
        padding: 2rem;
    }
    
    .mobile-carousel-card {
        width: 20rem;
        min-width: 20rem;
        max-width: 20rem;
    }
    
    .container {
        padding: 0 2rem;
    }
    
    /* Header adjustments */
    .mobile-header {
        padding: 1.5rem 2rem;
    }
    
    .mobile-header h1 {
        font-size: 1.75rem;
    }
    
    /* Search adjustments */
    .mobile-search,
    .mobile-filters {
        padding: 1rem 2rem;
    }
}

/* ===== LARGE DEVICES (1024px and up) ===== */
@media (min-width: 1024px) {
    html {
        font-size: 18px;
    }
    
    .establishments-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
        padding: 2.5rem;
    }
    
    .mobile-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
        padding: 2.5rem;
    }
    
    .container {
        max-width: 1200px;
        padding: 0 2.5rem;
    }
    
    .mobile-header {
        padding: 2rem 2.5rem;
    }
    
    .mobile-header h1 {
        font-size: 2rem;
    }
    
    .mobile-search,
    .mobile-filters {
        padding: 1.5rem 2.5rem;
    }
}

/* ===== EXTRA LARGE DEVICES (1200px and up) ===== */
@media (min-width: 1200px) {
    .establishments-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .container {
        max-width: 1400px;
    }
}

/* ===== SPECIFIC DEVICE OPTIMIZATIONS ===== */

/* iPhone SE and similar small screens */
@media (max-width: 375px) {
    html {
        font-size: 14px;
    }
    
    .mobile-header h1 {
        font-size: 1.25rem;
    }
    
    .mobile-carousel-card {
        width: calc(100vw - 2rem);
        min-width: calc(100vw - 2rem);
        max-width: calc(100vw - 2rem);
    }
    
    .mobile-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        padding: 0.75rem;
    }
    
    .stat-number {
        font-size: 1.25rem;
    }
    
    .stat-label {
        font-size: 0.625rem;
    }
    
    .filter-chip {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }
    
    .action-btn {
        width: 2rem;
        height: 2rem;
    }
}

/* iPhone 12/13/14 and similar */
@media (max-width: 390px) and (max-height: 844px) {
    .mobile-carousel-card {
        width: calc(100vw - 3rem);
        min-width: calc(100vw - 3rem);
        max-width: calc(100vw - 3rem);
    }
}

/* iPhone 12/13/14 Pro Max and similar */
@media (max-width: 428px) and (max-height: 926px) {
    .mobile-carousel-card {
        width: calc(100vw - 3.5rem);
        min-width: calc(100vw - 3.5rem);
        max-width: calc(100vw - 3.5rem);
    }
}

/* Tablet Portrait */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .establishments-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .mobile-carousel-card {
        width: 18rem;
        min-width: 18rem;
        max-width: 18rem;
    }
}

/* Tablet Landscape */
@media (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) {
    .establishments-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .mobile-carousel-card {
        width: 20rem;
        min-width: 20rem;
        max-width: 20rem;
    }
}

/* ===== ORIENTATION SPECIFIC ===== */
@media (orientation: landscape) and (max-height: 500px) {
    .mobile-header {
        padding: 0.75rem 1rem;
    }
    
    .mobile-header h1 {
        font-size: 1.25rem;
    }
    
    .mobile-stats {
        padding: 1rem;
        margin: 0.5rem 0;
    }
    
    .stat-item {
        padding: 0.5rem 0;
    }
    
    section {
        margin-bottom: 1rem;
    }
}

/* ===== HIGH DPI DISPLAYS ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimizations for Retina displays */
    .establishment-card .card-image img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ===== DARK MODE ===== */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #111827;
        color: #f9fafb;
    }
    
    .mobile-header {
        background: rgba(17, 24, 39, 0.95);
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }
    
    .mobile-header h1 {
        color: #f9fafb;
    }
    
    .mobile-header p {
        color: #d1d5db;
    }
    
    .action-btn {
        background: #374151;
        color: #d1d5db;
    }
    
    .action-btn:hover {
        background: #4b5563;
        color: #f9fafb;
    }
    
    .mobile-filters,
    .mobile-search {
        background: #1f2937;
        border-bottom-color: #374151;
    }
    
    .filter-chip {
        background: #374151;
        color: #d1d5db;
        border-color: #4b5563;
    }
    
    .filter-chip.active {
        background: #3b82f6;
        color: white;
    }
    
    .search-input-container {
        background: #374151;
        border-color: #4b5563;
    }
    
    .search-input {
        color: #f9fafb;
    }
    
    .search-input::placeholder {
        color: #9ca3af;
    }
    
    .establishment-card {
        background: #1f2937;
        border-color: #374151;
    }
    
    .establishment-card .card-title {
        color: #f9fafb;
    }
    
    .establishment-card .card-address {
        color: #d1d5db;
    }
    
    .mobile-stats {
        background: #1f2937;
    }
    
    .stat-number {
        color: #f9fafb;
    }
    
    .stat-label {
        color: #d1d5db;
    }
}

/* ===== 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;
    }
    
    .mobile-carousel-wrapper {
        transition: none !important;
    }
    
    .establishment-card {
        transition: none !important;
    }
    
    .establishment-card:hover {
        transform: none !important;
    }
    
    .spinner {
        animation: none !important;
    }
    
    .status-dot {
        animation: none !important;
    }
}

/* ===== HIGH CONTRAST ===== */
@media (prefers-contrast: high) {
    .establishment-card {
        border: 2px solid #000;
    }
    
    .filter-chip {
        border: 2px solid #000;
    }
    
    .action-btn {
        border: 2px solid #000;
    }
    
    .mobile-header {
        border-bottom: 2px solid #000;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.4;
    }
    
    .mobile-header,
    .mobile-filters,
    .mobile-search,
    .mobile-carousel-prev,
    .mobile-carousel-next,
    .action-btn,
    .favorite-btn {
        display: none !important;
    }
    
    .establishment-card {
        break-inside: avoid;
        border: 1px solid #000;
        margin-bottom: 1rem;
    }
    
    .establishment-card .card-image {
        height: auto;
        max-height: 200px;
    }
    
    .establishments-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0;
    }
    
    .mobile-stats {
        display: none !important;
    }
    
    .shadow-lg,
    .shadow-xl,
    .shadow-2xl {
        box-shadow: none !important;
    }
    
    a {
        color: black !important;
        text-decoration: underline !important;
    }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
@media (hover: none) and (pointer: coarse) {
    /* Touch devices - increase touch targets */
    .action-btn,
    .filter-chip,
    .mobile-carousel-prev,
    .mobile-carousel-next {
        min-height: 44px;
        min-width: 44px;
    }
    
    .establishment-card {
        margin-bottom: 1rem;
    }
    
    .establishment-card .card-content {
        padding: 1.25rem;
    }
    
    /* Improve scrolling performance on touch devices */
    .mobile-carousel-container,
    .filter-scroll {
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }
    
    .mobile-carousel-card {
        scroll-snap-align: start;
    }
    
    .filter-chip {
        scroll-snap-align: start;
    }
}

/* ===== FOCUS STYLES FOR ACCESSIBILITY ===== */
.action-btn:focus,
.filter-chip:focus,
.search-input:focus,
.mobile-carousel-prev:focus,
.mobile-carousel-next:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.establishment-card .card-image img {
    will-change: transform;
    transform: translateZ(0);
}

.mobile-carousel-wrapper {
    will-change: transform;
    transform: translateZ(0);
}

/* ===== CUSTOM SCROLLBARS ===== */
.filter-scroll::-webkit-scrollbar {
    height: 4px;
}

.filter-scroll::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 2px;
}

.filter-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.filter-scroll::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Firefox scrollbar styling */
.filter-scroll {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

/* ===== SAFE AREA SUPPORT ===== */
@supports (padding: max(0px)) {
    .mobile-header {
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    main {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: max(5rem, env(safe-area-inset-bottom));
    }
}

/* ===== SPECIFIC DEVICE FIXES ===== */

/* Fix for some Android devices with viewport issues */
@media screen and (max-width: 767px) {
    .mobile-optimized {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
}

/* Fix for iOS Safari bottom bar */
@supports (-webkit-touch-callout: none) {
    main {
        min-height: -webkit-fill-available;
    }
}

/* Fix for very wide screens */
@media (min-width: 1400px) {
    .container {
        max-width: 1400px;
    }
    
    .mobile-carousel-card {
        width: 22rem;
        min-width: 22rem;
        max-width: 22rem;
    }
} 