/* =========================
   VARIABLES & RESET
   ========================= */

:root {
    --background: #0e1117;
    --card-bg: #1e2130;
    --border: #2e3440;
    --primary: #4a9eff;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --text: #ffffff;
    --text-muted: #adb5bd;
}

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

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

/* =========================
   AUTH VIEW (LOGIN)
   ========================= */

.auth-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-view h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.input-group {
    width: 100%;
    max-width: 350px;
    margin-bottom: 15px;
}

.input-group input {
    width: 100%;
    padding: 12px 15px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

/* =========================
   BUTTONS
   ========================= */

.btn {
    padding: 10px 20px;
    font-size: 0.95rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: #3a8eef;
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

/* =========================
   TOP MENU (macOS style)
   ========================= */

.top-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    gap: 20px;
    z-index: 1000;
}

.menu-left h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.menu-center {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: center;
}

.date-input {
    padding: 8px 12px;
    font-size: 0.95rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #2e3440;
    /* Fond plus clair que var(--background) */
    color: var(--text);
    cursor: pointer;
}

.date-input::-webkit-calendar-picker-indicator {
    filter: brightness(2) contrast(0.8);
    /* Éclaircit l'icône */
    cursor: pointer;
    opacity: 1;
}

.date-input:focus {
    outline: none;
    border-color: var(--primary);
}

.menu-right {
    display: flex;
    gap: 10px;
}

/* =========================
   DASHBOARD LAYOUT
   ========================= */

.main-content {
    padding: 80px 20px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* KPIs */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
}

.kpi-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

@media (max-width: 900px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
}

.chart-container h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.chart-wrapper {
    position: relative;
    height: 400px;
}

.chart-wrapper canvas {
    max-height: 400px;
}

/* Table */
.table-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
}

.table-container h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.table-wrapper {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

thead {
    position: sticky;
    top: 0;
    background: var(--background);
    z-index: 10;
}

th {
    text-align: left;
    padding: 12px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* =========================
   MODAL
   ========================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
}

.modal-content h2 {
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    margin: 20px 0;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: rgba(74, 158, 255, 0.05);
}

.upload-label {
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
}

/* Upload Tabs */
.upload-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 10px 15px;
    font-size: 0.95rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

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

.tab-btn:hover:not(.active) {
    border-color: var(--primary);
    background: rgba(74, 158, 255, 0.1);
}

/* CSV Textarea */
.csv-textarea {
    width: 100%;
    padding: 15px;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    color: var(--text);
    resize: vertical;
    min-height: 200px;
}

.csv-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.csv-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.upload-message {
    padding: 10px;
    border-radius: 6px;
    margin-top: 15px;
    font-size: 0.95rem;
}

.upload-message.success {
    background: rgba(40, 167, 69, 0.2);
    color: var(--success);
    border: 1px solid var(--success);
}

.upload-message.error {
    background: rgba(220, 53, 69, 0.2);
    color: var(--danger);
    border: 1px solid var(--danger);
}

/* =========================
   RESPONSIVE
   ========================= */

@media (max-width: 768px) {
    .top-menu {
        flex-wrap: wrap;
        height: auto;
        padding: 10px;
    }

    .menu-left,
    .menu-center,
    .menu-right {
        width: 100%;
        justify-content: center;
    }

    .menu-center {
        margin: 10px 0;
    }

    .main-content {
        padding: 150px 15px 15px;
    }

    .kpis {
        grid-template-columns: repeat(2, 1fr);
    }
}