/* style.css - version intégrale */
:root {
    --bg-body: #0a0e14;
    --bg-sidebar: #05080c;
    --bg-card: #11151c;
    --bg-card-hover: #1a1f2e;
    --bg-input: #0d1118;
    --bg-overlay: rgba(0, 0, 0, 0.8);
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --primary-dim: rgba(59, 130, 246, 0.1);
    --primary-hover: #2563eb;
    --success: #10b981;
    --success-dim: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-dim: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-dim: rgba(239, 68, 68, 0.1);
    --purple: #8b5cf6;
    --purple-dim: rgba(139, 92, 246, 0.1);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --border: #2d3748;
    --border-light: #1e293b;
    --radius-md: 12px;
    --radius-sm: 6px;
    --sidebar-width: 280px;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; outline: none; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    background-image: radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.03) 0%, transparent 30%);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

/* Auth */
.auth-container {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--primary);
}
.auth-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.auth-tab {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}
.auth-tab.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}
.auth-form {
    display: none;
    flex-direction: column;
    gap: 1rem;
}
.auth-form.active { display: flex; }
.auth-error {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 1rem;
    text-align: center;
}

/* Layout */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: 70px 1fr;
    width: 100%;
    height: 100%;
}
.sidebar {
    grid-row: 1 / -1;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.2rem;
    overflow-y: auto;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2rem;
    text-decoration: none;
}
.brand-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px var(--primary-glow);
}
.nav-group-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin: 1.5rem 0 0.5rem 0.5rem;
    font-weight: 700;
}
.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}
.nav-item:hover {
    background-color: rgba(255,255,255,0.03);
    color: var(--text-main);
}
.nav-item.active {
    background: linear-gradient(90deg, var(--primary-dim) 0%, transparent 100%);
    color: var(--primary);
}
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem 0.5rem;
    border-top: 1px solid var(--border);
}
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}
.user-info {
    flex: 1;
}
.user-name { font-weight: 600; font-size: 0.85rem; }
.user-role { font-size: 0.7rem; color: var(--text-muted); }

/* Header */
.top-header {
    grid-column: 2;
    background: rgba(19, 22, 31, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.select-wrapper {
    position: relative;
    display: inline-block;
}
.custom-select {
    appearance: none;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
}
.select-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}
.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}
.btn-outline {
    border-color: var(--border);
    background: transparent;
    color: var(--text-main);
}
.btn-outline:hover {
    border-color: var(--text-muted);
    background: rgba(255,255,255,0.05);
}
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}
.btn-icon:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-main);
}

/* Main content */
.main-content {
    grid-column: 2;
    overflow-y: auto;
    padding: 2rem;
}
.section {
    display: none;
    animation: fadeIn 0.3s;
}
.section.active { display: block; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* KPI */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    position: relative;
    transition: transform 0.2s;
}
.kpi-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--kpi-color, var(--primary));
}
.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}
.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

/* Cards & Charts */
.charts-container {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}
.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}
.chart-wrapper {
    height: 300px;
    position: relative;
}

/* Tables */
.data-table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 2rem;
}
.category-header {
    background: rgba(59, 130, 246, 0.1);
    padding: 0.5rem 1.5rem;
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-light);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    background: rgba(0,0,0,0.4);
    text-align: left;
    padding: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
    font-size: 0.85rem;
}
.data-table tr:hover td {
    background: rgba(255,255,255,0.02);
}

/* Inputs */
.input-control {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 6px 10px;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    width: 100%;
}
.input-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-dim);
}
.input-nostyle {
    background: transparent;
    border: none;
    width: 100%;
    font-family: inherit;
    color: inherit;
}
.input-nostyle:focus {
    outline: none;
    border-bottom: 1px solid var(--primary);
}
.sm { padding: 4px 8px; font-size: 0.8rem; }

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}
.badge-s1 { background: var(--danger-dim); color: var(--danger); }
.badge-s2 { background: var(--warning-dim); color: var(--warning); }
.badge-s3 { background: var(--purple-dim); color: var(--purple); }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 2rem;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(120%);
    transition: transform 0.3s;
}
.toast.show { transform: translateX(0); }
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    z-index: 200;
}
.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Export dropdown */
.export-menu { position: relative; }
.export-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    min-width: 200px;
    display: none;
    z-index: 50;
}
.export-dropdown.show { display: block; }
.export-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-main);
}
.export-item:hover { background: rgba(255,255,255,0.05); }

/* Responsive */
@media (max-width: 1024px) {
    .app-layout { grid-template-columns: 80px 1fr; }
    .brand-text, .nav-item span, .user-info { display: none; }
    .charts-container { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .app-layout { display: flex; flex-direction: column; height: auto; overflow: auto; }
    .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 1rem; }
    .kpi-grid { grid-template-columns: 1fr; }
}