/* CSS Variables and Design System */
:root {
    --font-main: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
    
    /* Light Theme */
    --bg-primary: var(--g-bg);
    --bg-secondary: var(--g-surface);
    --bg-tertiary: var(--g-surface-2);
    --border-color: var(--g-border);
    --text-main: var(--g-text);
    --text-muted: var(--g-text-2);
    --text-white: #ffffff;
    
    /* Primary Colors */
    --primary: var(--g-accent);
    --primary-hover: var(--g-accent-hover);
    --primary-light: var(--g-accent-soft);
    --accent: var(--g-accent);
    
    /* Status Colors */
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

.dark {
    /* Dark Theme */
    --success-light: #062f21;
    --warning-light: #3a2205;
    --danger-light: #3c0c0c;
}

/* Reset and Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}



#theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    width: 2.2rem;
    height: 2.2rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

#theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
    background-color: var(--bg-tertiary);
}

.hidden {
    display: none !important;
}

/* Layout and Container */
.main-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.section-title i {
    color: var(--primary);
}

/* Models Grid Section */
.models-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 2.5rem;
}

@media (max-width: 850px) {
    .models-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 480px) {
    .models-grid {
        grid-template-columns: 1fr;
    }
}

.model-card {
    background-color: var(--bg-secondary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    cursor: pointer;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 110px;
    justify-content: flex-start;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.model-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.model-card.active {
    border-color: var(--primary);
    background-color: var(--primary-light);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
}

.model-card-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: var(--radius-sm);
    background-color: var(--bg-primary);
    flex-shrink: 0;
}

.dark .model-card-icon-wrapper {
    background-color: var(--bg-tertiary);
}

.model-card-body-wrapper {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.model-title {
    font-weight: 800;
    font-size: 0.85rem;
    line-height: 1.35;
    margin-bottom: 0.35rem;
    color: var(--text-main);
    white-space: normal;
}

.model-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: normal;
    line-height: 1.4;
}

/* Segmented Pills Controls (Tabs) */
.editor-tabs {
    display: flex;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 0.25rem;
    margin-bottom: 1.5rem;
    max-width: fit-content;
    gap: 0.25rem;
}

.tab-btn {
    border: none;
    background: none;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    background-color: var(--bg-secondary);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Two-column layout: Form / Results */
.app-grid {
    display: grid;
    grid-template-cols: 380px 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 968px) {
    .app-grid {
        grid-template-cols: 1fr;
    }
}

/* Cards */
.card-panel {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

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

.form-label {
    display: block;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-select, .form-input {
    width: 100%;
    font-family: var(--font-main);
    font-size: 0.85rem;
    color: var(--text-main);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
    outline: none;
}

.form-select:focus, .form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-row {
    display: grid;
    grid-template-cols: 1fr 1fr;
    gap: 0.75rem;
}

/* Deliverables Header Options (Exports) */
.export-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn-export {
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-export:hover {
    border-color: var(--primary);
    color: var(--primary);
    background-color: var(--bg-primary);
}

.btn-export-all {
    background-color: var(--primary);
    color: var(--text-white);
    border-color: var(--primary);
}

.btn-export-all:hover {
    background-color: var(--primary-hover);
    color: var(--text-white);
    border-color: var(--primary-hover);
}

/* SMART Formulation block */
.smart-formulation-box {
    background: linear-gradient(135deg, var(--primary-light), rgba(6, 182, 212, 0.08));
    border: 1.5px solid rgba(79, 70, 229, 0.2);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.smart-formulation-box::before {
    content: "OBJECTIF SMART FORMULÉ (MODIFIABLE)";
    position: absolute;
    top: -10px;
    left: 20px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: var(--text-white);
    font-size: 0.65rem;
    font-weight: 900;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.8px;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.editable-textarea {
    width: 100%;
    background: transparent;
    border: none;
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.5;
    resize: none;
    outline: none;
}

.dark .editable-textarea {
    color: #a5b4fc;
}

.editable-textarea:focus {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 8px;
    box-shadow: 0 0 0 2px var(--primary);
}

/* SMART criteria list with specific branding per letter */
.smart-criteria-grid {
    display: grid;
    grid-template-cols: repeat(5, 1fr);
    gap: 0.85rem;
    margin-bottom: 2rem;
}

@media (max-width: 968px) {
    .smart-criteria-grid {
        grid-template-cols: 1fr;
    }
}

.criteria-card {
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    position: relative;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.criteria-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.criteria-letter {
    font-size: 3rem;
    font-weight: 950;
    position: absolute;
    bottom: -5px;
    right: 5px;
    line-height: 1;
    pointer-events: none;
}

.criteria-title {
    font-weight: 900;
    color: var(--g-text); /* la couleur du critère est portée par la bordure gauche */
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.criteria-desc {
    width: 100%;
    background: transparent;
    border: none;
    font-family: var(--font-main);
    font-size: 0.78rem;
    color: var(--text-main);
    line-height: 1.45;
    resize: none;
    outline: none;
    position: relative;
    z-index: 2;
}

.criteria-desc:focus {
    background-color: var(--bg-primary);
    box-shadow: 0 0 0 2px var(--primary);
    border-radius: var(--radius-sm);
    padding: 4px;
}

/* Individual colors for S M A R T */
.criteria-card:nth-child(1) { border-left: 4.5px solid #3b82f6; }
.criteria-card:nth-child(1) .criteria-letter { color: rgba(59, 130, 246, 0.08); }

.criteria-card:nth-child(2) { border-left: 4.5px solid #10b981; }
.criteria-card:nth-child(2) .criteria-letter { color: rgba(16, 185, 129, 0.08); }

.criteria-card:nth-child(3) { border-left: 4.5px solid #f59e0b; }
.criteria-card:nth-child(3) .criteria-letter { color: rgba(245, 158, 11, 0.08); }

.criteria-card:nth-child(4) { border-left: 4.5px solid #8b5cf6; }
.criteria-card:nth-child(4) .criteria-letter { color: rgba(139, 92, 246, 0.08); }

.criteria-card:nth-child(5) { border-left: 4.5px solid #ef4444; }
.criteria-card:nth-child(5) .criteria-letter { color: rgba(239, 68, 68, 0.08); }

/* KPIs section styles */
.kpis-grid {
    display: grid;
    grid-template-cols: 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.kpi-card {
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: grid;
    grid-template-cols: 1fr 220px;
    gap: 1.5rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
    .kpi-card {
        grid-template-cols: 1fr;
    }
}

.kpi-main-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.kpi-name-input {
    font-family: var(--font-main);
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--text-main);
    background: transparent;
    border: none;
    width: 100%;
    outline: none;
    border-bottom: 1.5px dashed transparent;
    padding-bottom: 2px;
}

.kpi-name-input:focus {
    border-bottom-color: var(--primary);
}

.kpi-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    align-items: center;
}

.kpi-meta-item strong {
    color: var(--text-main);
}

.kpi-formula-input, .kpi-source-input {
    background: transparent;
    border: none;
    font-family: var(--font-main);
    font-size: 0.8rem;
    color: var(--text-main);
    font-weight: 700;
    outline: none;
    border-bottom: 1.5px dashed transparent;
}

.kpi-formula-input:focus, .kpi-source-input:focus {
    border-bottom-color: var(--primary);
}

.kpi-source-link {
    color: var(--primary);
    text-decoration: underline;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.kpi-target-col {
    background-color: var(--primary-light);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 1.5px dashed var(--primary);
    transition: background-color 0.2s ease;
}

.kpi-target-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.kpi-target-value-input {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--primary);
    width: 100%;
    text-align: center;
    background: transparent;
    border: none;
    outline: none;
}

.dark .kpi-target-value-input {
    color: #a5b4fc;
}

/* Alert Thresholds styling */
.alert-thresholds-box {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.thresholds-grid {
    display: grid;
    grid-template-cols: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.threshold-indicator {
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 700;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.threshold-green {
    background-color: var(--success-light);
    color: var(--success);
}
.threshold-yellow {
    background-color: var(--warning-light);
    color: var(--warning);
}
.threshold-red {
    background-color: var(--danger-light);
    color: var(--danger);
}

/* Recommendations Action Plan */
.actions-list {
    display: grid;
    grid-template-cols: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .actions-list {
        grid-template-cols: 1fr;
    }
}

.action-card {
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.action-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.action-num {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: var(--text-white);
    font-weight: 900;
    font-size: 0.95rem;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.15);
}

.action-card textarea {
    width: 100%;
    background: transparent;
    border: none;
    font-family: var(--font-main);
    font-size: 0.8rem;
    color: var(--text-main);
    line-height: 1.5;
    resize: none;
    outline: none;
}

.action-card textarea:focus {
    box-shadow: 0 0 0 2px var(--primary);
    border-radius: var(--radius-sm);
    padding: 4px;
    background-color: var(--bg-primary);
}

/* KPI Tracking Table */
.kpi-table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.kpi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    text-align: left;
}

.kpi-table th {
    background-color: var(--bg-tertiary);
    padding: 1rem 1.25rem;
    font-weight: 800;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.8px;
}

.kpi-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

.kpi-table tbody tr:last-child td {
    border-bottom: none;
}

.kpi-table tbody tr {
    transition: background-color 0.15s ease;
}

.kpi-table tbody tr:hover {
    background-color: rgba(79, 70, 229, 0.03);
}

.dark .kpi-table tbody tr:hover {
    background-color: rgba(79, 70, 229, 0.08);
}

/* Useful Apps Section */
.useful-apps-section {
    margin-top: 4rem;
    border-t: 1px solid var(--border-color);
    padding-top: 2rem;
}

/* Footer & Methodology styling */
.methodology-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-t: 1px solid var(--border-color);
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Custom Searchable Select Combobox */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select-trigger-container {
    position: relative;
    display: flex;
    align-items: center;
}

.custom-select-search {
    padding-right: 2rem !important;
    cursor: text;
}

.custom-select-arrow {
    position: absolute;
    right: 0.85rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
    transition: transform 0.2s ease;
}

.custom-select-wrapper.open .custom-select-arrow {
    transform: rotate(180deg);
}

.custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-secondary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-top: 0.25rem;
    max-height: 250px;
    overflow-y: auto;
    z-index: 150;
    box-shadow: var(--shadow-lg);
}

.custom-option-group {
    padding: 0.25rem 0;
}

.custom-option-group-title {
    font-size: 0.65rem;
    font-weight: 900;
    color: var(--primary);
    padding: 0.45rem 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.custom-option {
    padding: 0.6rem 0.75rem;
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--text-main);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.custom-option:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.custom-option.selected {
    background-color: var(--primary);
    color: var(--text-white);
}

.custom-select-options.hidden {
    display: none !important;
}

/* Teintes d'état AA en thème clair (texte sur fond clair et fond sous texte blanc ≥ 4,5:1).
   Le thème sombre conserve les teintes vives, lisibles sur fond sombre. */
html:not(.dark) { --success: #15803d; --warning: #92400e; --danger: #b91c1c; }
