/* responsive.css - Media queries pour l'affichage mobile */

/* Amélioration accessibilité - taille minimum des boutons tactiles */
.btn, button, input, select {
    min-height: 44px;
    touch-action: manipulation;
}

/* Amélioration PWA - éviter le zoom automatique */
input, select, textarea {
    font-size: 16px !important;
}

/* Pull-to-refresh pour mobile */
.pull-to-refresh {
    position: relative;
    overflow: hidden;
}

.pull-to-refresh-indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.pull-to-refresh-indicator.visible {
    opacity: 1;
    top: 20px;
}

.pull-to-refresh-indicator.loading {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translateX(-50%) rotate(0deg); }
    100% { transform: translateX(-50%) rotate(360deg); }
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--glass-bg) 25%, rgba(255,255,255,0.1) 50%, var(--glass-bg) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}

.skeleton-text {
    height: 14px;
    margin: 8px 0;
    border-radius: 4px;
}

.skeleton-text.title {
    height: 20px;
    width: 60%;
}

.skeleton-text.subtitle {
    height: 16px;
    width: 40%;
}

.skeleton-box {
    height: 200px;
    border-radius: 12px;
    margin: 16px 0;
}

.skeleton-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
}

.skeleton-stat {
    height: 100px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.skeleton-table-row {
    display: flex;
    gap: 16px;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.skeleton-table-cell {
    height: 16px;
    border-radius: 4px;
    flex: 1;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* === RÈGLES D'AFFICHAGE TABLE/CARTES - SOLUTION PROPRE === */

/* DESKTOP : Tableaux uniquement (règle par défaut) */
body:not(.mobile-mode) .results-grid,
body:not(.mobile-mode) .reports-table-mobile,
body:not(.mobile-mode) .result-card,
body:not(.mobile-mode) .report-card {
    display: none !important;
}

body:not(.mobile-mode) .table-container {
    display: block !important;
}

/* MODE MOBILE DÉTECTÉ : Masquer les tableaux, afficher les cartes */
body.mobile-mode .table-container {
    display: none !important;
}

body.mobile-mode .results-grid {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 20px;
}

body.mobile-mode .reports-table-mobile {
    display: block !important;
}

body.mobile-mode .result-card,
body.mobile-mode .report-card {
    display: block !important;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 16px;
}

body.mobile-mode .result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Masquer le bouton hamburger sur desktop */
.hamburger-btn {
    display: none;
}

/* Menu hamburger pour PWA mobile */
@media (max-width: 768px) {
    .nav-container {
        position: relative;
    }
    
    /* Bouton hamburger */
    .hamburger-btn {
        display: block;
        position: fixed;
        top: 20px;
        right: 20px;
        z-index: 1001;
        background: var(--primary-gradient);
        border: none;
        border-radius: 12px;
        padding: 12px;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .hamburger-btn:hover {
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    }
    
    .hamburger-icon {
        width: 24px;
        height: 20px;
        position: relative;
        transform: rotate(0deg);
        transition: 0.3s ease-in-out;
    }
    
    .hamburger-icon span {
        display: block;
        position: absolute;
        height: 3px;
        width: 100%;
        background: white;
        border-radius: 9px;
        opacity: 1;
        left: 0;
        transform: rotate(0deg);
        transition: 0.25s ease-in-out;
    }
    
    .hamburger-icon span:nth-child(1) { top: 0px; }
    .hamburger-icon span:nth-child(2) { top: 8px; }
    .hamburger-icon span:nth-child(3) { top: 16px; }
    
    /* Animation hamburger vers X */
    .hamburger-btn.open .hamburger-icon span:nth-child(1) {
        top: 8px;
        transform: rotate(135deg);
    }
    
    .hamburger-btn.open .hamburger-icon span:nth-child(2) {
        opacity: 0;
        left: -60px;
    }
    
    .hamburger-btn.open .hamburger-icon span:nth-child(3) {
        top: 8px;
        transform: rotate(-135deg);
    }
    
    /* Menu dépliable */
    .nav-tabs {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: var(--glass-bg);
        backdrop-filter: blur(20px);
        border-left: 1px solid var(--border-color);
        z-index: 1000;
        padding: 80px 20px 20px;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
        transition: right 0.3s ease;
        flex-direction: column;
        gap: 16px;
        overflow-y: auto;
    }
    
    .nav-tabs.open {
        right: 0;
    }
    
    .nav-tab {
        width: 100%;
        text-align: left;
        padding: 16px 20px;
        font-size: 16px;
        border-radius: 12px;
        min-height: 56px;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        transition: all 0.3s ease;
        border: 1px solid transparent;
    }
    
    .nav-tab:hover {
        transform: translateX(-4px);
        border-color: var(--border-color);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    }
    
    .nav-tab.active {
        background: var(--primary-gradient);
        color: white;
        transform: translateX(-8px);
        box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    }
    
    /* Overlay pour fermer le menu */
    .nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .nav-overlay.open {
        opacity: 1;
        visibility: visible;
    }
    
    /* === MOBILE: Layout uniquement === */
    /* L'affichage cartes/tableaux est géré par .mobile-mode en JavaScript */
    
    /* Styles .result-card maintenant dans les règles .mobile-mode */
    
    .result-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 16px;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--border-color);
    }
    
    .result-card-title {
        font-weight: bold;
        font-size: 16px;
        color: var(--text-primary);
    }
    
    .result-card-badge {
        background: var(--primary-gradient);
        color: white;
        padding: 4px 12px;
        border-radius: 20px;
        font-size: 12px;
        font-weight: 500;
    }
    
    .result-card-body {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        font-size: 14px;
    }
    
    .result-card-field {
        display: flex;
        flex-direction: column;
    }
    
    .result-card-label {
        font-size: 11px;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 4px;
    }
    
    .result-card-value {
        color: var(--text-primary);
        font-weight: 500;
    }
    
    .result-card-weight {
        grid-column: span 2;
        text-align: center;
        padding: 12px;
        background: rgba(102, 126, 234, 0.1);
        border-radius: 8px;
        margin-top: 8px;
    }
    
    .result-card-weight .result-card-value {
        font-size: 18px;
        font-weight: bold;
        color: #667eea;
    }
    
    /* MOBILE : Afficher les cartes de rapports */
    .reports-table-mobile {
        display: block;
    }
    
    /* MOBILE : Afficher les cartes de rapports individuelles */
    .report-card {
        display: block;
        background: var(--glass-bg);
        backdrop-filter: blur(10px);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .report-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--border-color);
    }
    
    .report-card-date {
        font-weight: bold;
        color: var(--text-primary);
        font-size: 14px;
    }
    
    .report-card-weight {
        background: var(--primary-gradient);
        color: white;
        padding: 4px 8px;
        border-radius: 12px;
        font-size: 12px;
        font-weight: bold;
    }
    
    .report-card-body {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        font-size: 12px;
    }
    
    .report-card-field {
        display: flex;
        flex-direction: column;
    }
    
    .report-card-field-label {
        color: var(--text-secondary);
        font-size: 10px;
        text-transform: uppercase;
        margin-bottom: 2px;
    }
    
    .report-card-field-value {
        color: var(--text-primary);
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* === DESKTOP: Tableaux uniquement === */
@media (min-width: 769px) {
    /* DESKTOP : Masquer toutes les cartes */
    .results-grid,
    .reports-table-mobile,
    .result-card,
    .report-card {
        display: none;
    }
    
    /* DESKTOP : Afficher les tableaux */
    .table-container {
        display: block;
    }
}

/* Mobile Layout et Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 12px;
        margin: 0;
    }
    
    .header-content {
        padding: 0 16px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .logo-text {
        font-size: 18px;
    }

    .user-section {
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
    }

    .status-indicator {
        padding: 6px 12px;
        font-size: 12px;
    }

    .user-info {
        font-size: 12px;
        text-align: right;
    }

    .btn-logout {
        padding: 8px 16px;
        font-size: 14px;
    }

    .main-content {
        padding: 20px 12px;
    }

    .search-form {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .search-actions {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .search-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
        font-size: 14px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .stat-card {
        padding: 20px 16px;
    }

    .stat-icon {
        width: 48px;
        height: 48px;
        font-size: 18px;
        margin-bottom: 16px;
    }

    .stat-value {
        font-size: 24px;
    }

    .stat-label {
        font-size: 12px;
    }

    .card {
        padding: 20px 16px;
        margin-bottom: 20px;
    }

    .card-header {
        margin-bottom: 20px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .card-title {
        font-size: 18px;
    }

    .ticket-details {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .nav-tabs {
        padding: 16px 0;
        gap: 6px;
    }

    .nav-tab {
        padding: 10px 16px;
        font-size: 14px;
        border-radius: 8px;
    }

    .chart-container {
        padding: 20px 16px;
        height: 300px;
    }

    .ticket-preview {
        padding: 16px 12px;
        margin: 16px 0;
    }

    .ticket-header h2 {
        font-size: 1.1em;
    }

    .ticket-header h3 {
        font-size: 1em;
    }

    .ticket-actions {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .reports-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .comparison-grid {
        grid-template-columns: 1fr;
    }
    
    .reports-actions {
        flex-direction: column;
    }
    
    .table-controls {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Breakpoint tablet intermédiaire */
@media (max-width: 768px) and (min-width: 481px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .stat-card {
        padding: 18px 14px;
    }
}

/* Très petits écrans */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .header-content {
        justify-content: space-between;
    }

    .user-section {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .user-info {
        display: none;
    }

    .status-indicator span {
        display: none;
    }

    .status-indicator {
        padding: 8px;
        border-radius: 50%;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .btn-logout {
        padding: 6px 12px;
        font-size: 12px;
    }

    .main-content {
        padding: 16px 8px;
    }

    .card {
        padding: 16px 12px;
    }

    .search-actions .btn {
        padding: 10px 18px;
        font-size: 13px;
    }

    .nav-tab {
        padding: 8px 14px;
        font-size: 13px;
        border-radius: 8px;
    }
    
    .data-table {
        min-width: 500px;
    }

    .chart-container {
        height: 250px;
        padding: 16px 12px;
    }
}

/* Amélioration du scroll horizontal */
.nav-tabs::-webkit-scrollbar {
    height: 4px;
}

.nav-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.nav-tabs::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.table-container::-webkit-scrollbar {
    height: 6px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--darker-bg);
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.4);
}