/* ═══════════════════════════════════════════════════════════════
   OpusWebcam V2.0 - Responsive Design
   Fichier: responsive.css
   Description: Adaptations pour tous les écrans et devices
   ═══════════════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────────────────────────
   BREAKPOINTS
   ─────────────────────────────────────────────────────────────── */
/* 
   - Mobile: < 576px
   - Tablet: 576px - 768px
   - Desktop: 768px - 1200px
   - Large: > 1200px
*/

/* ───────────────────────────────────────────────────────────────
   LARGE SCREENS (> 1200px)
   ─────────────────────────────────────────────────────────────── */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
    
    .sidebar {
        width: 320px;
    }
    
    .inventory-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    .header h1 {
        font-size: 3rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .kpi-value {
        font-size: 2.5rem;
    }
}

/* ───────────────────────────────────────────────────────────────
   DESKTOP (768px - 1200px)
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .inventory-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    }
    
    .charts-grid {
        grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    }
}

/* ───────────────────────────────────────────────────────────────
   TABLET (576px - 768px)
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Sidebar Mobile */
    .sidebar-toggle {
        display: block;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: calc(var(--z-fixed) + 10);
        background: white;
        border: none;
        border-radius: var(--border-radius-md);
        box-shadow: var(--shadow-lg);
        padding: var(--space-sm) var(--space-md);
        font-size: 1.5rem;
        color: var(--primary);
        cursor: pointer;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        background: white;
        z-index: var(--z-fixed);
        transform: translateX(-100%);
        transition: transform var(--transition-slow);
        box-shadow: 2px 0 16px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    body.sidebar-open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: calc(var(--z-fixed) - 1);
    }
    
    /* Layout ajustements */
    .app-container {
        flex-direction: column;
    }
    
    .main-content {
        padding: var(--space-md);
        padding-top: 4rem;
    }
    
    /* Header */
    .header h1 {
        font-size: 2rem;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    /* Navigation */
    .nav-tabs {
        flex-wrap: wrap;
    }
    
    .nav-tabs .nav-link {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.875rem;
    }
    
    /* Cards Grid */
    .inventory-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: var(--space-md);
    }
    
    /* Modal */
    .modal-content {
        margin: var(--space-md);
        width: calc(100% - 2rem);
    }
    
    .modal-body {
        grid-template-columns: 1fr;
        padding: var(--space-lg);
    }
    
    .modal-image {
        max-width: 200px;
        margin: 0 auto;
    }
    
    /* Tables */
    .inventory-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .inventory-table {
        min-width: 600px;
    }
    
    /* Dashboard */
    .kpi-section {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    /* Buttons */
    .validation-actions {
        flex-wrap: wrap;
    }
    
    .inventory-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .view-selector {
        width: 100%;
        justify-content: center;
    }
}

/* ───────────────────────────────────────────────────────────────
   MOBILE (< 576px)
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 576px) {
    /* Typography */
    html {
        font-size: 14px;
    }
    
    .header h1 {
        font-size: 1.75rem;
    }
    
    .header p {
        font-size: 0.875rem;
    }
    
    /* Spacing */
    .main-content {
        padding: var(--space-sm);
        padding-top: 3.5rem;
    }
    
    .content-section {
        padding: var(--space-md);
        border-radius: var(--border-radius-lg);
    }
    
    /* Sidebar */
    .sidebar {
        width: 100%;
        max-width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }
    
    /* Navigation tabs */
    .nav-tabs {
        gap: 2px;
        margin-bottom: var(--space-md);
    }
    
    .nav-tabs .nav-link {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.75rem;
    }
    
    .nav-tabs .nav-link .tab-badge {
        min-width: 16px;
        height: 16px;
        font-size: 0.625rem;
    }
    
    /* Cards */
    .inventory-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: var(--space-sm);
    }
    
    .card-name {
        font-size: 0.75rem;
    }
    
    .card-series {
        font-size: 0.625rem;
    }
    
    /* Validation Cards */
    .validation-card .card-body {
        padding: var(--space-sm);
    }
    
    .validation-actions {
        flex-direction: column;
    }
    
    .validation-actions button {
        width: 100%;
    }
    
    /* Dashboard */
    .kpi-section {
        grid-template-columns: 1fr;
    }
    
    .kpi-card {
        padding: var(--space-md);
    }
    
    .kpi-icon {
        font-size: 2rem;
    }
    
    .kpi-value {
        font-size: 1.5rem;
    }
    
    /* Tables */
    .table {
        font-size: 0.875rem;
    }
    
    .table td,
    .table th {
        padding: var(--space-sm);
    }
    
    /* Modals */
    .modal-header {
        padding: var(--space-md);
    }
    
    .modal-header h4 {
        font-size: 1.125rem;
    }
    
    .modal-body {
        padding: var(--space-md);
    }
    
    .modal-footer {
        flex-direction: column;
        padding: var(--space-md);
    }
    
    .modal-footer button {
        width: 100%;
    }
    
    /* Forms */
    .form-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .form-row label {
        width: 100%;
        margin-bottom: var(--space-xs);
    }
    
    /* Buttons */
    .btn {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.875rem;
    }
    
    .btn-custom {
        padding: var(--space-sm) var(--space-lg);
        font-size: 0.875rem;
    }
    
    /* View Selector */
    .view-selector button {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.75rem;
    }
    
    /* Empty States */
    .empty-state {
        padding: var(--space-lg);
    }
    
    .empty-state h4 {
        font-size: 1.125rem;
    }
    
    .empty-state p {
        font-size: 0.875rem;
    }
}

/* ───────────────────────────────────────────────────────────────
   VERY SMALL DEVICES (< 360px)
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 360px) {
    .inventory-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .nav-tabs .nav-link {
        padding: var(--space-xs);
        font-size: 0.625rem;
    }
}

/* ───────────────────────────────────────────────────────────────
   LANDSCAPE MODE
   ─────────────────────────────────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
    .app-container {
        flex-direction: row;
    }
    
    .sidebar {
        width: 250px;
        position: relative;
        transform: none;
    }
    
    .main-content {
        padding: var(--space-sm);
    }
    
    .header {
        margin-bottom: var(--space-md);
    }
    
    .header h1 {
        font-size: 1.75rem;
    }
    
    .header p {
        display: none;
    }
    
    .video-container {
        max-height: 60vh;
    }
    
    .recent-matches {
        max-height: 150px;
    }
}

/* ───────────────────────────────────────────────────────────────
   PRINT STYLES
   ─────────────────────────────────────────────────────────────── */
@media print {
    /* Reset colors for print */
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    /* Hide non-printable elements */
    .sidebar,
    .sidebar-toggle,
    .nav-tabs,
    .btn,
    button,
    .modal,
    .toast-container,
    #videoBox,
    #overlay,
    .status-indicator,
    .detection-animation {
        display: none !important;
    }
    
    /* Layout adjustments */
    .app-container {
        display: block;
    }
    
    .main-content {
        padding: 0;
    }
    
    .content-section {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }
    
    /* Show all tabs content */
    .tab-pane {
        display: block !important;
        page-break-before: always;
    }
    
    /* Cards adjustments */
    .inventory-card,
    .validation-card {
        break-inside: avoid;
        border: 1px solid #ddd;
    }
    
    /* Tables */
    table {
        border-collapse: collapse;
    }
    
    th, td {
        border: 1px solid #ddd;
    }
    
    /* Links */
    a[href]:after {
        content: " (" attr(href) ")";
    }
    
    /* Page numbers */
    @page {
        margin: 2cm;
    }
}

/* ───────────────────────────────────────────────────────────────
   ACCESSIBILITY
   ─────────────────────────────────────────────────────────────── */
@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;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --primary: #0066cc;
        --secondary: #6600cc;
        --success: #008000;
        --danger: #cc0000;
        --warning: #cc6600;
    }
    
    * {
        border-width: 2px !important;
    }
    
    .btn,
    .card,
    .modal-content {
        border: 2px solid currentColor !important;
    }
}

/* Dark Mode Support (Future) */
@media (prefers-color-scheme: dark) {
    /* Prepared for future dark mode implementation */
}