/* ===== PROJECTS: sidebar dynamique + admin modal ===== */

/* Liste projets dans sidebar */
#projects-list { display: flex; flex-direction: column; gap: 4px; }
.project-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-radius: 8px;
    cursor: pointer; transition: background var(--transition);
    border-left: 3px solid transparent;
    color: var(--text);
}
.project-item:hover { background: var(--bg-hover, rgba(255,255,255,0.04)); border-left-color: var(--proj-color, var(--accent)); }
.project-item.current { background: var(--bg-hover, rgba(255,255,255,0.06)); border-left-color: var(--proj-color, var(--accent)); }
.project-item .project-icon {
    width: 28px; height: 28px; border-radius: 6px;
    background: rgba(255,255,255,0.04);
    display: flex; align-items: center; justify-content: center;
    color: var(--proj-color, var(--accent));
    flex-shrink: 0;
}
.project-item .project-icon svg { width: 14px; height: 14px; }
.project-item .project-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.project-item .project-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-item .project-sub { font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.projects-empty, .projects-error {
    padding: 8px 12px; font-size: 11px; color: var(--text-muted); font-style: italic;
}
.projects-error { color: var(--red, #ef4444); }

/* Bouton + nouveau projet */
.projects-add {
    margin-top: 6px;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 12px; border-radius: 8px;
    background: transparent; color: var(--text-muted);
    border: 1px dashed var(--border);
    cursor: pointer; font-size: 11px; font-family: inherit;
    transition: all var(--transition);
}
.projects-add:hover { color: var(--text); border-color: var(--accent); background: rgba(255,255,255,0.02); }
.projects-add svg { width: 12px; height: 12px; }

/* ===== Modal overlay ===== */
.project-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center; justify-content: center;
    z-index: 9999;
    padding: 24px;
}
.project-modal-overlay.open { display: flex; }
.project-modal {
    background: var(--bg-card, #1a1b1e);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 720px; width: 100%;
    max-height: 90vh; overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

/* Modal head */
.modal-head {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 18px 22px; border-bottom: 1px solid var(--border);
    background: var(--bg-elev, rgba(255,255,255,0.02));
}
.modal-head-icon {
    width: 40px; height: 40px; border-radius: 8px;
    background: rgba(255,255,255,0.04);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}
.modal-head-icon svg { width: 20px; height: 20px; }
.modal-head-text { flex: 1; min-width: 0; }
.modal-head-text h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); }
.modal-id {
    margin: 4px 0 0; font-family: 'JetBrains Mono', monospace;
    font-size: 11px; color: var(--text-muted);
}
.modal-close {
    background: transparent; border: none; color: var(--text-muted);
    font-size: 24px; line-height: 1; cursor: pointer;
    width: 32px; height: 32px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
}
.modal-close:hover { background: rgba(255,255,255,0.05); color: var(--text); }

/* Modal body */
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.proj-desc { margin: 0 0 16px; color: var(--text-muted); font-size: 13px; line-height: 1.5; }

.proj-fields {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px;
    margin-bottom: 14px;
}
.proj-field {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; border-bottom: 1px solid var(--border);
    font-size: 12px;
}
.proj-field-key { color: var(--text-muted); font-weight: 500; }
.proj-field-val { color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.proj-empty { color: var(--text-dim); font-style: italic; }
.proj-tags-row { display: flex; gap: 12px; align-items: flex-start; padding-top: 8px; }
.proj-tags { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.proj-tag {
    padding: 3px 9px; border-radius: 4px;
    background: rgba(124, 58, 237, 0.15); color: #c4b5fd;
    font-size: 10px; font-weight: 500;
}

/* Modal foot */
.modal-foot {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 14px 22px; border-top: 1px solid var(--border);
    background: var(--bg-elev, rgba(255,255,255,0.02));
}
.btn-primary, .btn-ghost, .btn-danger {
    padding: 7px 14px; border-radius: 6px;
    font-size: 12px; font-family: inherit; font-weight: 500;
    cursor: pointer; transition: all var(--transition);
    border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,0.04); }
.btn-danger { background: transparent; border-color: rgba(239, 68, 68, 0.4); color: #ef4444; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); border-color: #ef4444; }

/* Formulaire */
.project-form {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px;
}
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field.full { grid-column: 1 / -1; }
.form-field > span {
    font-size: 11px; color: var(--text-muted); font-weight: 500;
}
.form-field input, .form-field select, .form-field textarea {
    background: var(--bg, #0f1012); border: 1px solid var(--border);
    color: var(--text); padding: 7px 10px; border-radius: 6px;
    font-size: 12px; font-family: inherit;
    transition: border-color var(--transition);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    outline: none; border-color: var(--accent);
}
.form-field textarea { resize: vertical; min-height: 56px; font-family: inherit; }

.color-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.color-swatch {
    width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid transparent; cursor: pointer;
    padding: 0; transition: transform var(--transition);
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text); }

.form-error {
    grid-column: 1 / -1;
    padding: 8px 12px; border-radius: 6px;
    background: rgba(239, 68, 68, 0.1); color: #ef4444;
    font-size: 12px; border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Light theme */
body.theme-light .project-item:hover,
body.theme-light .project-item.current { background: rgba(0,0,0,0.04); }
body.theme-light .project-modal { background: #fff; }
body.theme-light .modal-head, body.theme-light .modal-foot { background: rgba(0,0,0,0.02); }
body.theme-light .form-field input,
body.theme-light .form-field select,
body.theme-light .form-field textarea { background: #fff; }
body.theme-light .projects-add:hover { background: rgba(0,0,0,0.02); }

/* Responsive */
@media (max-width: 600px) {
    .project-form { grid-template-columns: 1fr; }
    .proj-fields { grid-template-columns: 1fr; }
}

/* ===== Page projet plein ecran ===== */
.project-detail-view {
    padding: 0 28px 32px;
    display: flex; flex-direction: column; gap: 20px;
}
.pd-header {
    display: flex; align-items: center; gap: 16px;
    padding: 18px 22px;
    background: var(--bg-card, #1a1b1e);
    border: 1px solid var(--border); border-radius: 12px;
    margin-top: 16px;
}
.pd-header-icon {
    width: 48px; height: 48px; border-radius: 10px;
    background: rgba(255,255,255,0.04);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.pd-header-icon svg { width: 24px; height: 24px; }
.pd-header-text { flex: 1; min-width: 0; }
.pd-header-text h2 { margin: 0; font-size: 20px; font-weight: 600; color: var(--text); }
.pd-id {
    margin: 4px 0 0; font-family: 'JetBrains Mono', monospace;
    font-size: 11px; color: var(--text-muted);
}
.pd-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

.pd-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.pd-card {
    background: var(--bg-card, #1a1b1e);
    border: 1px solid var(--border); border-radius: 12px;
    padding: 18px 22px;
}
.pd-card-title {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted);
    margin-bottom: 14px;
}
.pd-desc {
    margin: 0; color: var(--text); font-size: 13px; line-height: 1.6;
}
.pd-fields {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px;
}
.pd-field {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; border-bottom: 1px solid var(--border);
    font-size: 12px;
}
.pd-field-key { color: var(--text-muted); font-weight: 500; }
.pd-field-val { color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.pd-tags-row {
    display: flex; gap: 12px; align-items: flex-start; padding-top: 12px;
}
.pd-tags { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.proj-link {
    color: var(--accent); text-decoration: none;
    font-family: 'JetBrains Mono', monospace; font-size: 11px;
    border-bottom: 1px dotted var(--accent);
}
.proj-link:hover { filter: brightness(1.2); }
.proj-status-badge {
    padding: 2px 8px; border-radius: 4px;
    background: rgba(124, 58, 237, 0.15); color: #c4b5fd;
    font-size: 11px; font-weight: 500; font-family: inherit;
}
.proj-status-badge[data-status="Termine"] { background: rgba(34,197,94,0.15); color: #86efac; }
.proj-status-badge[data-status="En cours"] { background: rgba(245,158,11,0.15); color: #fcd34d; }
.proj-status-badge[data-status="Cadrage"] { background: rgba(59,130,246,0.15); color: #93c5fd; }
.proj-status-badge[data-status="En pause"] { background: rgba(156,163,175,0.15); color: #d1d5db; }
.proj-status-badge[data-status="Annule"] { background: rgba(239,68,68,0.15); color: #fca5a5; }

.pd-placeholder-text {
    margin: 0 0 12px; color: var(--text); font-size: 13px; line-height: 1.5;
}
.pd-placeholder-list {
    margin: 0 0 14px; padding-left: 18px; color: var(--text-muted);
    font-size: 12px; line-height: 1.8;
}
.pd-placeholder-list strong { color: var(--accent); font-weight: 600; }
.pd-placeholder-hint {
    margin: 0; padding: 10px 12px; border-radius: 6px;
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.2);
    color: var(--text-muted); font-size: 11px; line-height: 1.5;
}
.pd-placeholder-hint strong { color: var(--text); font-weight: 600; }

body.theme-light .pd-header,
body.theme-light .pd-card { background: #fff; }

@media (max-width: 900px) {
    .pd-grid { grid-template-columns: 1fr; }
    .pd-fields { grid-template-columns: 1fr; }
    .pd-header { flex-wrap: wrap; }
    .pd-header-actions { width: 100%; justify-content: flex-end; }
}

/* ===== Onglets internes page projet ===== */
.pd-tabs {
    display: flex; gap: 4px;
    border-bottom: 1px solid var(--border);
    margin: 0 0 4px;
}
.pd-tab {
    background: transparent; border: none;
    padding: 10px 18px; cursor: pointer;
    font: inherit; font-size: 13px; font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.pd-tab:hover { color: var(--text); }
.pd-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.pd-tab-content { display: flex; flex-direction: column; gap: 16px; }

/* KPIs onglet dashboard projet */
.pd-kpis {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.pd-kpi {
    background: var(--bg-card, #1a1b1e);
    border: 1px solid var(--border); border-radius: 10px;
    padding: 14px 16px;
}
.pd-kpi-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); margin-bottom: 6px; font-weight: 600;
}
.pd-kpi-value {
    font-size: 20px; font-weight: 600; color: var(--text); line-height: 1.2;
}
.pd-kpi-value.pd-kpi-sm { font-size: 13px; font-family: 'JetBrains Mono', monospace; }
.pd-kpi-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

body.theme-light .pd-kpi { background: #fff; }

@media (max-width: 900px) {
    .pd-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
    .pd-kpis { grid-template-columns: 1fr; }
    .pd-tabs { overflow-x: auto; }
}

/* ===== Editeur d'onglets custom ===== */
.tabs-editor #tabs-editor-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 10px; }
.tabs-editor .tab-row {
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 8px; padding: 10px;
    background: var(--surface-2, rgba(255,255,255,0.02));
}
.tabs-editor .tab-row-head {
    display: flex; gap: 6px; align-items: center; margin-bottom: 8px;
}
.tabs-editor .tab-label {
    flex: 1; padding: 6px 10px;
    background: var(--surface, transparent);
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 6px; color: inherit; font: inherit;
}
.tabs-editor .tab-content {
    width: 100%; padding: 8px;
    background: var(--surface, transparent);
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 6px; color: inherit;
    font: 12px/1.4 ui-monospace, "Cascadia Code", Consolas, monospace;
    resize: vertical;
}
.btn-icon {
    width: 28px; height: 28px; padding: 0;
    border: 1px solid var(--border, #2a2a2a);
    background: transparent; color: inherit;
    border-radius: 6px; cursor: pointer;
    font-size: 14px; line-height: 1;
}
.btn-icon:hover { background: var(--surface-hover, rgba(255,255,255,0.05)); }
.btn-icon-danger:hover { background: rgba(239,68,68,0.15); color: #ef4444; border-color: #ef4444; }
.tabs-editor .hint { opacity: 0.65; font-weight: normal; font-size: 11px; }
#tabs-add-btn { margin-top: 4px; }

.pd-custom-tab { line-height: 1.55; }
.pd-custom-tab h1, .pd-custom-tab h2, .pd-custom-tab h3 { margin-top: 0; }
.pd-custom-tab img { max-width: 100%; height: auto; border-radius: 6px; }
.pd-custom-tab pre {
    background: var(--surface-2, rgba(0,0,0,0.25));
    padding: 12px; border-radius: 6px; overflow-x: auto;
}

/* ===== Editeur d'onglets custom ===== */
.tabs-editor #tabs-editor-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 10px; }
.tabs-editor .tab-row {
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 8px; padding: 10px;
    background: var(--surface-2, rgba(255,255,255,0.02));
}
.tabs-editor .tab-row-head {
    display: flex; gap: 6px; align-items: center; margin-bottom: 8px;
}
.tabs-editor .tab-label {
    flex: 1; padding: 6px 10px;
    background: var(--surface, transparent);
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 6px; color: inherit; font: inherit;
}
.tabs-editor .tab-content {
    width: 100%; padding: 8px;
    background: var(--surface, transparent);
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 6px; color: inherit;
    font: 12px/1.4 ui-monospace, "Cascadia Code", Consolas, monospace;
    resize: vertical;
}
.btn-icon {
    width: 28px; height: 28px; padding: 0;
    border: 1px solid var(--border, #2a2a2a);
    background: transparent; color: inherit;
    border-radius: 6px; cursor: pointer;
    font-size: 14px; line-height: 1;
}
.btn-icon:hover { background: var(--surface-hover, rgba(255,255,255,0.05)); }
.btn-icon-danger:hover { background: rgba(239,68,68,0.15); color: #ef4444; border-color: #ef4444; }
.tabs-editor .hint { opacity: 0.65; font-weight: normal; font-size: 11px; }
#tabs-add-btn { margin-top: 4px; }

.pd-custom-tab { line-height: 1.55; }
.pd-custom-tab h1, .pd-custom-tab h2, .pd-custom-tab h3 { margin-top: 0; }
.pd-custom-tab img { max-width: 100%; height: auto; border-radius: 6px; }
.pd-custom-tab pre {
    background: var(--surface-2, rgba(0,0,0,0.25));
    padding: 12px; border-radius: 6px; overflow-x: auto;
}
