:root {
    --primary: #1e3a5f;
    --secondary: #2d5a8e;
    --accent: #3b82f6;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --background: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #334155;
    --text-muted: #64748b;
    --border: #e2e8f0;
    
    --risk-faible: #22c55e;
    --risk-modere: #f59e0b;
    --risk-eleve: #f97316;
    --risk-critique: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
}

/* Typography */
h1, h2, h3, h4 { color: var(--primary); margin-bottom: 0.5rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}
.alert-danger { background-color: #fee2e2; color: #991b1b; border: 1px solid #f87171; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}
.btn-primary { background-color: var(--accent); color: white; }
.btn-primary:hover { background-color: #2563eb; }
.btn-outline { background-color: transparent; border-color: var(--border); color: var(--text-main); }
.btn-outline:hover { background-color: var(--border); }
.btn-block { display: block; width: 100%; }
.btn-large { padding: 0.75rem 1.5rem; font-size: 1.1rem; }

/* Login Page */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}
.login-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}
.login-card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.login-title { font-size: 1.5rem; text-align: center; margin-bottom: 0.25rem; }
.login-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
label { display: block; font-weight: 500; margin-bottom: 0.5rem; }
input[type="text"], input[type="password"], textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
}
input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Layout */
.app-header {
    background: var(--primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
}
.app-header h1 { color: white; margin: 0; font-size: 1.25rem; }
.header-user { display: flex; align-items: center; gap: 1rem; }
.header-user .btn-outline { color: white; border-color: rgba(255,255,255,0.3); }
.header-user .btn-outline:hover { background: rgba(255,255,255,0.1); }

.dashboard-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem;
    max-width: 1680px;
    margin: 0 auto;
}

.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Drag & Drop */
.drag-drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 1.5rem;
}
.drag-drop-zone:hover, .drag-drop-zone.dragover {
    border-color: var(--accent);
    background: #eff6ff;
}
.drop-icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; }
.image-preview { margin-top: 1rem; }
.image-preview img { max-width: 100%; max-height: 250px; border-radius: 4px; }
.file-name { margin-top: 0.5rem; font-weight: 500; font-size: 0.9rem; }

/* Grid Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
.grid-2-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 768px) {
    .grid-2-col { grid-template-columns: 1fr; }
}

/* Sidebar History */
.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 0.5rem;
}
.history-card-header h2 { margin-bottom: 0; }
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.history-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.history-item {
    position: relative;
    padding: 1rem;
    padding-right: 2.25rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}
.history-item:hover { background: #f8fafc; }
.hist-id { font-weight: bold; display: block; font-size: 0.9rem; }
.hist-date { color: var(--text-muted); font-size: 0.8rem; display: block; }
.hist-zone { margin: 0.25rem 0; font-size: 0.95rem; }
.history-delete-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 1.5rem;
    height: 1.5rem;
    line-height: 1.5rem;
    text-align: center;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
}
.history-delete-btn:hover { background: #fee2e2; color: var(--danger); }

/* Checkbox groups */
.checkbox-group {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: normal;
    cursor: pointer;
}
.checkbox-inline input[type="checkbox"] {
    width: auto;
}

/* Status & Badges */
.status-banner {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-weight: bold;
    text-align: center;
    font-size: 1.25rem;
}
.status-conforme { background-color: #dcfce7; color: #166534; border: 1px solid #86efac; }
.status-non-conforme { background-color: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.status-info-insuffisante { background-color: #fef3c7; color: #92400e; border: 1px solid #fde047; }

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
}
.badge-conforme { background: var(--success); color: white; }
.badge-non-conforme { background: var(--danger); color: white; }
.badge-insuffisant { background: var(--warning); color: white; }
.badge-true { background: var(--danger); color: white; }
.badge-false { background: var(--success); color: white; }

/* Risk Colors */
.risk-faible { background-color: #dcfce7 !important; color: #166534; }
.risk-modere { background-color: #fef3c7 !important; color: #92400e; }
.risk-eleve { background-color: #ffedd5 !important; color: #9a3412; }
.risk-critique { background-color: #fee2e2 !important; color: #991b1b; }

/* Info Cards */
.info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.info-card {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--accent);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.info-card h3 { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 0.25rem; }
.info-card p { font-size: 1.1rem; font-weight: bold; }

/* Comparison Grid */
.comparison-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    text-align: center;
}
.comp-box { padding: 1rem; background: #f8fafc; border-radius: 4px; }
.comp-box h4 { margin-bottom: 0.5rem; font-size: 0.9rem; color: var(--text-muted); }
.comp-box.final { background: #eff6ff; border: 1px solid #bfdbfe; }

/* Tables */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}
.table-responsive.card {
    max-width: none;
}
.data-table {
    width: 100%;
    min-width: 1100px;
    border-collapse: collapse;
    font-size: 1rem;
}
.data-table th, .data-table td {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    line-height: 1.6;
}
.data-table th {
    background: #f8fafc;
    font-weight: bold;
    color: var(--primary);
    font-size: 0.95rem;
    white-space: nowrap;
}

/* Lists */
.list-section ul { padding-left: 1.5rem; }
.list-section li { margin-bottom: 0.5rem; }

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.spinner {
    width: 50px; height: 50px;
    border: 5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Report Page */
.report-wrapper { min-height: 80vh; padding: 2rem; }
.report-main { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }
.loading-text { text-align: center; color: var(--text-muted); margin-top: 2rem; }

/* Badge Levels (inline in table) */
.badge-level {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
}
.badge-faible { background: #dcfce7; color: #166534; }
.badge-modere { background: #fef3c7; color: #92400e; }
.badge-eleve { background: #ffedd5; color: #9a3412; }
.badge-critique { background: #fee2e2; color: #991b1b; }

/* Level text colors */
.level-faible { color: var(--risk-faible); }
.level-modere { color: var(--risk-modere); }
.level-eleve { color: var(--risk-eleve); }
.level-critique { color: var(--risk-critique); }

/* Actions cell */
.actions-cell { font-size: 0.95rem; line-height: 1.7; min-width: 220px; }
.actions-cell strong { color: var(--primary); }

/* Actions bar */
.actions-bar {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Results animation */
.results-section {
    animation: fadeIn 0.5s ease-in-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Print styles */
@media print {
    .app-header, .dashboard-sidebar, .loading-overlay, .actions-bar, .upload-section { display: none !important; }
    .dashboard-layout { grid-template-columns: 1fr !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    body { background: white; }
}