﻿/* =============================================
   responsive.css — Global responsive overrides
   À inclure dans index.html après app.css
   ============================================= */

/* =============================================
   UTILITAIRES GLOBAUX
   ============================================= */

* {
    box-sizing: border-box;
}

img, video, iframe {
    max-width: 100%;
}

/* =============================================
   GRILLES GLOBALES
   Tous les composants qui utilisent une grille
   auto-fill tombent automatiquement en colonne
   ============================================= */

@media (max-width: 640px) {

    /* Grilles auto-fill → 1 colonne */
    [style*="auto-fill"],
    .clients-grid,
    .produits-grid,
    .dashboard-grid,
    .categories-grid {
        grid-template-columns: 1fr !important;
    }

    /* Form layouts 2-col → 1 colonne */
    .form-layout {
        grid-template-columns: 1fr !important;
    }

    .form-row {
        grid-template-columns: 1fr !important;
    }

    .form-main {
        order: 1;
    }

    .form-sidebar {
        order: 2; /* ← reste en bas */
    }

    /* Tables → scroll horizontal */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Headers page */
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }

        .page-header h1 {
            font-size: 1.4rem !important;
        }

    /* Filters bar → colonne */
    .filters-bar {
        flex-direction: column;
        align-items: stretch !important;
    }

    .search-box {
        min-width: unset !important;
    }

    /* Cards actions → wrap */
    .card-actions,
    .produit-actions {
        flex-wrap: wrap;
    }

    .btn-action {
        min-width: calc(50% - 0.25rem);
        flex: none !important;
    }
}

/* =============================================
   TABLET (641px – 1024px)
   ============================================= */

@media (min-width: 641px) and (max-width: 1024px) {

    .form-layout {
        grid-template-columns: 1fr 260px !important;
    }

    .clients-grid,
    .produits-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .page-header h1 {
        font-size: 1.6rem !important;
    }
}

/* =============================================
   INTERVENTIONS TABLE — responsive
   ============================================= */

@media (max-width: 768px) {
    .interventions-table th:nth-child(3),
    .interventions-table td:nth-child(3),
    .interventions-table th:nth-child(5),
    .interventions-table td:nth-child(5) {
        display: none;
    }
}

@media (max-width: 480px) {
    .interventions-container {
        padding: 0.75rem !important;
    }

    .interventions-table th:nth-child(2),
    .interventions-table td:nth-child(2) {
        display: none;
    }
}

/* =============================================
   MODALS — responsive
   ============================================= */

@media (max-width: 640px) {
    .js-modal {
        padding: 1.25rem !important;
        border-radius: 12px 12px 0 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        max-width: 100% !important;
        max-height: 90dvh !important;
        animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .js-modal-overlay {
        align-items: flex-end !important;
    }

    /* Blazor modals */
    .modal-card {
        max-width: 100% !important;
        border-radius: 16px 16px 0 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        max-height: 92dvh !important;
        animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .modal-overlay {
        align-items: flex-end !important;
    }

    /* Detail grids in modals */
    .detail-grid,
    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .detail-section.full-width,
    .form-group.full-width {
        grid-column: 1 !important;
    }
}

/* =============================================
   DASHBOARD
   ============================================= */

@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
    }

    .card-value {
        font-size: 1.3rem !important;
    }
}

/* =============================================
   NEW FORMS (produit, client, categorie…)
   ============================================= */

@media (max-width: 640px) {
    .new-produit-page,
    .new-client-page,
    .new-categorie-page,
    .new-souscategorie-page {
        max-width: 100% !important;
    }

    .qualite-options {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    .margin-preview {
        margin-top: 0.75rem;
    }

    /* Layout interventions */
    .layout-grid {
        grid-template-columns: 1fr !important;
    }

    .sidebar {
        position: static !important;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .form-group.full-width {
        grid-column: 1 !important;
    }
}

/* =============================================
   USER INFO PAGE
   ============================================= */

@media (max-width: 640px) {
    .user-page {
        max-width: 100% !important;
        margin: 0 !important;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .form-actions {
        flex-direction: column !important;
    }
}

/* =============================================
   CATEGORIES PAGE
   ============================================= */

@media (max-width: 640px) {
    .subcategory-panel {
        max-width: 100% !important;
        border-radius: 16px 16px 0 0 !important;
    }

    .subcategory-overlay {
        align-items: flex-end !important;
    }
}

/* =============================================
   TOUCH IMPROVEMENTS
   ============================================= */

@media (hover: none) and (pointer: coarse) {
    /* Agrandir les zones cliquables sur tactile */
    .btn-action {
        min-height: 40px;
    }

    .sidebar-link {
        min-height: 48px;
    }

    /* Cacher les animations au hover (économie batterie) */
    .produit-card:hover,
    .client-card:hover,
    .dashboard-card:hover {
        transform: none !important;
    }
}

/* =============================================
   ANIMATIONS
   ============================================= */

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}
