/* V-Cert - Dark/Light Theme */

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

:root {
    --bg: #1a1a2e;
    --sidebar-bg: #16213e;
    --border: #0f3460;
    --card-bg: #16213e;
    --text: #e0e0e0;
    --text-muted: #888;
    --text-dim: #666;
    --heading: #fff;
    --accent: #4ecca3;
    --input-bg: #0f3460;
    --input-border: #1a3a6e;
    --row-hover: #16213e;
    --nav-link-color: #b0b0b0;
    --toast-success-bg: #0d4a3a;
    --toast-success-fg: #4ecca3;
    --toast-success-border: #1a6e4a;
    --toast-success-bar: #4ecca3;
    --toast-error-bg: #4a0d0d;
    --toast-error-fg: #e94560;
    --toast-error-border: #6e1a1a;
    --toast-error-bar: #e94560;
    --toast-warning-bg: #4a3a0d;
    --toast-warning-fg: #f0c040;
    --toast-warning-border: #6e5a1a;
    --toast-warning-bar: #f0c040;
    --toast-info-bg: #0d2a4a;
    --toast-info-fg: #5dade2;
    --toast-info-border: #1a3a6e;
    --toast-info-bar: #5dade2;
}

body.light {
    --bg: #f0f2f5;
    --sidebar-bg: #fff;
    --border: #ccc;
    --card-bg: #fff;
    --text: #222;
    --text-muted: #555;
    --text-dim: #666;
    --heading: #1a1a2e;
    --accent: #1e8f5a;
    --input-bg: #fff;
    --input-border: #bbb;
    --row-hover: #e8eaed;
    --nav-link-color: #555;
    --toast-success-bg: #d4edda;
    --toast-success-fg: #155724;
    --toast-success-border: #b8d9c5;
    --toast-success-bar: #28a745;
    --toast-error-bg: #f8d7da;
    --toast-error-fg: #721c24;
    --toast-error-border: #f0b8be;
    --toast-error-bar: #dc3545;
    --toast-warning-bg: #fff3cd;
    --toast-warning-fg: #856404;
    --toast-warning-border: #ffeaa7;
    --toast-warning-bar: #e0a800;
    --toast-info-bg: #d1ecf1;
    --toast-info-fg: #0c5460;
    --toast-info-border: #b8daff;
    --toast-info-bar: #17a2b8;
}
body.light label { color: var(--text); }
body.light .card .label { color: var(--text-muted); }
body.light .card .detail { color: var(--text-dim); }
body.light .action-card p { color: var(--text-muted); }
body.light th { color: var(--text-muted); }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

.content { padding: 30px; flex: 1; min-height: 100vh; }

h1 { font-size: 24px; color: var(--heading); margin-bottom: 24px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
h2 { font-size: 16px; color: var(--accent); margin: 20px 0 12px 0; text-transform: uppercase; letter-spacing: 0.5px; }

.cards { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    min-width: 180px;
    flex: 1;
}

.card .label { color: #888; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.card .value { font-size: 28px; font-weight: 700; color: var(--heading); }
.card .value.ok { color: #4ecca3; }
.card .value.warn { color: #f9a825; }
.card .value.error { color: #e94560; }
.card .detail { color: #666; font-size: 11px; margin-top: 4px; }

.status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-running { background: #0d4a3a; color: #4ecca3; }
.status-stopped { background: #4a0d0d; color: #e94560; }
.status-unknown { background: #3a3a0d; color: #f9a825; }

table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--card-bg); color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
tr:hover { background: var(--row-hover); }
td { font-size: 13px; font-family: 'Consolas', 'Courier New', monospace; }

.form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }

input[type="text"], input[type="number"], select, textarea {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Consolas', 'Courier New', monospace;
}

input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { width: 100%; min-height: 80px; resize: vertical; }
label { color: #b0b0b0; font-size: 13px; min-width: 140px; }

.btn {
    display: inline-block;
    padding: 8px 18px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary { background: var(--accent); color: #1a1a2e; }
.btn-primary:hover { background: #3db88e; }
.btn-success { background: #4ecca3; color: #1a1a2e; }
.btn-success:hover { background: #3db88e; }
.btn-warning { background: #f9a825; color: #1a1a2e; }
.btn-warning:hover { background: #e09620; }
.btn-danger { background: #8b0000; color: #fff; }
.btn-danger:hover { background: #a00000; }
.btn-sm { padding: 4px 10px; font-size: 11px; }

.alert { padding: 12px 16px; border-radius: 4px; margin-bottom: 20px; font-size: 13px; }
.alert-success { background: #0d4a3a; color: #4ecca3; border: 1px solid #1a6e4a; }
.alert-error { background: #4a0d0d; color: #e94560; border: 1px solid #6e1a1a; }
.alert-info { background: #0d2a4a; color: #5dade2; border: 1px solid #1a3a6e; }

/* Toast: geré par lib-toasts */
@keyframes toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}
@keyframes toast-progress {
    from { width: 100%; }
    to { width: 0; }
}

.actions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 24px; }
.action-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.action-card h3 { color: var(--heading); font-size: 14px; margin-bottom: 8px; }
.action-card p { color: #888; font-size: 12px; margin-bottom: 14px; line-height: 1.4; }

.config-section { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.config-section h3 { color: var(--heading); font-size: 14px; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.config-table { border-collapse: collapse; }
.config-table th, .config-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.config-table th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }

/* Task planification - modern layout */
.task-plan-section { padding: 24px !important; }
.task-status-bar {
    display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
    padding: 14px 18px; background: rgba(0,0,0,0.15); border-radius: 10px; margin-bottom: 24px;
}
body.light .task-status-bar { background: rgba(0,0,0,0.04); }
.task-status-badge {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 600;
}
.task-status-badge .task-status-dot { width: 8px; height: 8px; border-radius: 50%; }
.task-status-badge.status-on { background: rgba(78, 204, 163, 0.2); color: #4ecca3; }
.task-status-badge.status-on .task-status-dot { background: #4ecca3; box-shadow: 0 0 8px #4ecca3; }
.task-status-badge.status-off { background: rgba(233, 69, 96, 0.15); color: #e94560; }
.task-status-badge.status-off .task-status-dot { background: #e94560; }
.task-status-badge.status-unknown { background: rgba(136, 136, 136, 0.2); color: var(--text-muted); }
.task-status-details { display: flex; gap: 20px; flex-wrap: wrap; font-size: 13px; color: var(--text-muted); }
.task-status-item { display: inline-flex; align-items: center; gap: 4px; }
.task-result-ok { color: #4ecca3; font-weight: 600; }
.task-result-err { color: #e94560; font-weight: 600; }
.task-actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.task-action-group {
    padding: 16px; background: rgba(0,0,0,0.08); border-radius: 10px; border: 1px solid var(--border);
}
body.light .task-action-group { background: rgba(0,0,0,0.03); }
.task-action-group-title {
    display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--text-muted); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.task-action-buttons { display: flex; flex-direction: column; gap: 8px; }
.task-exec-hint { margin: 10px 0 0 0; font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.task-btn {
    display: inline-flex; align-items: center; gap: 10px; width: 100%; justify-content: center;
    padding: 12px 18px; border: none; border-radius: 8px; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
    font-family: inherit;
}
.task-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.task-btn:active { transform: translateY(0); }
.task-btn-primary { background: linear-gradient(135deg, var(--accent) 0%, #3db88e 100%); color: #1a1a2e; }
.task-btn-primary:hover { filter: brightness(1.08); }
.task-btn-success { background: linear-gradient(135deg, #4ecca3 0%, #3db88e 100%); color: #1a1a2e; }
.task-btn-success:hover { filter: brightness(1.08); }
.task-btn-warning { background: linear-gradient(135deg, #f9a825 0%, #e09620 100%); color: #1a1a2e; }
.task-btn-warning:hover { filter: brightness(1.08); }
.task-btn-danger { background: linear-gradient(135deg, #c0392b 0%, #a93226 100%); color: #fff; }
.task-btn-danger:hover { filter: brightness(1.1); }
.task-btn-secondary { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); }
.task-btn-secondary:hover { background: var(--row-hover); }
.task-script-path { margin-top: 16px; font-size: 11px; color: var(--text-muted); }
.task-script-path code { font-family: Consolas, monospace; font-size: 11px; }
.task-history-section { padding: 24px !important; }
.task-history-table { font-size: 13px; }
.task-history-table tbody tr:hover { background: rgba(0,0,0,0.06); }
.task-log-row:hover { background: rgba(78, 204, 163, 0.08) !important; }
body.light .task-history-table tbody tr:hover { background: rgba(0,0,0,0.03); }
.task-history-empty {
    text-align: center; padding: 40px 20px; color: var(--text-muted);
}
.task-history-empty svg { opacity: 0.4; margin-bottom: 12px; }
.task-history-empty p { margin: 0 0 6px 0; font-size: 14px; }
.task-history-empty-hint { font-size: 12px; opacity: 0.8; }

/* Tabs */
.tabs-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 10px 18px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color .2s, border-color .2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.tab-panel { display: none; animation: tabFadeIn .2s ease; }
.tab-panel.active { display: block; }
@keyframes tabFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Back to top */
.back-to-top {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 900;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: #1a1a2e;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s, transform .3s;
    transform: translateY(12px);
}
.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.back-to-top:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.back-to-top svg { width: 20px; height: 20px; }

.log-output {
    background: #101a33;
    color: #d7e3ff;
    border: 1px solid #1a3a6e;
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 340px;
    font-size: 11px;
    line-height: 1.45;
}
body.light .log-output {
    background: #eef3ff;
    color: #10243f;
    border-color: #b8c8e8;
}

.search-box { margin-bottom: 16px; }
.search-box input { width: 300px; padding: 8px 14px; background: var(--input-bg); border: 1px solid var(--input-border); color: var(--text); border-radius: 4px; font-size: 13px; }
.search-box input:focus { outline: none; border-color: var(--accent); }

.table-wrap { max-height: 600px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; }
.table-wrap table { margin-bottom: 0; }
.table-wrap th { position: sticky; top: 0; z-index: 1; }

/* Light mode: meilleur contraste pour textes secondaires et alertes */
body.light p[style*="color:#888"],
body.light p[style*="color: #888"],
body.light span[style*="color:#888"],
body.light span[style*="color: #888"] { color: var(--text-muted) !important; }
body.light span.quota-warn,
body.light span[style*="color:#f9a825"],
body.light span[style*="color: #f9a825"],
body.light p[style*="color:#f9a825"],
body.light p[style*="color: #f9a825"] { color: #b8860b !important; }
body.light .card .value.warn { color: #b8860b; }
