/* Responsive Design System */

/* Mobile First Approach - Base styles are for mobile */

/* Extra Small Devices (phones, less than 576px) */
@media (max-width: 575.98px) {
    :root {
        --container-max-width: 100%;
        --spacing-xs: 0.25rem;
        --spacing-sm: 0.5rem;
        --spacing-md: 0.75rem;
        --spacing-lg: 1rem;
        --spacing-xl: 1.5rem;
        --spacing-2xl: 2rem;
    }
    
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    /* Header adjustments */
    .main-header {
        height: auto;
        padding: var(--spacing-sm) 0;
    }
    
    .header-content {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .logo-section {
        width: 100%;
        justify-content: center;
    }
    
    .app-title {
        font-size: 1.5rem;
        text-align: center;
    }
    
    .connection-status {
        justify-content: center;
        margin-top: var(--spacing-sm);
    }
    
    .main-nav {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .nav-btn {
        flex: 1;
        min-width: 120px;
        padding: var(--spacing-sm) var(--spacing-xs);
        font-size: 0.8rem;
    }
    
    .nav-btn .icon {
        font-size: 1rem;
    }
    
    /* Main content adjustments */
    .main-content {
        padding-top: var(--spacing-md);
    }
    
    .section-header {
        text-align: center;
        margin-bottom: var(--spacing-lg);
    }
    
    .section-header h2 {
        font-size: 1.75rem;
    }
    
    /* Gallery controls */
    .gallery-controls {
        flex-direction: column;
        gap: var(--spacing-md);
        align-items: stretch;
    }
    
    .search-box {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .search-box input {
        width: 100%;
    }
    
    .filter-controls {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .filter-controls select {
        width: 100%;
    }
    
    /* Photo grid */
    .photo-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }
    
    .photo-item {
        aspect-ratio: 1;
    }
    
    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }
    
    .stat-card {
        padding: var(--spacing-md);
    }
    
    .stat-card h3 {
        font-size: 0.9rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 5vh auto;
    }
    
    .modal-body {
        padding: var(--spacing-md);
        flex-direction: column;
    }
    
    .modal-body img {
        max-height: 40vh;
        width: 100%;
        object-fit: contain;
    }
    
    /* Button adjustments */
    .btn {
        padding: var(--spacing-md) var(--spacing-lg);
        font-size: 0.9rem;
        width: 100%;
        justify-content: center;
    }
    
    .form-actions .btn {
        margin-bottom: var(--spacing-sm);
    }
    
    /* Typography adjustments */
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
    h5 { font-size: 1.1rem; }
    h6 { font-size: 1rem; }
}

/* Small Devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
    
    .photo-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .nav-btn {
        flex: none;
        min-width: 100px;
    }
}

/* Medium Devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }
    
    /* Header back to horizontal layout */
    .header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .logo-section {
        width: auto;
        justify-content: flex-start;
    }
    
    .app-title {
        text-align: left;
        font-size: 1.75rem;
    }
    
    .connection-status {
        justify-content: flex-start;
        margin-top: 0;
    }
    
    .main-nav {
        width: auto;
        justify-content: flex-end;
    }
    
    /* Gallery controls back to horizontal */
    .gallery-controls {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }
    
    .search-box {
        flex-direction: row;
        align-items: center;
    }
    
    .search-box input {
        width: 300px;
    }
    
    .filter-controls {
        flex-direction: row;
        gap: var(--spacing-md);
    }
    
    .filter-controls select {
        width: auto;
        min-width: 150px;
    }
    
    .photo-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--spacing-md);
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 80%;
        max-width: 800px;
    }
    
    .modal-body {
        flex-direction: row;
        gap: var(--spacing-xl);
    }
    
    .modal-body img {
        max-height: 60vh;
        width: 60%;
    }
    
    .photo-info {
        width: 40%;
    }
    
    /* Button back to inline */
    .btn {
        width: auto;
        display: inline-flex;
    }
    
    .form-actions .btn {
        margin-bottom: 0;
    }
}

/* Large Devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
    
    .photo-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .search-box input {
        width: 400px;
    }
    
    .modal-content {
        max-width: 1000px;
    }
}

/* Extra Large Devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: var(--container-max-width);
    }
    
    .photo-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* 2K and larger screens */
@media (min-width: 1400px) {
    .photo-grid {
        grid-template-columns: repeat(8, 1fr);
    }
    
    .container {
        max-width: 1320px;
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 600px) {
    .main-header {
        height: 60px;
        padding: var(--spacing-xs) 0;
    }
    
    .app-title {
        font-size: 1.25rem;
    }
    
    .nav-btn {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.8rem;
    }
    
    .modal-content {
        max-height: 95vh;
        margin: 2.5vh auto;
    }
    
    .modal-body img {
        max-height: 50vh;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Ensure crisp rendering on retina displays */
    .photo-item img,
    .upload-thumbnail,
    .modal-body img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print styles */
@media print {
    .main-header,
    .main-nav,
    .upload-section,
    .stats-section,
    .modal,
    .toast-container {
        display: none !important;
    }
    
    .main-content {
        padding-top: 0;
    }
    
    .photo-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-sm);
    }
    
    .photo-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    body {
        background: white;
        color: black;
    }
}

/* Reduced motion preferences */
@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;
    }
    
    .spinner {
        animation: none;
        border: 3px solid var(--border-color);
        border-top: 3px solid var(--primary-color);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-muted: #333333;
        --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.3);
    }
    
    .btn {
        border-width: 2px;
    }
    
    .photo-item {
        border: 2px solid var(--border-color);
    }
}

/* Focus management for keyboard navigation */
@media (hover: none) and (pointer: coarse) {
    /* Touch device optimizations */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-btn {
        min-height: 48px;
    }
    
    .photo-item {
        cursor: default;
    }
    
    .photo-item:hover {
        transform: none;
    }
}

/* Specific mobile device optimizations */
@media screen and (max-width: 480px) {
    /* Very small screens - single column layout */
    .photo-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .photo-item {
        aspect-ratio: 16/9;
        max-width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .upload-details {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 98%;
        margin: 1vh auto;
        max-height: 98vh;
    }
} 