/* === Syntheses PNCEE - Styles === */

:root {
    --primary-color: #0d6efd;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --muted-color: #6c757d;
}

/* === Navigation === */
nav .nav-link {
    font-size: 0.9rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

nav .nav-link.active {
    opacity: 1;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 4px;
}

nav .nav-link:hover {
    opacity: 1;
}

/* === Page Sections === */
.page-section[hidden] {
    display: none;
}

.page-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Actions bar with search left, button right */
.config-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
}
.config-actions-bar input[type="search"] {
    margin: 0 !important;
    max-width: 20rem;
}

/* === Config Section Cards === */
.config-section {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.config-section h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

/* === User Guide === */
.guide-section {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    background: #fff;
}

.guide-section summary {
    padding: 0.6rem 0.9rem;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.guide-section summary::before {
    content: '\25B6';
    font-size: 0.65rem;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.guide-section[open] summary::before {
    transform: rotate(90deg);
}

.guide-section summary::-webkit-details-marker { display: none; }

.guide-content {
    padding: 0 0.9rem 0.75rem;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #444;
}

.guide-content h5 {
    font-size: 0.88rem;
    margin: 0.75rem 0 0.3rem;
    color: #333;
}

.guide-content h5:first-child {
    margin-top: 0;
}

.guide-content ul, .guide-content ol {
    margin: 0.3rem 0 0.5rem 1.2rem;
    padding: 0;
}

.guide-content p {
    margin: 0.3rem 0;
}

.guide-content table {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin: 0.3rem 0 0.5rem;
}

.guide-content table th,
.guide-content table td {
    border-bottom: 1px solid #eee;
}

.guide-content pre {
    overflow-x: auto;
}

/* === Placeholder selects (empty value selected) === */
select.select-placeholder {
    color: var(--muted-color);
}

/* === Form Groups === */
.form-group {
    margin-bottom: 0.75rem;
}

.form-group label {
    font-weight: 600;
}

/* === Actions === */
.actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 0.75rem;
}

/* === Action Buttons === */
.btn-action-blue,
.btn-action-green,
.btn-action-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0 0.9rem;
    margin: 0;
    color: #fff;
    border: none;
    border-radius: 0.3rem;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    line-height: 2rem;
    box-sizing: border-box;
    height: 2rem;
    vertical-align: middle;
}

.btn-action-blue { background: #1976d2; }
.btn-action-green { background: #2e7d32; }
.btn-action-outline {
    background: #fff;
    color: #555;
    border: 1px solid #adb5bd;
}

.btn-action-blue:hover,
.btn-action-green:hover { opacity: 0.88; }
.btn-action-outline:hover { background: #f1f3f5; }
.btn-action-outline.danger { color: #c62828; border-color: #c62828; }
.btn-action-outline.danger:hover { background: #ffebee; }

.btn-action-blue:disabled,
.btn-action-green:disabled,
.btn-action-outline:disabled { opacity: 0.5; cursor: default; }

/* === Small action buttons (edit/delete in tables) === */
.btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    color: #333;
    border: 1px solid #dee2e6;
    border-radius: 0.2rem;
    background: #fff;
    cursor: pointer;
    gap: 0.2rem;
}

.btn-sm:hover {
    background: #f1f3f5;
}

.btn-sm.danger {
    color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-sm.danger:hover {
    background: rgba(220, 53, 69, 0.1);
}

.btn-sm.insert {
    color: var(--success-color);
    border-color: var(--success-color);
    font-weight: 700;
}

.btn-sm.insert:hover {
    background: rgba(25, 135, 84, 0.1);
}

.btn-sm.insert-int {
    color: var(--muted-color);
    border-color: var(--muted-color);
    font-size: 0.65rem;
    font-weight: 700;
}

.btn-sm.insert-int:hover {
    background: rgba(108, 117, 125, 0.1);
}

/* === Info Icon (tooltip) === */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    font-size: 0.65rem;
    font-style: normal;
    font-weight: 600;
    color: #6b7280;
    background: transparent;
    border: 1.5px solid #9ca3af;
    border-radius: 50%;
    cursor: help;
    margin-left: 0.35rem;
    vertical-align: middle;
    position: relative;
    transition: color 0.15s, border-color 0.15s;
}
.info-icon:hover {
    color: #2563eb;
    border-color: #2563eb;
}


/* === Color Combo (hex + swatch + picker) === */
.color-combo {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.3rem;
}
.color-combo .color-swatch {
    display: inline-block;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 3px;
    border: 1.5px solid #ccc;
    cursor: pointer;
    flex-shrink: 0;
    vertical-align: middle;
}
.color-combo .color-swatch:hover { border-color: #888; }
.color-combo .col-color-hex {
    width: 5.5rem !important;
    max-width: 5.5rem !important;
    font-family: monospace !important;
    font-size: 0.8rem !important;
    padding: 0.15rem 0.3rem !important;
    margin: 0 !important;
    height: 1.6rem !important;
    text-transform: uppercase;
}
.color-combo .col-color-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

/* === Status Badges === */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 0.3rem;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-badge.success {
    background: #d1e7dd;
    color: #0f5132;
}

.status-badge.running {
    background: #cfe2ff;
    color: #084298;
}

.status-badge.pending {
    background: #e2e3e5;
    color: #41464b;
}

.status-badge.needs-validation {
    background: var(--warning-color, #e6a817);
    color: #fff;
}

.status-badge.error {
    background: #f8d7da;
    color: #842029;
}

/* === History alert icons === */
#history-table td:nth-child(6) {
    white-space: nowrap;
}
.history-alert {
    cursor: help;
    font-size: 0.9rem;
    vertical-align: middle;
    margin-left: 0.35rem;
}
.history-alert-error {
    color: #dc3545;
}
.history-alert-warning {
    color: #e6a817;
}

/* === Download Button === */
.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.8rem;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 0.3rem;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
}

.btn-download:hover {
    opacity: 0.9;
}

/* === Warnings === */
.warnings {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    list-style: none;
}

.warnings li {
    padding: 0.15rem 0;
    color: #856404;
    font-size: 0.85rem;
}

/* === Loading Overlay === */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay[hidden] {
    display: none;
}

/* === Compact layout overrides (PicoCSS) === */
main.container h2 {
    margin-bottom: 0.75rem;
}

main.container h3 {
    margin-bottom: 0.5rem;
}

main.container p {
    margin-bottom: 0.5rem;
}

main.container table {
    margin-bottom: 0.5rem;
}

main.container table th,
main.container table td {
    padding: 0.35rem 0.5rem;
}

/* === Mapping Editor === */
.mapping-editor {
    overflow-x: auto;
}

.mapping-editor table {
    font-size: 0.85rem;
    min-width: 700px;
}

.mapping-editor input,
.mapping-editor select,
.mapping-editor textarea {
    font-size: 0.85rem;
    padding: 0.15rem 0.4rem;
    margin-bottom: 0;
    height: auto;
    line-height: 1.3;
}

.mapping-editor td {
    overflow: hidden;
}

.mapping-editor td input,
.mapping-editor td select {
    max-width: 100%;
    box-sizing: border-box;
}

/* Masquer la fleche dropdown des datalist (Chrome/Edge) */
.mapping-editor td input[list]::-webkit-calendar-picker-indicator {
    display: none !important;
}

.mapping-label-cell .label-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    max-height: calc(1.3em * 3);
    word-break: break-word;
}

/* Stats config table: compact inputs */
#stats-config-table input,
#stats-config-table select {
    font-size: 0.85rem;
    padding: 0.15rem 0.4rem;
    margin-bottom: 0;
    height: auto;
    line-height: 1.3;
}

/* Column label textarea: auto-height */
.col-label-textarea {
    width: 100%;
    min-height: 1.6rem;
    resize: vertical;
    overflow: hidden;
    font-family: inherit;
    field-sizing: content;
}

/* === Validation values textarea === */
.validation-values-textarea {
    width: 100%;
    min-height: 2.5rem;
    max-height: 7.5rem;
    resize: vertical;
    font-family: inherit;
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
    border: 1px solid #dee2e6;
    border-radius: 0.2rem;
    field-sizing: content;
    overflow-y: auto;
}

/* === Color swatch input === */
input[type="color"] {
    width: 3rem;
    height: 1.8rem;
    padding: 0.1rem;
    border: 1px solid #dee2e6;
    border-radius: 0.2rem;
    cursor: pointer;
}

/* === Mapping source indicators === */
.source-indicator {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    margin-right: 0.3rem;
}

.source-indicator.mapped {
    background: var(--primary-color);
}

.source-indicator.unmapped {
    background: var(--warning-color);
}

.source-indicator.intermediate {
    background: var(--danger-color);
}

/* === Intermediate column rows === */
tr.intermediate-row {
    background: #f8f9fa;
}

tr.intermediate-row td:first-child {
    color: var(--muted-color);
    font-style: italic;
}

/* === Test mapping result column === */
.test-badge {
    display: inline-block;
    font-size: 0.78rem;
    padding: 0.1rem 0.45rem;
    border-radius: 0.25rem;
    max-width: 14rem;
    white-space: normal;
    word-break: break-word;
    vertical-align: middle;
}
.test-badge-ok    { background: #d4edda; color: #155724; }
.test-badge-empty { background: #e9ecef; color: #6c757d; font-style: italic; }
.test-badge-missing { background: #fff3cd; color: #856404; }

.formula-vars-details {
    display: inline-block;
    vertical-align: middle;
    margin-left: 0.3rem;
    position: relative;
}
.formula-vars-details summary {
    cursor: pointer;
    font-size: 0.8rem;
    color: #0d6efd;
    list-style: none;
    padding: 0.1rem 0.3rem;
    border-radius: 50%;
    background: #e7f1ff;
    user-select: none;
}
.formula-vars-details summary::-webkit-details-marker { display: none; }
.formula-vars-table {
    position: fixed;
    z-index: 1000;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.35rem;
    box-shadow: 0 3px 12px rgba(0,0,0,0.18);
    font-size: 0.78rem;
    padding: 0.35rem 0.5rem;
    max-width: 28rem;
    width: max-content;
    white-space: normal;
    word-break: break-word;
}
.formula-vars-table td { padding: 0.1rem 0.5rem; vertical-align: top; }
.formula-vars-table tr td:first-child { font-family: monospace; color: #0d6efd; white-space: nowrap; }
.formula-vars-table tr td:last-child  { color: #333; }

/* === Formula display in mapping === */
.formula-preview {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.78rem;
    color: #555;
    background: #e9ecef;
    padding: 0.15rem 0.4rem;
    border-radius: 0.15rem;
    max-width: 20rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

/* === Button for opening formula editor === */
.btn-open-formula {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    font-size: 0.7rem;
    color: #333;
    border: 1px solid #dee2e6;
    border-radius: 0.2rem;
    background: #f8f9fa;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 0.2rem;
}

.btn-open-formula:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* === Kizeo forms table === */
#forms-table input,
#forms-table select {
    font-size: 0.8rem;
    padding: 0.15rem 0.35rem;
    margin-bottom: 0;
    height: auto;
}

/* === User info in nav === */
.user-info {
    font-size: 0.85rem;
    color: var(--muted-color);
}

.role-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 0.3rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-left: 0.4rem;
    vertical-align: middle;
}

.role-badge.role-admin {
    background: #0d6efd;
    color: #fff;
}

.role-badge.role-user {
    background: #e9ecef;
    color: #555;
}

.logout-link {
    font-size: 0.8rem;
    color: var(--danger-color) !important;
    text-decoration: underline;
    cursor: pointer;
    margin-left: 0.5rem;
}

.logout-link:hover {
    opacity: 0.8;
}

/* === Progress steps === */
.progress-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.85rem;
}

.progress-step .step-icon {
    width: 1.2rem;
    text-align: center;
}

.progress-step.done .step-icon {
    color: var(--success-color);
}

.progress-step.running .step-icon {
    color: var(--primary-color);
}

.progress-step.pending .step-icon {
    color: var(--muted-color);
}

/* === Formula Editor Modal === */
.formula-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.formula-modal-overlay[hidden] {
    display: none;
}

.formula-modal {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 95%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.formula-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.formula-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted-color);
    border-radius: 0.3rem;
}

.formula-modal-close:hover {
    background: #e9ecef;
    color: var(--danger-color);
}

.formula-modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.formula-modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.25rem;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

.formula-modal-footer button {
    padding: 0.4rem 1.2rem;
    font-size: 0.9rem;
}

.formula-expr-input {
    width: 100%;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.9rem;
    padding: 0.6rem 0.75rem;
    border: 2px solid #dee2e6;
    border-radius: 0.4rem;
    resize: vertical;
    min-height: 3rem;
    margin-bottom: 0.5rem;
}

.formula-expr-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.formula-validation {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
    border-radius: 0.3rem;
    margin-bottom: 0.5rem;
}

.formula-valid {
    color: #0f5132;
    background: #d1e7dd;
}

.formula-invalid {
    color: #842029;
    background: #f8d7da;
}

.formula-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.formula-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    border: 1px solid #dee2e6;
    border-radius: 0.3rem;
    background: #f8f9fa;
    cursor: pointer;
    color: #333;
}

.formula-toolbar-btn:hover {
    background: #e9ecef;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.formula-sub-panel {
    border: 1px solid #dee2e6;
    border-radius: 0.4rem;
    margin-bottom: 0.5rem;
    background: #fafbfc;
    max-height: 12rem;
    overflow-y: auto;
}

.formula-sub-panel[hidden] {
    display: none;
}

.formula-sub-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    background: #f0f1f3;
    border-bottom: 1px solid #dee2e6;
    font-size: 0.8rem;
}

.formula-fn-list {
    padding: 0.25rem;
}

.formula-fn-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.4rem;
    border-radius: 0.2rem;
    font-size: 0.78rem;
}

.formula-fn-row:hover {
    background: #e9ecef;
}

.formula-fn-name {
    font-weight: 700;
    color: var(--primary-color);
    min-width: 5rem;
}

.formula-fn-syntax {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.72rem;
    color: #555;
    background: #e9ecef;
    padding: 0.1rem 0.3rem;
    border-radius: 0.15rem;
    min-width: 10rem;
}

.formula-fn-desc {
    color: var(--muted-color);
    flex: 1;
    font-size: 0.72rem;
}

.formula-fn-insert {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    padding: 0;
    font-size: 0.75rem;
    font-weight: bold;
    border: 1px solid var(--primary-color);
    border-radius: 0.2rem;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    flex-shrink: 0;
}

.formula-fn-insert:hover {
    background: var(--primary-color);
    color: #fff;
}

.formula-mapping-list {
    padding: 0.25rem;
}

.formula-mapping-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.4rem;
    border-radius: 0.2rem;
    font-size: 0.8rem;
}

.formula-mapping-row:hover {
    background: #e9ecef;
}

.formula-help p {
    margin: 0.2rem 0;
}

.formula-help code {
    font-size: 0.75rem;
    background: #e9ecef;
    padding: 0.1rem 0.3rem;
    border-radius: 0.15rem;
}

/* === Generic Modal === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 95%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.15s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.modal-header h4 {
    margin: 0;
    font-size: 1rem;
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted-color);
    border-radius: 0.3rem;
}

.modal-close:hover {
    background: #e9ecef;
    color: var(--danger-color);
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.modal-body p {
    margin: 0;
    font-size: 0.95rem;
}

.modal-form-group {
    margin-bottom: 0.75rem;
}

.modal-form-group:last-child {
    margin-bottom: 0;
}

.modal-form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.modal-form-group input,
.modal-form-group select {
    width: 100%;
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0;
}

.modal-checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-checkbox-row input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.modal-checkbox-row label {
    display: inline;
    font-weight: normal;
    margin-bottom: 0;
}

.field-error {
    border-color: var(--danger-color) !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.45) !important;
    background-color: #fff5f5 !important;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.25rem;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

.modal-footer button {
    padding: 0.4rem 1.2rem;
    font-size: 0.9rem;
}

/* === Collapsible Sections === */
.collapsible-section .section-toggle {
    cursor: pointer;
    user-select: none;
    margin-bottom: 0;
}

.collapsible-section .section-toggle:hover {
    color: var(--primary-color);
}

.collapsible-section .chevron {
    display: inline-block;
    font-size: 0.7em;
    transition: transform 0.2s ease;
    vertical-align: middle;
}

.collapsible-section.collapsed .chevron {
    transform: rotate(-90deg);
}

.collapsible-section.collapsed .section-content {
    display: none;
}

.collapsible-section:not(.collapsed) .section-toggle {
    margin-bottom: 0.5rem;
}

/* === Floating Save Button === */
.btn-save-floating {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 900;
    background: #2e7d32;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    padding: 0.6rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: opacity 0.2s, transform 0.2s;
}

.btn-save-floating:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-save-floating[hidden] {
    display: none;
}

/* === Inline progress in history === */
.inline-progress {
    margin-top: 0.25rem;
}

.mini-progress {
    width: 100%;
    height: 0.35rem;
    border-radius: 0.2rem;
    appearance: none;
    -webkit-appearance: none;
}

.mini-progress::-webkit-progress-bar {
    background: #e9ecef;
    border-radius: 0.2rem;
}

.mini-progress::-webkit-progress-value {
    background: #3b82f6;
    border-radius: 0.2rem;
    transition: width 0.3s;
}

.mini-progress::-moz-progress-bar {
    background: #3b82f6;
    border-radius: 0.2rem;
}

.mini-step {
    display: block;
    font-size: 0.68rem;
    color: #6c757d;
    margin-top: 0.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === Icon buttons in actions === */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.35rem;
    line-height: 1;
    border: 1px solid #dee2e6;
    background: #fff;
    cursor: pointer;
    border-radius: 0.25rem;
    text-decoration: none;
    color: inherit;
    margin-right: 0.2rem;
}

.btn-icon:hover {
    background: #f8f9fa;
}

.btn-icon svg {
    vertical-align: middle;
}

.btn-cancel {
    color: #dc3545;
    border-color: #dc3545;
}

.btn-cancel:hover {
    background: rgba(220, 53, 69, 0.1);
}

.btn-sp {
    color: #0078d4;
    border-color: #0078d4;
}

.btn-sp:hover {
    background: rgba(0, 120, 212, 0.1);
}

.btn-sp-done {
    color: #198754;
    border-color: #198754;
    cursor: default;
    font-weight: bold;
}

/* === Cancelled status badge === */
.status-badge.cancelled {
    background: #e2e3e5;
    color: #6c757d;
}

/* === Responsive === */
@media (max-width: 768px) {
    #nav-links {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .actions {
        flex-direction: column;
    }

    .mapping-editor table {
        min-width: unset;
    }
}

.app-version {
    font-size: 0.65em;
    opacity: 0.45;
    font-weight: normal;
    vertical-align: middle;
    letter-spacing: 0.02em;
}

/* === Surlignage des lignes verrouillees (jobs KPI) === */
/* Cible les td pour surcharger le striping de Pico CSS */
tr.row-locked > td {
    background-color: #e6f4ea !important;
}

/* === En-tête bleu marine (identité Spekty) — aligné integrations === */
.app-header {
    background: #1f2c54;                 /* bleu marine du logo */
    border-bottom: 3px solid #3d92d1;    /* liseré bleu (le point du logo) */
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
    margin-bottom: 1.2rem;
    /* Hauteur FIGEE alignee sur Pilotage CEE : 60 px liseré de 3 px inclus
       (avant : padding en rem -> 54 a 59 px selon la largeur d'ecran). */
    box-sizing: border-box;
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 22px;                     /* = 1.4rem de Pilotage (rem 16 px) */
    font-size: 0.88rem;                  /* bandeau compact */
    /* Barre FIGEE en haut au defilement (comme Pilotage CEE). z-index sous les
       overlays (chargement / modales >= 1000), au-dessus du bouton flottant (900). */
    position: sticky;
    top: 0;
    z-index: 950;
}
/* Ancres / scrollIntoView : ne pas finir sous la barre figee (60 px) */
html { scroll-padding-top: 64px; }
.app-header nav {
    width: 100%;
    align-items: center;
    /* Pico gonfle les <li> de la nav (padding vertical ~1rem) → bandeau trop haut.
       On réduit les variables d'espacement Pico pour un bandeau compact. */
    --pico-nav-element-spacing-vertical: 0.25rem;
    --pico-nav-element-spacing-horizontal: 0.5rem;
}
/* Tailles du bandeau figées en px (Pico grossit le rem jusqu'à 20px ≥1280px). */
.app-header nav .nav-link,
.app-header .nav-dd-toggle {
    font-size: 14px;
    padding-top: 4px;
    padding-bottom: 4px;
}
.app-header nav li {
    padding-top: 4px;
    padding-bottom: 4px;
}
.app-header .app-version { font-size: 10px; }
.app-header .user-info,
.app-header #user-display-name { font-size: 13px; }
.user-menu .caret { font-size: 10px; }
/* Marque */
.app-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.app-brand-logo-img {
    height: 34px;                        /* comme Pilotage CEE */
    width: auto;
    display: block;
}
.app-brand-name {
    color: rgba(255, 255, 255, 0.72);
    font-size: 13px;
    font-weight: 500;
    padding-left: 0.6rem;
    border-left: 1px solid rgba(255, 255, 255, 0.28);
}
.app-header .app-version {
    color: rgba(255, 255, 255, 0.5);
    opacity: 1;
}
/* Liens de navigation (blanc sur marine) */
.app-header nav .nav-link {
    color: #e7ecf6 !important;
    opacity: 0.82;
    font-weight: 500;
}
.app-header nav .nav-link:hover {
    color: #ffffff !important;
    opacity: 1;
}
.app-header nav .nav-link.active {
    color: #ffffff !important;
    opacity: 1;
    font-weight: 700;
    text-decoration: underline;
    text-decoration-color: #3d92d1;
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
}
/* Bloc utilisateur / déconnexion */
.app-header .user-info {
    color: rgba(255, 255, 255, 0.9);
}
.app-header .role-badge {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}
.app-header .role-badge.role-admin {
    background: #3d92d1;
    color: #fff;
}
.app-header .logout-link {
    color: #ffc2c2 !important;
}
.app-header .logout-link:hover {
    color: #fff !important;
}

/* Menu déroulant « Configuration » (regroupe les onglets admin) */
.nav-dropdown { position: relative; }
.nav-dd-toggle {
    cursor: pointer; color: #e7ecf6; opacity: 0.82; font-weight: 500;
    font-size: 0.9rem; user-select: none; white-space: nowrap;
}
.nav-dropdown:hover .nav-dd-toggle,
.nav-dropdown:focus-within .nav-dd-toggle,
.nav-dropdown.open .nav-dd-toggle { color: #fff; opacity: 1; }
.nav-dropdown:has(.nav-link.active) .nav-dd-toggle { color: #fff; opacity: 1; font-weight: 700; }
.nav-dd-menu {
    position: absolute; top: 100%; left: 0; margin: 0.3rem 0 0; padding: 0.3rem;
    list-style: none; min-width: 210px; background: #24325d;
    border: 1px solid rgba(255,255,255,0.15); border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0,0,0,0.35); display: none; z-index: 1200;
}
.nav-dropdown:hover .nav-dd-menu,
.nav-dropdown:focus-within .nav-dd-menu,
.nav-dropdown.open .nav-dd-menu { display: block; }
.nav-dd-menu li { display: block; margin: 0; }
.app-header .nav-dd-menu li { padding: 0; }
.app-header .nav-dd-menu .nav-link {
    display: block; padding: 8px 12px; margin: 1px 0; white-space: nowrap;
    border-radius: 6px; line-height: 1.2;
    color: #e7ecf6 !important; opacity: 0.9; font-weight: 500;
}
.app-header .nav-dd-menu .nav-link:hover { background: #2e4272; color: #fff !important; opacity: 1; text-decoration: none; }
.app-header .nav-dd-menu .nav-link.active {
    background: #2e4272; color: #fff !important; opacity: 1;
    text-decoration: none; font-weight: 500;
}

/* Menu utilisateur : ouverture au CLIC uniquement (pas au survol), aligné à droite. */
.user-menu .user-menu-toggle { display: inline-flex; align-items: center; gap: 0.4rem; }
.user-menu .caret { font-size: 0.7rem; opacity: 0.8; }
.user-menu:hover .nav-dd-menu { display: none; }
.user-menu.open .nav-dd-menu { display: block; }
.user-menu .nav-dd-menu { left: auto; right: 0; min-width: 160px; }
.app-header .user-menu .nav-dd-menu .logout-link { color: #ffc2c2 !important; }
.app-header .user-menu .nav-dd-menu .logout-link:hover { background: rgba(255,255,255,0.08); color: #fff !important; }

/* Coche « Vue mini » (menu utilisateur) */
.app-header .user-menu .mini-view-toggle {
    display: flex; align-items: center; gap: 0.45rem; padding: 8px 12px; margin: 1px 0;
    border-radius: 6px; white-space: nowrap; cursor: pointer;
    color: #e7ecf6; font-size: 0.9rem; font-weight: 500;
}
.app-header .user-menu .mini-view-toggle:hover { background: #2e4272; color: #fff; }
.app-header .user-menu .mini-view-toggle input { margin: 0; cursor: pointer; }
/* Vue mini : seul l'onglet Génération reste dans la barre de navigation */
body.mini-view #nav-links > li:not(.mini-keep) { display: none !important; }

/* Items masqués dans un sous-menu : `.nav-dd-menu li { display:block }` écrase le
   `[hidden]` natif -> on force le masquage (admin-only, etc.). */
.app-header .nav-dd-menu li[hidden] { display: none !important; }

/* Champs de date jj/mm/aaaa (dates_fr.js, repris de Calife) : saisie texte + bouton calendrier ; le champ natif,
   masqué, garde la valeur et sert d'ancre au calendrier. Bouton remis à zéro face aux styles Pico. */
.date-fr { position: relative; display: inline-flex; align-items: center; width: fit-content; max-width: 100%; align-self: flex-start; }
.date-fr > input[type=date] { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; padding: 0; border: 0;
  margin: 0; opacity: 0; pointer-events: none; }
input.date-fr-texte { width: 9.5em; padding-right: 1.9em; box-sizing: border-box; font-variant-numeric: tabular-nums; }
input.date-fr-texte.date-fr-ko { border-color: #c0392b; background: #fdecea; }
.date-fr > button.date-fr-cal { position: absolute; right: .25rem; top: 50%; transform: translateY(-50%); width: auto;
  margin: 0; border: 0; box-shadow: none; background: transparent; color: var(--muted-color, #6b7280); cursor: pointer;
  padding: .1rem; line-height: 0; border-radius: 4px; }
.date-fr > button.date-fr-cal:hover:not(:disabled) { color: inherit; background: #eef1f8; }
.date-fr > button.date-fr-cal:disabled { cursor: default; opacity: .4; }
