/* MoePlanning — Charte Teal/Slate */
:root {
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #99f6e4;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #0d9488;
    --header-bg: #ffffff;
    --body-bg: #f1f5f9;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --card-bg: #ffffff;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--body-bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* Header */
.header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: 56px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 16px; }

.hamburger-btn {
    background: none; border: none; font-size: 20px; cursor: pointer;
    color: var(--text); padding: 4px 8px; border-radius: 6px;
}
.hamburger-btn:hover { background: var(--body-bg); }

.logo {
    font-size: 20px; font-weight: 900; color: var(--primary);
    text-decoration: none; letter-spacing: -0.5px;
}
.logo b { color: var(--text); }
.logo:hover { text-decoration: none; color: var(--primary); }

.version-badge {
    font-size: 11px; font-weight: 700; color: var(--text);
    text-align: right; line-height: 1.3;
}
.version-git { font-size: 10px; color: var(--text-muted); font-weight: 500; }
.dev-tag {
    font-size: 10px; font-weight: 900; color: var(--success);
    background: #ecfdf5; padding: 1px 6px; border-radius: 4px; margin-left: 4px;
}

/* Magic fill button */
.magic-btn {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: white; border: none; border-radius: 8px;
    width: 36px; height: 36px; font-size: 18px;
    cursor: pointer; transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(245,158,11,0.3);
}
.magic-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(245,158,11,0.5);
}

/* Sidebar */
.sidebar {
    position: fixed; top: 56px; left: 0; bottom: 0;
    width: 200px; background: #fff; border-right: 2px solid var(--border);
    padding: 6px 0; overflow-y: auto;
    scrollbar-width: none; -ms-overflow-style: none;
    transition: width 0.2s ease;
    z-index: 90;
}
.sidebar::-webkit-scrollbar { display: none; }
.sidebar.collapsed { width: 56px; padding: 12px 0; overflow: hidden; }
.sidebar.collapsed .menu-item { padding: 10px 0; justify-content: center; gap: 0; }
.sidebar.collapsed .menu-item span:not(.menu-icon) { display: none; }
.sidebar.collapsed .menu-icon { margin: 0; font-size: 20px; }

.menu-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 24px;
    color: var(--text-muted); text-decoration: none;
    font-size: 14px; font-weight: 600;
    transition: all 0.2s;
    position: relative;
}
.menu-item:hover {
    background: var(--body-bg);
    color: var(--text);
}
.menu-item.active {
    background: linear-gradient(to right, #f0fdfa, #fff);
    color: var(--primary);
    border-right: 3px solid var(--primary);
}
.menu-icon { font-size: 20px; flex-shrink: 0; }

/* Main content */
.main-content {
    margin-top: 56px;
    margin-left: 200px;
    padding: 24px;
    min-height: calc(100vh - 56px);
    transition: margin-left 0.2s ease;
}
.main-content.expanded { margin-left: 56px; }

/* Page header */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.page-title { font-size: 22px; font-weight: 800; color: var(--text); }

/* Cards */
.card {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: 12px; padding: 20px;
}

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    background: var(--body-bg); padding: 10px 12px;
    font-weight: 700; color: var(--text-muted); text-align: left;
    border-bottom: 2px solid var(--border); font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
tbody td {
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:hover { background: #f8fafc; }
/* Ligne de totaux : meme padding que tbody pour aligner les colonnes */
tfoot td {
    padding: 10px 12px; border-top: 2px solid var(--border);
    vertical-align: middle;
}

/* Progress bar */
.progress-bar-wrap {
    width: 100%; height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden;
}
.progress-bar-fill {
    height: 100%; border-radius: 4px; transition: width 0.3s;
}
.progress-bar-fill.green { background: var(--success); }
.progress-bar-fill.yellow { background: var(--warning); }
.progress-bar-fill.red { background: var(--danger); }
.progress-bar-fill.teal { background: var(--primary); }

/* Status badges */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 6px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-draft { background: #f1f5f9; color: #64748b; }
.badge-active { background: #ecfdf5; color: #059669; }
.badge-onhold { background: #fef3c7; color: #d97706; }
.badge-completed { background: #dbeafe; color: #2563eb; }
.badge-cancelled { background: #fee2e2; color: #dc2626; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border: none; border-radius: 8px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    text-decoration: none; transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-secondary { background: var(--body-bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase;
    letter-spacing: 0.3px;
}
.form-control {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px; font-family: inherit;
    background: white; color: var(--text);
    transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,148,136,0.1); }
select.form-control { appearance: auto; }

/* Alerts */
.alert {
    padding: 12px 16px; border-radius: 8px; margin-bottom: 16px;
    font-size: 13px; font-weight: 500;
}
.alert-success { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }

/* Error banner */
.error-banner {
    display: flex; align-items: center; justify-content: space-between;
    background: #dc2626; color: white;
    padding: 10px 16px; border-radius: 8px; margin-bottom: 16px;
    font-size: 13px; font-weight: 600;
    animation: slideDown 0.2s ease;
}
.error-banner-left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.error-banner-msg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.error-banner-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.error-banner-x {
    background: none; border: none; color: white; font-size: 20px;
    cursor: pointer; padding: 0 4px; line-height: 1; opacity: 0.7;
}
.error-banner-x:hover { opacity: 1; }
@@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* Error modal */
.error-modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.5); align-items: center; justify-content: center;
}
.error-modal-overlay.visible { display: flex; }
.error-modal {
    background: white; border-radius: 12px; width: 90%; max-width: 640px;
    max-height: 80vh; display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.error-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.error-modal-close {
    background: none; border: none; font-size: 22px; cursor: pointer;
    color: var(--text-muted); padding: 0 4px;
}
.error-modal-close:hover { color: var(--text); }
.error-modal-body {
    flex: 1; overflow: auto; padding: 16px 20px; margin: 0;
    font-family: 'Consolas', 'Monaco', monospace; font-size: 12px;
    line-height: 1.6; color: var(--text); background: #f8fafc;
    white-space: pre-wrap; word-break: break-all;
}
.error-modal-footer {
    display: flex; align-items: center; justify-content: flex-end; gap: 8px;
    padding: 12px 20px; border-top: 1px solid var(--border);
}

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab {
    padding: 10px 20px; font-size: 13px; font-weight: 600;
    color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all 0.15s; text-decoration: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Responsive */

/* WBS Tree */
.wbs-tree { padding: 8px 0; }
.wbs-node { margin-left: 0; }
.wbs-children { margin-left: 24px; }
.wbs-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 4px; cursor: default; font-size: 14px; }
.wbs-row[onclick] { cursor: pointer; }
.wbs-row:hover { background: var(--body-bg); }
.wbs-row-project { font-size: 15px; background: #f0fdfa; border: 1px solid var(--primary-light); border-radius: 6px; margin-bottom: 4px; }
.wbs-row-phase { color: var(--primary-dark); }
.wbs-row-lot { color: #475569; }
.wbs-row-task { color: var(--text); font-size: 13px; }
.wbs-toggle { width: 16px; text-align: center; font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.wbs-icon { font-size: 14px; flex-shrink: 0; }
.wbs-meta { margin-left: auto; font-size: 12px; color: var(--text-muted); font-weight: 400; white-space: nowrap; }
.wbs-badge-phase { font-size: 10px; background: #e0f2fe; color: #0369a1; padding: 1px 7px; border-radius: 8px; font-weight: 600; }

/* Gantt */
.gantt-phase .bar { fill: var(--primary) !important; }
.gantt-phase .bar-progress { fill: var(--primary-dark) !important; }
.gantt-task .bar { fill: #60a5fa !important; }
.gantt-task .bar-progress { fill: #2563eb !important; }
.gantt .bar-label { fill: #fff !important; font-size: 12px !important; }
#gantt-target svg { min-height: 200px; }
.gantt-zoom.active { background: var(--primary) !important; color: #fff !important; }

/* ─── Accordion ────────────────────────────────────────── */
.accordion { border: 1px solid var(--border); border-radius: 12px; background: var(--card-bg); overflow: hidden; }
.accordion-header { display: flex; align-items: center; gap: 10px; padding: 14px 20px; cursor: pointer; user-select: none; background: var(--card-bg); border-bottom: 1px solid transparent; transition: background 0.15s; }
.accordion-header:hover { background: #f8fafc; }
.accordion-icon { font-size: 12px; transition: transform 0.2s; color: var(--text-muted); }
.accordion-body { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.accordion-body.open { max-height: 5000px; border-top: 1px solid var(--border); }
.accordion-toggle { display: inline-block; font-size: 13px; color: var(--text-muted); transition: transform 0.2s; min-width: 14px; order: -1; }
.accordion-toggle.open { transform: rotate(90deg); }

/* ─── CRA / Timesheets ─────────────────────────────────── */
.cra-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.cra-grid thead th { background: var(--body-bg); padding: 8px 6px; font-weight: 700; font-size: 12px; border-bottom: 2px solid var(--border); }
.cra-grid tbody td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.cra-input { width: 56px; padding: 6px 4px; text-align: center; border: 1.5px solid #94a3b8; border-radius: 6px; font-size: 13px; font-weight: 600; background: #fff; }
.cra-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,148,136,0.1); }
.cra-input[readonly] { background: var(--body-bg); color: var(--text-muted); cursor: not-allowed; }
.cra-total-ok { color: var(--success); font-weight: 700; }
.cra-total-warn { color: var(--warning); font-weight: 700; }
.cra-total-over { color: var(--danger); font-weight: 700; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-muted); padding: 2px 6px; border-radius: 4px; }
.btn-icon:hover { background: #fee2e2; color: var(--danger); }

.badge-submitted { background: #dbeafe; color: #1e40af; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-paid { background: #e0e7ff; color: #3730a3; }

/* ─── Costs layout 80/20 ──────────────────────────────── */
.costs-layout { display: flex; flex-direction: column; height: calc(100vh - 140px); gap: 12px; }
.costs-list-zone { flex: 3; min-height: 0; overflow: hidden; }
.costs-validation-zone { flex: 2; min-height: 200px; max-height: 50vh; position: sticky; bottom: 0; }

.week-nav { display: flex; align-items: center; gap: 8px; }
.week-nav-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; background: var(--body-bg); border: 1px solid var(--border); text-decoration: none; color: var(--text); font-weight: 700; font-size: 14px; }
.week-nav-btn:hover { background: var(--primary-light); border-color: var(--primary); }
.week-nav-label { font-weight: 700; font-size: 14px; min-width: 240px; text-align: center; }

/* ─── Heatmap Staffing ─────────────────────────────────── */
.heatmap-table { border-collapse: separate; border-spacing: 3px; width: 100%; }
.heatmap-table th, .heatmap-table td { padding: 6px 8px; }
.heatmap-table thead th { background: var(--card-bg); font-size: 11px; font-weight: 700; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.heatmap-sticky-col { position: sticky; left: 0; z-index: 2; background: var(--card-bg); min-width: 180px; max-width: 220px; border-right: 2px solid var(--border); }
.heatmap-cell { border-radius: 4px; font-size: 12px; font-weight: 700; min-width: 60px; transition: transform 0.1s, box-shadow 0.1s; }
.heatmap-cell:hover { transform: scale(1.08); box-shadow: 0 2px 8px rgba(0,0,0,0.12); z-index: 1; }

@@media (max-width: 768px) {
    .sidebar { width: 0; overflow: hidden; padding: 0; }
    .main-content { margin-left: 0; }
    .sidebar:not(.collapsed) { width: 200px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ─── Draggable modale (dialog natif) ──────────────────── */
.dlg-draggable { border: none; border-radius: 14px; padding: 0; max-width: 95vw; box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; }
.dlg-draggable::backdrop { background: rgba(0,0,0,.55); }
.dlg-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; cursor: move; user-select: none; }
.dlg-title { font-size: 15px; font-weight: 800; }
.dlg-close { background: rgba(255,255,255,.2); border: none; color: #fff; font-size: 22px; line-height: 1; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; padding: 0; }
.dlg-close:hover { background: rgba(255,255,255,.35); }
.dlg-body { padding: 24px 28px 20px; max-height: calc(90vh - 60px); overflow-y: auto; }
@keyframes dlgShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.dlg-draggable.dlg-shake { animation: dlgShake 0.18s ease-in-out; }
.form-label { display: block; font-size: 12px; font-weight: 700; color: #374151; margin-bottom: 4px; }
/* ─── Validation cliente : champ invalide + message inline ── */
.field-invalid { border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220,38,38,0.15) !important; background: #fef2f2 !important; }
.field-invalid:focus { border-color: #b91c1c !important; box-shadow: 0 0 0 3px rgba(220,38,38,0.25) !important; }
.field-error { color: #b91c1c; font-size: 12px; margin-top: 4px; font-weight: 600; line-height: 1.3; }
