/* style.css - Design System et Styles pour l'application WAHAB */

/* Variables & Design Tokens */
:root {
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    
    --accent: #0d9488;
    --accent-hover: #0f766e;
    
    --success: #10b981;
    --success-light: #ecfdf5;
    
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    
    --danger: #ef4444;
    --danger-light: #fef2f2;
    
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #ffffff;
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    
    --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

/* Reset et Styles Globaux */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Layout Principal */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 32px 12px;
}

.logo-icon {
    font-size: 28px;
    color: #3b82f6;
    animation: pulse 2s infinite;
}

.logo-text {
    font-size: 22px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 1px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-links li a i {
    font-size: 20px;
}

.nav-links li a:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.nav-links li.active a {
    background-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-role {
    font-weight: 600;
    color: #ffffff;
    font-size: 14px;
}

.user-status {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    color: var(--success);
    font-size: 8px;
}

/* Zone de Contenu Principal */
.main-content {
    margin-left: 260px;
    width: calc(100% - 260px);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Navbar */
.top-navbar {
    height: 70px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.nav-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
}

.search-box {
    position: relative;
    width: 300px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-app);
    font-size: 14px;
    transition: all 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

/* Corps de Contenu */
.content-body {
    padding: 32px;
    flex-grow: 1;
}

.page-section {
    display: none;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.page-section.active-section {
    display: block;
}

/* Bannières et Panneaux */
.welcome-banner {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #0d9488 100%);
    color: #ffffff;
    padding: 32px;
    border-radius: var(--radius-lg);
    margin-bottom: 32px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.welcome-banner h1 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
}

.welcome-banner p {
    opacity: 0.9;
    font-size: 16px;
}

.welcome-banner::after {
    content: '';
    position: absolute;
    right: -50px;
    top: -50px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

/* Grille de Statistiques */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
}

.stat-icon {
    font-size: 32px;
    padding: 12px;
    border-radius: var(--radius-md);
}

/* Variantes Cartes */
.stat-card.blue .stat-icon { color: var(--primary); background-color: var(--primary-light); }
.stat-card.orange .stat-icon { color: var(--warning); background-color: var(--warning-light); }
.stat-card.green .stat-icon { color: var(--success); background-color: var(--success-light); }
.stat-card.teal .stat-icon { color: var(--accent); background-color: rgba(13, 148, 136, 0.1); }
.stat-card.red .stat-icon { color: var(--danger); background-color: var(--danger-light); }

/* Panneaux Dashboard */
.dashboard-details {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 32px;
}

.dashboard-panel {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.dashboard-panel h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-main);
    border-left: 4px solid var(--primary);
    padding-left: 12px;
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-weight: 600;
    font-size: 14px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-secondary {
    background-color: #ffffff;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-app);
    border-color: var(--text-muted);
}

.btn-danger {
    background-color: var(--danger-light);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background-color: var(--danger);
    color: #ffffff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    margin-top: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background-color: #ffffff;
}

.table th {
    background-color: #f8fafc;
    padding: 16px;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
}

.badge-attente { background-color: var(--warning-light); color: var(--warning); }
.badge-repare { background-color: rgba(13, 148, 136, 0.1); color: var(--accent); }
.badge-remplace { background-color: var(--success-light); color: var(--success); }
.badge-non-rempl { background-color: var(--danger-light); color: var(--danger); }

/* Filtres */
.filter-bar {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    background-color: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}

.filter-group select {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: #ffffff;
    font-size: 14px;
    min-width: 180px;
    outline: none;
}

.filter-group select:focus {
    border-color: var(--primary);
}

/* Modals */
.modal-overlay {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-box {
    background-color: #ffffff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-box.small-modal {
    max-width: 450px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.close-modal {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.close-modal:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background-color: #f8fafc;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Formulaires */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    font-family: var(--font-family);
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.required {
    color: var(--danger);
}

.form-row {
    display: flex;
    gap: 16px;
}

.col-6 {
    flex: 1;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
}

.toast {
    min-width: 300px;
    padding: 16px;
    border-radius: var(--radius-md);
    background-color: #ffffff;
    color: var(--text-main);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 5px solid var(--primary);
    transform: translateX(120%);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateX(0);
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-info { border-left-color: var(--primary); }

/* Rapports & Onglets */
.rapport-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-main);
    background-color: rgba(0, 0, 0, 0.02);
}

.tab-btn.active {
    color: var(--primary);
    background-color: var(--primary-light);
}

.rapport-content {
    display: none;
}

.rapport-content.active-rapport {
    display: block;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background-color: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.report-meta h3 {
    font-size: 16px;
    font-weight: 700;
}

.report-meta p {
    font-size: 13px;
    color: var(--text-muted);
}

/* Timeline / Historique */
.timeline-container {
    background-color: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -32px;
    top: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #ffffff;
    border: 3px solid var(--primary);
    z-index: 2;
}

.timeline-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timeline-time {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.timeline-title {
    font-weight: 700;
    font-size: 15px;
}

.timeline-desc {
    font-size: 13px;
    color: var(--text-muted);
    background-color: var(--bg-app);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-top: 4px;
    border: 1px solid var(--border-color);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* ==================== STYLES D'IMPRESSION ==================== */
@media print {
    @page {
        margin: 0;
    }
    body {
        background-color: #ffffff;
        color: #000000;
        font-size: 12pt;
        margin: 1.6cm;
    }
    
    #app-container {
        display: none !important;
    }
    
    /* Layout d'impression de la décharge */
    .print-only {
        display: block !important;
        padding: 40px;
    }
    
    .print-header {
        text-align: center;
        border-bottom: 2px solid #000000;
        padding-bottom: 20px;
        margin-bottom: 30px;
    }
    
    .print-header h1 {
        font-size: 26px;
        font-weight: 800;
        text-transform: uppercase;
        margin-bottom: 6px;
    }
    
    .print-details {
        margin-bottom: 30px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        font-size: 14px;
    }
    
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 40px;
    }
    
    .print-table th, 
    .print-table td {
        border: 1px solid #000000;
        padding: 10px;
        text-align: left;
    }
    
    .print-table th {
        background-color: #f2f2f2 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .print-signatures {
        margin-top: 60px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        text-align: center;
    }
    
    .signature-box {
        border-top: 1px dashed #000000;
        padding-top: 10px;
        width: 200px;
        margin: 0 auto;
        font-weight: 700;
    }
    
    /* Pour imprimer les états de retour */
    .rapport-content.active-rapport {
        display: block !important;
    }
    
    .rapport-content.active-rapport .table-container {
        border: none !important;
    }
    
    .rapport-content.active-rapport table {
        width: 100% !important;
        border-collapse: collapse !important;
    }
    
    .rapport-content.active-rapport th,
    .rapport-content.active-rapport td {
        border: 1px solid #cccccc !important;
        padding: 8px !important;
    }
}

/* --- LOGIN SCREEN (AUTH) --- */
.login-overlay-full {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.15) 0%, rgba(13, 148, 136, 0.05) 90.2%), #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    color: #ffffff;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo-auth-icon {
    font-size: 48px;
    color: #3b82f6;
    margin-bottom: 10px;
    animation: pulse 2s infinite;
}

.login-logo h2 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.login-logo p {
    color: #94a3b8;
    font-size: 13px;
}

.input-with-icon {
    position: relative;
    width: 100%;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 18px;
}

.input-with-icon input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.5);
    color: #ffffff;
    outline: none;
    font-size: 14px;
    font-family: var(--font-family);
    transition: all 0.3s ease;
}

.input-with-icon input:focus {
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.login-card .form-group label {
    color: #cbd5e1;
}

.login-footer {
    text-align: center;
    margin-top: 30px;
    font-size: 11px;
    color: #64748b;
}

/* Bouton Déconnexion dans Sidebar */
.nav-logout-btn {
    margin-top: auto; /* Pousse le bouton de déconnexion tout en bas de la sidebar */
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 12px;
}

.nav-logout-btn a:hover {
    background-color: rgba(239, 68, 68, 0.1) !important;
}
