/* Mobile First Responsive Design */

/* Small devices (phones, 576px and up) */
@media (max-width: 575.98px) {
    .container {
        padding: 0 var(--space-3);
    }
    
    .nav-container {
        padding: 0 var(--space-3);
        height: 56px;
    }
    
    .nav-menu {
        display: none;
    }
    
    .nav-actions {
        gap: var(--space-2);
    }
    
    .btn {
        padding: var(--space-2) var(--space-4);
        font-size: var(--font-size-xs);
    }
    
    .btn-lg {
        padding: var(--space-3) var(--space-6);
        font-size: var(--font-size-sm);
    }
    
    .hero-container {
        grid-template-columns: 1fr;
        gap: var(--space-8);
        text-align: center;
    }
    
    .hero-logo-img {
        height: 60px;
        max-width: 150px;
    }
    
    .hero-title {
        font-size: var(--font-size-3xl);
    }
    
    .hero-description {
        font-size: var(--font-size-base);
    }
    
    .hero-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .hero-actions .btn {
        width: 100%;
        max-width: 300px;
    }
    
    .hero-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .har-preview {
        padding: var(--space-6);
        max-width: 250px;
    }
    
    .har-stats {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }
    
    .compact-upload {
        margin-top: var(--space-4);
        padding-top: var(--space-4);
    }
    
    .compact-upload-area {
        padding: var(--space-3);
    }
    
    .compact-upload-content {
        flex-direction: column;
        gap: var(--space-1);
    }
    
    .compact-upload-options {
        padding: var(--space-3);
    }
    
    .compact-upload-options .form-actions {
        flex-direction: column;
    }
    
    .compact-upload-options .form-actions .btn {
        width: 100%;
    }
    
    .stats-toggle {
        margin-bottom: var(--space-1);
        padding-bottom: var(--space-1);
    }
    
    .files-toggle {
        margin: var(--space-2) 0;
        padding: var(--space-2) 0;
    }
    
    .files-toggle .toggle-container {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }
    
    .files-toggle .toggle-buttons {
        width: 100%;
    }
    
    .files-toggle .toggle-btn {
        flex: 1;
        min-width: 0;
    }
    
    .files-table-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }
    
    .files-table-header .search-box {
        max-width: none;
    }
    
    .toggle-container {
        flex-direction: column;
        gap: var(--space-2);
    }
    
    .toggle-buttons {
        width: 100%;
    }
    
    .toggle-btn {
        flex: 1;
        min-width: auto;
    }
    
    .section-title {
        font-size: var(--font-size-2xl);
    }
    
    .upload-area {
        padding: var(--space-8);
    }
    
    .upload-icon {
        font-size: var(--font-size-3xl);
    }
    
    .upload-title {
        font-size: var(--font-size-lg);
    }
    
    .files-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    .file-card {
        padding: var(--space-4);
    }
    
    .file-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
    }
    
    .file-actions {
        opacity: 1;
        align-self: flex-end;
    }
    
    .file-stats {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }
    
    .section-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        min-width: auto;
    }
    
    .search-box .clear-btn {
        right: var(--space-3);
    }
    
    .search-box .results-count {
        right: var(--space-10);
        font-size: 0.7rem;
        padding: var(--space-1);
    }
    
    .modal-content {
        margin: var(--space-4);
        max-width: calc(100vw - var(--space-8));
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--space-4);
    }
    
    .preview-tabs {
        flex-wrap: wrap;
    }
    
    .tab-btn {
        padding: var(--space-2) var(--space-4);
        font-size: var(--font-size-sm);
    }
    
    .toast-container {
        left: var(--space-3);
        right: var(--space-3);
    }
    
    .toast {
        min-width: auto;
    }
    
    /* Sluice section responsive */
    .sluice-info {
        grid-template-columns: 1fr;
        gap: var(--space-8);
    }
    
    .sluice-features {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    .sluice-download {
        position: static;
    }
    
    .download-info {
        flex-direction: column;
        align-items: center;
        gap: var(--space-2);
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .hero-container {
        grid-template-columns: 1fr;
        gap: var(--space-12);
    }
    
    .hero-title {
        font-size: var(--font-size-4xl);
    }
    
    .files-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .file-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .section-actions {
        flex-direction: row;
        align-items: center;
    }
    
    .search-box {
        min-width: 250px;
    }
    
    /* Sluice section responsive */
    .sluice-features {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .hero-container {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-12);
    }
    
    .files-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .file-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 992px) {
    .files-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Extra extra large devices (1400px and up) */
@media (min-width: 1200px) {
    .files-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print styles */
@media print {
    .navbar,
    .nav-actions,
    .hero-actions,
    .upload-section,
    .modal,
    .toast-container {
        display: none !important;
    }
    
    .main-content {
        padding-top: 0;
    }
    
    .file-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .hero {
        background: none;
        padding: var(--space-4) 0;
    }
    
    .hero-title {
        color: #000;
    }
    
    .hero-description {
        color: #333;
    }
}

/* 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;
    }
    
    .spinner {
        animation: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --bg-tertiary: #334155;
        --text-primary: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-muted: #64748b;
        --border-color: #334155;
        --border-hover: #475569;
    }
    
    .hero {
        background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    }
    
    .hero::before {
        opacity: 0.1;
    }
}

/* Focus styles for accessibility */
@media (prefers-reduced-motion: no-preference) {
    .btn:focus,
    .nav-link:focus,
    .file-card:focus,
    .tab-btn:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
    
    .form-group input:focus,
    .form-group textarea:focus,
    .form-group select:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-secondary: #000;
        --text-muted: #333;
    }
    
    .btn-outline {
        border-width: 2px;
    }
    
    .file-card {
        border-width: 2px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 767.98px) and (orientation: landscape) {
    .hero {
        padding: var(--space-12) 0;
    }
    
    .hero-container {
        gap: var(--space-6);
    }
    
    .hero-logo-img {
        height: 50px;
        max-width: 120px;
    }
    
    .hero-title {
        font-size: var(--font-size-2xl);
    }
    
    .hero-description {
        font-size: var(--font-size-sm);
    }
    
    .upload-section {
        padding: var(--space-12) 0;
    }
    
    .files-section {
        padding: var(--space-12) 0;
    }
}

/* Very small screens (320px and below) */
@media (max-width: 320px) {
    .container {
        padding: 0 var(--space-2);
    }
    
    .nav-container {
        padding: 0 var(--space-2);
    }
    
    .hero-title {
        font-size: var(--font-size-2xl);
    }
    
    .hero-description {
        font-size: var(--font-size-sm);
    }
    
    .upload-area {
        padding: var(--space-6);
    }
    
    .file-card {
        padding: var(--space-3);
    }
    
    .modal-content {
        margin: var(--space-2);
        max-width: calc(100vw - var(--space-4));
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .file-card:hover {
        transform: none;
    }
    
    .file-actions {
        opacity: 1;
    }
    
    .btn:hover {
        transform: none;
    }
    
    .nav-link:hover {
        background-color: transparent;
    }
    
    .nav-link.active {
        background-color: var(--primary-light);
    }
}

/* Hover-capable devices */
@media (hover: hover) and (pointer: fine) {
    .file-card:hover .file-actions {
        opacity: 1;
    }
    
    .user-menu:hover .user-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

/* Preview Modal Responsive Styles */
@media (max-width: 768px) {
    .preview-tabs {
        flex-wrap: wrap;
        gap: var(--space-1);
    }
    
    .tab-btn {
        flex: 1;
        min-width: 0;
        padding: var(--space-2) var(--space-3);
        font-size: var(--font-size-sm);
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }
    
    .stat-card {
        padding: var(--space-3);
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: var(--font-size-md);
    }
    
    .requests-table {
        font-size: var(--font-size-sm);
    }
    
    .requests-table th,
    .requests-table td {
        padding: var(--space-2) var(--space-3);
    }
    
    .url-cell {
        max-width: 150px;
    }
    
    .timeline-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }
    
    .timeline-legend {
        flex-wrap: wrap;
        gap: var(--space-2);
    }
    
    .performance-grid {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }
    
    .metric-card {
        padding: var(--space-3);
    }
    
    .metric-icon {
        width: 40px;
        height: 40px;
        font-size: var(--font-size-md);
    }
}

@media (max-width: 480px) {
    .hero-logo-img {
        height: 45px;
        max-width: 100px;
    }
    
    .preview-tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        text-align: left;
        border-bottom: 1px solid var(--border-light);
        border-radius: 0;
    }
    
    .tab-btn.active {
        border-bottom-color: var(--primary-color);
        background-color: var(--bg-secondary);
    }
    
    .status-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }
    
    .status-bar-fill {
        width: 100%;
        height: 6px;
    }
    
    .requests-table {
        font-size: var(--font-size-xs);
    }
    
    .method-badge,
    .status-badge {
        font-size: var(--font-size-xs);
        padding: var(--space-1);
    }
    
    .user-avatar-img {
        width: 20px;
        height: 20px;
    }
}
