/* Variables de thème (clair par défaut) */
:root {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --accent-color: #4361ee;
    --accent-light: #e0e7ff;
    --danger-color: #e63946;
    --warning-color: #f4a261;
    --success-color: #2a9d8f;
    --info-color: #4cc9f0;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --font-family: 'Inter', sans-serif;
}

/* Thème sombre */
body.dark {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-card: #2d2d2d;
    --text-primary: #f8f9fa;
    --text-secondary: #adb5bd;
    --border-color: #495057;
    --accent-color: #5a6bff;
    --accent-light: #2d3b8c;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
    min-height: 100vh;
    padding: 16px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 8px;
}

header h1 i {
    margin-right: 10px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
}

.theme-toggle button {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.theme-toggle button:hover {
    background: var(--accent-light);
}

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

.tab {
    flex: 1;
    min-width: 120px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 12px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab:hover {
    background: var(--accent-light);
    color: var(--accent-color);
}

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

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

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

/* Barre de statut */
.status-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.status-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-item .label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-item .value {
    font-weight: 600;
    font-size: 1rem;
}

#status-indicator i {
    color: var(--success-color);
    margin-right: 6px;
}

#refreshBtn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

#refreshBtn:hover {
    background: #3a56d4;
}

/* Grille des métriques */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.metric-card:hover {
    transform: translateY(-4px);
}

.card-cpu {
    border-top: 4px solid var(--accent-color);
}

.card-memory {
    border-top: 4px solid var(--success-color);
}

.card-disk {
    border-top: 4px solid var(--warning-color);
}

.card-system {
    border-top: 4px solid var(--info-color);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.metric-header h3 {
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.badge.alert {
    background: var(--danger-color);
    color: white;
}

.badge.ok {
    background: var(--success-color);
    color: white;
}

.metric-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.metric-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.task-progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}
.task-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #3b82f6);
    border-radius: 4px;
    transition: width 1s ease;
}

.progress-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s;
}

.card-cpu .progress-fill {
    background: var(--accent-color);
}

.card-memory .progress-fill {
    background: var(--success-color);
}

.card-disk .progress-fill {
    background: var(--warning-color);
}

/* Système */
.system-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.system-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
}

.system-row i {
    width: 20px;
    color: var(--accent-color);
}

/* Résumé des alertes */
.alert-summary {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.alert-summary h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--success-color);
}

.alert-summary.alert-active h3 {
    color: var(--danger-color);
}

/* Graphiques */
.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.graph-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.graph-controls select, .graph-controls button {
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: inherit;
}

.graph-controls button {
    background: var(--accent-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    height: 300px;
}

/* Section alertes */
.alerts-section, .config-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.alerts-list {
    margin-top: 16px;
}

.alert-item {
    background: rgba(230, 57, 70, 0.1);
    border-left: 4px solid var(--danger-color);
    padding: 16px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.no-alerts {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Configuration */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input[type="range"] {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    background: var(--bg-primary);
    outline: none;
    -webkit-appearance: none;
}

.form-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
}

.form-group span {
    display: inline-block;
    margin-left: 12px;
    font-weight: 600;
    color: var(--accent-color);
    min-width: 40px;
}

.btn-save {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

.btn-save:hover {
    background: #3a56d4;
}

#config-status {
    margin-top: 16px;
    padding: 12px;
    border-radius: var(--radius);
    text-align: center;
}

#config-status.success {
    background: rgba(42, 157, 143, 0.1);
    color: var(--success-color);
}

#config-status.error {
    background: rgba(230, 57, 70, 0.1);
    color: var(--danger-color);
}

/* À propos */
.about-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow);
    text-align: center;
}

.about-card h2 {
    margin-bottom: 20px;
    color: var(--accent-color);
}

.about-card p {
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.about-card hr {
    margin: 24px 0;
    border: none;
    height: 1px;
    background: var(--border-color);
}

.btn-github {
    margin-top: 20px;
    background: #333;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* Footer */
footer {
    margin-top: 40px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.footer-note {
    margin-top: 8px;
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 768px) {
    .tabs {
        flex-direction: column;
    }
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    .status-bar {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    .theme-toggle {
        position: static;
        margin-top: 16px;
        align-self: flex-end;
    }
    .graph-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .chart-container {
        height: 250px;
    }
}

/* === TASKS TAB === */
.tasks-container h2, .tasks-container h3 {
    margin-bottom: 12px;
    color: var(--text-primary);
}
.task-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}
.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.task-status {
    font-weight: 600;
    font-size: 14px;
}
.task-status.running { color: #f59e0b; }
.task-status.done { color: #10b981; }
.task-status.error { color: #ef4444; }
.task-runtime {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}
.task-name {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.task-progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}
.task-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #3b82f6);
    border-radius: 4px;
    transition: width 1s ease;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #3b82f6);
    border-radius: 4px;
    transition: width 1s ease;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}
.task-details {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}
.task-empty {
    text-align: center;
    padding: 40px;
    color: #10b981;
    font-size: 18px;
}
.task-empty i {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}
.task-history {
    max-height: 200px;
    overflow-y: auto;
}
.task-history-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}
.task-history-item .status-icon {
    margin-right: 8px;
}
.log-container {
    background: #1a1a2e;
    color: #a0ffa0;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 12px;
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.4;
}
.log-line {
    padding: 2px 0;
    white-space: pre-wrap;
    word-break: break-all;
}
.log-line.error { color: #ff6b6b; }
.log-line.warn { color: #ffd93d; }
.log-line.info { color: #6bc5ff; }

/* PDF Status Grid */
.pdf-status-container {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 8px;
}
.pdf-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.pdf-stat {
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
}
.pdf-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.pdf-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent-color);
}
/* Pipeline progress */
.pipeline-progress-container { background: #1e1e1e; border-radius:8px; padding:12px; margin-bottom:8px; }
.pipeline-status { font-size:14px; font-weight:bold; margin-bottom:6px; }
.pipeline-steps { margin-top:8px; }
.pipeline-step { font-size:12px; padding:2px 0; color:#ccc; }

/* ===== PIPELINE TAB ===== */
.pipeline-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.pipeline-section h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 10px;
}
.pipeline-tools-table {
    background: var(--bg-primary);
    border-radius: 8px;
    overflow: hidden;
}
.pipeline-tools-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
}
.pipeline-tools-table td {
    font-size: 0.85rem;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-color);
}
.pipeline-tools-table tr:last-child td {
    border-bottom: none;
}
.otel-metrics-preview {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 12px;
    max-height: 250px;
    overflow-y: auto;
    line-height: 1.6;
    color: var(--text-secondary);
}
.otel-metrics-preview .metric-line {
    padding: 2px 0;
    white-space: pre-wrap;
    word-break: break-all;
}
.otel-ok { color: var(--success-color); }
.otel-err { color: var(--danger-color); }
