/* Responsive Design for Cometeo */

/* Large devices (desktops, less than 1200px) */
@media (max-width: 1199.98px) {
    .container {
        max-width: 960px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    
    .primary-card {
        grid-column: 1;
        grid-row: 1;
    }
    
    .alert-card {
        grid-column: 1;
        grid-row: 2;
    }
    
    .historical-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .forecast-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .planner-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .alerts-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* Medium devices (tablets, less than 992px) */
@media (max-width: 991.98px) {
    .container {
        max-width: 720px;
        padding: 0 15px;
    }
    
    .header .container {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .nav {
        order: 3;
        width: 100%;
    }
    
    .nav ul {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }
    
    .location-selector {
        width: 100%;
        justify-content: space-between;
    }
    
    .search-box {
        flex: 1;
    }
    
    .search-box input {
        width: 100%;
    }
    
    .weather-main {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .temperature {
        font-size: 3.5rem;
    }
    
    .weather-icon {
        font-size: 4rem;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .pollutants-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .footer-content {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
}

/* Small devices (landscape phones, less than 768px) */
@media (max-width: 767.98px) {
    .container {
        max-width: 540px;
        padding: 0 12px;
    }
    
    .section {
        padding: 1rem 0;
    }
    
    .section-title h1 {
        font-size: 2rem;
    }
    
    .logo {
        font-size: 1.25rem;
    }
    
    .logo i {
        font-size: 1.5rem;
    }
    
    .nav-link {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .nav-link span {
        display: none;
    }
    
    .dashboard-card {
        padding: 1.25rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .card-header h3 {
        font-size: 1.1rem;
    }
    
    .temperature {
        font-size: 3rem;
    }
    
    .hour-item {
        min-width: 70px;
        padding: 0.875rem;
    }
    
    .hour-time {
        font-size: 0.8rem;
    }
    
    .hour-temp {
        font-size: 1.1rem;
    }
    
    .stat-card {
        padding: 1.25rem;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .forecast-day {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .forecast-date {
        min-width: auto;
    }
    
    .route-point {
        padding: 1rem;
    }
    
    .point-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }
    
    .footer-logo {
        justify-content: center;
    }
    
    .social-links {
        justify-content: center;
    }
}

/* Extra small devices (portrait phones, less than 576px) */
@media (max-width: 575.98px) {
    .container {
        width: 100%;
        padding: 0 10px;
    }
    
    .header .container {
        padding: 0.75rem 10px;
    }
    
    .section-title h1 {
        font-size: 1.75rem;
    }
    
    .location-selector {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }
    
    .search-box {
        width: 100%;
    }
    
    .search-box input {
        min-width: auto;
    }
    
    .temperature {
        font-size: 2.5rem;
    }
    
    .unit {
        font-size: 1.5rem;
    }
    
    .weather-icon {
        font-size: 3.5rem;
    }
    
    .detail-item {
        padding: 0.875rem;
    }
    
    .hourly-scroll {
        gap: 0.75rem;
    }
    
    .hour-item {
        min-width: 65px;
        padding: 0.75rem;
    }
    
    .pollutants-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .forecast-controls {
        width: 100%;
    }
    
    .forecast-select {
        width: 100%;
    }
    
    .date-controls {
        width: 100%;
    }
    
    .date-selector {
        width: 100%;
        flex-direction: column;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }
    
    .input-group input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Hide less important elements on mobile */
    .view-all,
    .gps-btn .text {
        display: none;
    }
}

/* Mobile landscape orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        position: static;
    }
    
    .header .container {
        padding: 0.5rem 15px;
    }
    
    .section {
        padding: 0.5rem 0;
    }
    
    .dashboard-card {
        padding: 1rem;
    }
    
    .main {
        min-height: auto;
        padding: 1rem 0;
    }
}

/* High-resolution displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo i,
    .weather-icon,
    .detail-item i,
    .nav-link i {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .nav-link,
    .btn-primary,
    .btn-secondary,
    .theme-toggle,
    .user-menu,
    .search-btn,
    .gps-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .hour-item {
        min-width: 70px;
        min-height: 70px;
    }
    
    .detail-item {
        padding: 16px;
    }
    
    /* Reduce hover effects on touch devices */
    .dashboard-card:hover {
        transform: none;
    }
    
    .detail-item:hover,
    .forecast-day:hover,
    .route-point:hover,
    .alert-item:hover {
        transform: none;
    }
}

/* Very large screens */
@media (min-width: 1600px) {
    .container {
        max-width: 1400px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }
    
    .primary-card {
        grid-column: 1;
        grid-row: 1;
    }
    
    .alert-card {
        grid-column: 1 / -1;
        grid-row: 2;
    }
}

/* Fix for mobile navigation */
@media (max-width: 767.98px) {
    .nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav ul {
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding-bottom: 0.5rem;
    }
    
    .nav-link {
        white-space: nowrap;
    }
}

/* Loading states for mobile */
@media (max-width: 767.98px) {
    .loading-logo {
        font-size: 1.75rem;
    }
    
    .loading-logo i {
        font-size: 2rem;
    }
    
    .loading-spinner {
        width: 40px;
        height: 40px;
    }
}

/* Notification responsive fixes */
@media (max-width: 575.98px) {
    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* Dark mode media query fallback */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --background-color: #0F172A;
        --surface-color: #1E293B;
        --card-color: #1E293B;
        --text-primary: #F1F5F9;
        --text-secondary: #CBD5E1;
        --text-tertiary: #64748B;
        --border-color: #334155;
        --border-light: #1E293B;
    }
}

/* Print styles improvements */
@media print {
    .dashboard-card {
        break-inside: avoid;
        margin-bottom: 1rem;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .section {
        page-break-inside: avoid;
    }
    
    .no-print {
        display: none !important;
    }
}

/* Reduced motion improvements */
@media (prefers-reduced-motion: reduce) {
    .dashboard-card,
    .detail-item,
    .forecast-day,
    .route-point,
    .alert-item,
    .hour-item,
    .stat-card {
        transition: none;
    }
    
    .loading-spinner {
        animation: none;
        border: 3px solid var(--border-color);
        border-top-color: var(--primary-color);
    }
    
    .prediction-fill::after {
        animation: none;
    }
}

/* Focus styles for accessibility */
@media (prefers-reduced-motion: no-preference) {
    .nav-link:focus,
    .btn-primary:focus,
    .btn-secondary:focus,
    .theme-toggle:focus,
    .user-menu:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-primary: #000000;
        --text-secondary: #333333;
    }
    
    [data-theme="dark"] {
        --border-color: #ffffff;
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
    }
    
    .dashboard-card {
        border: 2px solid var(--border-color);
    }
    
    .nav-link.active {
        outline: 2px solid var(--primary-color);
    }
}