/**
 * Styles responsive pour tous les écrans
 * Mobile first approach
 */

/* ============================================
   MOBILE (jusqu'à 639px)
   ============================================ */
@media screen and (max-width: 639px) {
    :root {
        --spacing-xl: 1.5rem;
        --spacing-2xl: 2rem;
    }
    
    .header {
        padding: 0 var(--spacing-md);
    }
    
    .logo-text {
        display: none;
    }
    
    .main-content {
        padding: var(--spacing-md);
    }
    
    .main-content.with-header {
        padding-top: calc(var(--header-height) + var(--spacing-md));
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .page-title {
        font-size: var(--font-size-xl);
    }
    
    .btn-export .btn-export-label {
        display: none;
    }
    
    .card {
        padding: var(--spacing-lg);
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-row .form-group {
        min-width: 100%;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .card-grid {
        grid-template-columns: 1fr;
    }
    
    .links-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .table th,
    .table td {
        padding: var(--spacing-sm);
        font-size: var(--font-size-sm);
    }

    /* Orders table - extra compact for 14 columns */
    .page-orders .table th,
    .page-orders .table td {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: var(--font-size-xs);
    }
    
    .detail-list {
        grid-template-columns: 1fr;
    }
    
    .detail-list dt {
        font-weight: 600;
        margin-top: var(--spacing-md);
    }
    
    .detail-list dd {
        margin-bottom: var(--spacing-sm);
    }
    
    .login-box {
        padding: var(--spacing-xl);
    }
    
    .error-code {
        font-size: 5rem;
    }
    
    .interlocutors-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   TABLET (640px - 1023px)
   ============================================ */
@media screen and (min-width: 640px) and (max-width: 1023px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .links-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .sidebar {
        width: 320px;
    }
}

/* ============================================
   DESKTOP (1024px et plus)
   ============================================ */
@media screen and (min-width: 1024px) {
    .main-content {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .links-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .login-container {
        max-width: 450px;
    }
}

/* ============================================
   LARGE DESKTOP (1440px et plus)
   ============================================ */
@media screen and (min-width: 1440px) {
    .main-content {
        max-width: 1600px;
        padding: var(--spacing-2xl);
    }
    
    .main-content.with-header {
        padding-top: calc(var(--header-height) + var(--spacing-2xl));
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .header,
    .sidebar,
    .sidebar-overlay,
    .menu-toggle,
    .lang-selector,
    .btn {
        display: none !important;
    }
    
    .main-content {
        padding: 0 !important;
    }
    
    .main-content.with-header {
        padding-top: 0 !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .card {
        border: 1px solid var(--border-color);
        break-inside: avoid;
    }
}

/* ============================================
   ACCESSIBILITY - Reduced motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* ============================================
   ACCESSIBILITY - High contrast
   ============================================ */
@media (prefers-contrast: high) {
    :root {
        --border-color: currentColor;
        --input-border: currentColor;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .card {
        border-width: 2px;
    }
}

/* ============================================
   TOUCH DEVICES
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-link {
        min-height: 48px;
    }
    
    .form-input,
    .form-select {
        min-height: 44px;
    }
    
    .lang-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ============================================
   BROADCAST BANNER - Responsive
   ============================================ */
@media (max-width: 768px) {
    .broadcast-item {
        flex-direction: column;
        gap: var(--spacing-xs);
    }

    .broadcast-date {
        align-self: flex-end;
    }

    .broadcast-text {
        /* Tronquer à 2 lignes sur mobile */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}
}
