/* Baromètre Statistique Goma - Styles */

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --accent: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
}

/* Navigation */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 3rem;
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
}

.logo span {
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-item {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
}

/* Tabs */
.tab-content {
    display: none;
    pointer-events: none;
}

.tab-content.active {
    display: block;
    pointer-events: auto;
}

/* Layout */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.test-data-controls {
    position: relative;
    z-index: 100 !important;
    pointer-events: auto !important;
}

.btn-warning,
.btn-secondary {
    position: relative;
    z-index: 101 !important;
    pointer-events: auto !important;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Hero */
.hero {
    text-align: center;
    padding: 3rem 0;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Stats */
.stats-summary {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.stat-item {
    background: white;
    padding: 1.5rem 2.5rem;
    border-radius: 16px;
    text-align: center;
    border: 1px solid var(--border);
    min-width: 150px;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    margin-top: 0.25rem;
}

/* Cards */
.dashboard-grid,
.questionnaires-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    cursor: pointer;
    transition: all 0.3s;
}

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

.card-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card-desc {
    color: var(--text-muted);
    line-height: 1.5;
}

/* Domains */
.domains-container {
    display: grid;
    gap: 1.5rem;
}

.domain-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
}

.domain-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.domain-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary);
}

.domain-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.domain-indicators {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.indicator-tag {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f8fafc;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    border: 1px solid var(--border);
}

/* Questionnaires */
.questionnaire-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}

.q-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.q-icon {
    font-size: 1.5rem;
}

.q-info h4 {
    margin-bottom: 0.25rem;
}

.q-count {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.q-actions {
    display: flex;
    gap: 0.5rem;
}

/* Test Data Controls */
.test-data-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.input-small {
    width: 80px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
}

/* Buttons */
.btn-primary-small {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary-small:hover {
    background: var(--primary-hover);
}

.btn-warning {
    background: var(--warning);
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.btn-warning:hover {
    filter: brightness(0.9);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
}

.btn-sm.btn-accent {
    background: var(--accent);
    color: white;
    border: none;
}

/* New Button Variants */
.btn-warning {
    background: var(--warning);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-warning:hover {
    background: #d98c06;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--text-muted);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-1px);
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
}

.btn-action {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
}

.btn-filter {
    background: white;
    border: 1px solid var(--border);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    cursor: pointer;
}

.btn-tool {
    background: white;
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

/* Selects */
.select-styled {
    padding: 0.6rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    min-width: 200px;
    cursor: pointer;
}

.analysis-controls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Filter Panel */
.filter-panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.neighborhood-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.neighborhood-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #f8fafc;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Chart Toolbar */
.chart-toolbar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 10px;
    border: 1px solid var(--border);
}

/* Analysis Grid */
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
}

.analysis-summary {
    grid-column: 1 / -1;
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    border-left: 4px solid var(--primary);
}

.analysis-summary h3 {
    margin-bottom: 0.25rem;
}

.analysis-summary p {
    color: var(--text-muted);
}

.chart-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
}

.chart-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.chart-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: #fafafa;
}

.chart-header h4 {
    flex: 1;
}

.test-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: #f1f5f9;
    border-radius: 4px;
}

.test-badge.significant {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
}

.chart-stats {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: #fafafa;
    font-size: 0.9rem;
}

.chart-stats .stat strong {
    color: var(--primary);
}

.chart-body {
    padding: 1rem;
    height: 320px;
    overflow-y: auto;
}

.mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.mini-table th,
.mini-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.mini-table th {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 1;
}

.stat-val {
    font-weight: 600;
    color: var(--primary);
}

.stat-pct {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

/* Map */
.map-container {
    position: relative;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
}

#map {
    height: 65vh;
    min-height: 400px;
}

.map-controls {
    display: flex;
    gap: 0.75rem;
}

.map-legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: white;
    padding: 1rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
    min-width: 200px;
    max-width: 280px;
    z-index: 1000;
}

.map-legend h4 {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.legend-var-title {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-count {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.legend-scale {
    margin: 0.75rem 0;
}

.scale-bar {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(to right, rgb(0, 255, 50), rgb(255, 255, 50), rgb(255, 0, 50));
}

.scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.legend-stats {
    font-size: 0.85rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.legend-stats strong {
    color: var(--primary);
}

.legend-items {
    max-height: 200px;
    overflow-y: auto;
}

.btn-combine {
    background: var(--accent);
    color: white;
    border: none;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-lg {
    max-width: 700px;
}

.modal-xl {
    max-width: 95vw;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-close {
    background: #f1f5f9;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Forms */
.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.input-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.checkbox-grid,
.forms-grid {
    display: grid;
    gap: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
    cursor: pointer;
}

.form-checkbox span {
    flex: 1;
}

.form-checkbox small {
    color: var(--text-muted);
}

/* Structure Modal */
.structure-list {
    max-height: 60vh;
    overflow-y: auto;
}

.structure-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.structure-item:last-child {
    border: none;
}

.s-type {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    height: fit-content;
}

.s-label {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.s-name {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Data Explorer */
.data-explorer {
    max-height: 70vh;
    overflow: auto;
}

.data-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
}

.data-nav button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: white;
    border-radius: 6px;
    cursor: pointer;
}

.data-nav button:disabled {
    opacity: 0.5;
}

.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    background: #f8fafc;
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.data-table tr:hover {
    background: #fafafa;
}

.mini-table {
    width: 100%;
    border-collapse: collapse;
}

.mini-table th,
.mini-table td {
    padding: 0.5rem;
    border: 1px solid var(--border);
    text-align: left;
}

/* Utilities */
.badge {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.error-msg {
    color: var(--danger);
    margin-top: 0.5rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: #fafafa;
    border: 2px dashed var(--border);
    border-radius: 16px;
    grid-column: 1 / -1;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.empty-state p {
    color: var(--text-muted);
}

.loader {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

.loading {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.animate {
    animation: fadeIn 0.4s ease-out;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ML Domain Score Cards */
.domain-score-card:hover {
    border-color: var(--primary) !important;
    background-color: #f8fafc !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.domain-score-card:active {
    transform: translateY(0);
}

.domain-score-card div[id^="domain-details-"] {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    min-width: 300px;
    border-left: 5px solid var(--primary);
}

.toast-success {
    border-left-color: var(--accent);
}

.toast-info {
    border-left-color: var(--primary);
}

.toast-error {
    border-left-color: var(--danger);
}

.animate-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loader-sm {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 0.5rem;
}

.modality-container {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.modality-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.modality-item:hover {
    background: #f1f5f9;
}

.modality-item input {
    cursor: pointer;
}

.modality-all {
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.map-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
}

.map-popup {
    font-family: 'Outfit', sans-serif;
    padding: 0.25rem;
}

.map-popup strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: var(--primary);
}

.pop-val {
    font-size: 0.9rem;
    font-weight: 600;
}

.pop-val span {
    color: var(--accent);
}

.pop-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.pop-range {
    font-size: 0.7rem;
    background: #f1f5f9;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    margin-top: 0.4rem;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .container {
        padding: 1rem;
    }

    .stats-summary {
        gap: 1rem;
    }

    .stat-item {
        min-width: 120px;
        padding: 1rem;
    }

    .analysis-grid {
        grid-template-columns: 1fr;
    }
}

/* Analyse Mode Selector */
.analysis-type-selector {
    display: flex;
    gap: 0.5rem;
    background: #f1f5f9;
    padding: 0.4rem;
    border-radius: 12px;
    width: fit-content;
}

.btn-tab-mode {
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.2s;
    font-family: inherit;
}

.btn-tab-mode.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.analysis-controls-main {
    display: flex;
    gap: 0.75rem;
    width: 100%;
}

.analysis-config-panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-top: 4px solid var(--primary);
    width: 100%;
}

.analysis-results-container {
    width: 100%;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.multi-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
    background: #f8fafc;
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.multi-var-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-action-small {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

.btn-action-small:hover {
    background: var(--primary-hover);
}

.test-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.test-badge.significant {
    background: #dcfce7;
    color: #166534;
}

.cross-result {
    border-left: 5px solid var(--accent) !important;
}

.multi-result {
    grid-column: 1 / -1;
    border-left: 5px solid #8b5cf6 !important;
}

/* Dataset Linking Styles */
.link-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.2rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.link-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.1);
    transform: translateY(-2px);
}

.link-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border);
}

.link-visual {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.link-table-info {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
    min-width: 0;
}

.link-table-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-var-badge {
    display: inline-block;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.08) 0%, rgba(16, 185, 129, 0.08) 100%);
    color: var(--primary);
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    border: 1px solid rgba(79, 70, 229, 0.15);
}

.link-arrow {
    font-size: 1.5rem;
    color: var(--accent);
    flex-shrink: 0;
    animation: pulse-arrow 2s ease-in-out infinite;
}

@keyframes pulse-arrow {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.btn-outline-small {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-outline-small:hover {
    background: var(--primary);
    color: white;
}

/* Sub-Tabs (Sous-onglets) pour Modélisation */
.sub-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: white;
    padding: 0.5rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.sub-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 1rem 1.5rem;
    border: none;
    background: transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    color: var(--text-muted);
}

.sub-tab:hover {
    background: #f8fafc;
    color: var(--text-main);
}

.sub-tab.active {
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.sub-tab-icon {
    font-size: 1.2rem;
}

.sub-tab-label {
    font-size: 0.95rem;
}

.sub-tab-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.sub-tab:not(.active) .sub-tab-badge {
    background: #e5e7eb;
    color: var(--text-muted);
}

/* Sub-Panels */
.sub-panel {
    display: none;
    animation: fadeInUp 0.3s ease;
}

.sub-panel.active {
    display: block;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Link Form Enhancements */
.link-creation-panel {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.panel-title {
    margin-bottom: 1.2rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-icon {
    background: var(--primary);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.link-form-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: end;
}

.link-arrow-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 0.5rem;
}

.link-arrow-static {
    font-size: 1.5rem;
    color: var(--accent);
}

.link-form-actions {
    margin-top: 1rem;
    text-align: right;
}

/* Suggestions Panel */
.suggestions-panel {
    display: none;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.03) 0%, rgba(79, 70, 229, 0.03) 100%);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

.suggestions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Links Grid */
.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .sub-tabs {
        flex-direction: column;
    }

    .link-form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .link-arrow-container {
        padding: 0.5rem 0;
    }

    .link-arrow-static {
        transform: rotate(90deg);
    }
}

/* Links Toolbar */
.links-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.links-toolbar-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.input-filter {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    min-width: 220px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

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

.btn-danger-small {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-danger-small:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* Link Card Enhancements */
.link-card {
    position: relative;
}

.link-card-checkbox {
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

.link-card.selected {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.03);
}

/* Compressed View */
.links-grid.compressed {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.links-grid.compressed .link-card {
    padding: 0.6rem 1rem;
    border-radius: 8px;
    min-width: auto;
    flex: 0 0 auto;
}

.links-grid.compressed .link-card-header,
.links-grid.compressed .link-visual {
    display: none;
}

.links-grid.compressed .link-card::after {
    content: attr(data-summary);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
}

.links-grid.compressed .link-card-checkbox {
    position: static;
    margin-right: 0.5rem;
}

/* Link Card Compact Info */
.link-compact-info {
    display: none;
}

.links-grid.compressed .link-compact-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.links-grid.compressed .link-compact-info .table-name {
    font-weight: 600;
    color: var(--text-main);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.links-grid.compressed .link-compact-info .var-name {
    color: var(--primary);
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
}

@media (max-width: 768px) {
    .links-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .links-toolbar-actions {
        justify-content: space-between;
    }

    .input-filter {
        min-width: auto;
        flex: 1;
    }
}

/* ML & Multivariate Section */
.ml-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-top: 1rem;
}

.config-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.config-grid-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .config-grid-2 {
        grid-template-columns: 1fr;
    }
}

/* ML Domain Cards */
.ml-domains-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) #f1f5f9;
}

.ml-domains-scroll::-webkit-scrollbar {
    width: 6px;
}

.ml-domains-scroll::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.ml-domains-scroll::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.ml-domain-card:hover {
    border-color: var(--primary);
}

.ml-form-item:hover {
    background: rgba(79, 70, 229, 0.06) !important;
}

.checkbox-grid-scroll {
    display: grid;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    padding: 0.25rem 0;
    cursor: pointer;
}

.checkbox-item input {
    width: auto !important;
}

#ml-results-container {
    border-top: 2px dashed var(--border);
    padding-top: 2rem;
    margin-top: 2rem;
}

.ml-qol-chart,
.ml-clusters-chart {
    background: white;
    border-radius: 12px;
}

/* Animations */
.animate {
    animation: fadeIn 0.5s ease-out;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =====================================================
   ASSISTANT CONVERSATIONNEL - CHAT INTERFACE
   ===================================================== */

.chat-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    height: calc(100vh - 250px);
    min-height: 500px;
}

.chat-main {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.chat-suggestions {
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.05), rgba(16, 185, 129, 0.03));
    border-bottom: 1px solid var(--border);
}

.chat-suggestions h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.suggestions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.suggestion-btn {
    background: white;
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-welcome {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.chat-welcome .welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.chat-welcome h3 {
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.chat-message {
    max-width: 80%;
    padding: 1rem 1.25rem;
    border-radius: 16px;
    line-height: 1.6;
    animation: fadeIn 0.3s ease-out;
}

.chat-message.user {
    background: var(--primary);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant {
    background: #f1f5f9;
    color: var(--text-main);
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.chat-message.assistant p {
    margin-bottom: 0.75rem;
}

.chat-message.assistant p:last-child {
    margin-bottom: 0;
}

.chat-message.loading {
    background: #f1f5f9;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.typing-indicator {
    display: flex;
    gap: 0.25rem;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-input-area {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: #fafafa;
    border-top: 1px solid var(--border);
}

.chat-textarea {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    min-height: 48px;
    max-height: 120px;
}

.chat-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.chat-send {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    white-space: nowrap;
}

.chat-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-sidebar .card {
    cursor: default;
    padding: 1.25rem;
}

.chat-sidebar .card:hover {
    transform: none;
}

.chat-sources-list,
.chat-neighborhoods-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.source-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 0.85rem;
}

.source-icon {
    flex-shrink: 0;
}

.neighborhood-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.75rem;
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* =====================================================
   SEUILS D'INDICATEURS - THRESHOLDS PANEL
   ===================================================== */

.thresholds-grid {
    display: grid;
    gap: 1rem;
}

.threshold-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.threshold-item:hover {
    background: white;
    box-shadow: var(--shadow);
}

.threshold-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.threshold-var {
    font-weight: 600;
    color: var(--text-main);
}

.threshold-form {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.threshold-badges {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.threshold-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.threshold-badge.positive {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
}

.threshold-badge.negative {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.threshold-badge.quantitative {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
}

.threshold-badge.qualitative {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.threshold-actions {
    display: flex;
    gap: 0.5rem;
}

.input-field {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
}

/* Responsive */
@media (max-width: 1024px) {
    .chat-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .chat-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .chat-sidebar .card {
        flex: 1;
        min-width: 200px;
    }
}

/* =============================================================================
   THRESHOLD CARDS INTERFACE
   ============================================================================= */

.threshold-cards-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.threshold-card {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-main);
    border-radius: 10px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.threshold-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.1);
}

.threshold-card-question {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.threshold-card-question h4 {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    color: var(--text-main);
}

.threshold-card-question .var-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.threshold-card-config {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.threshold-card-config .config-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.threshold-card-config label {
    font-size: 0.85rem;
    color: var(--text-muted);
    min-width: 60px;
}

.threshold-card-config .select-styled,
.threshold-card-config .input-field {
    flex: 1;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

.threshold-config-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.25rem;
}

.add-positive-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    color: var(--accent);
    background: rgba(16, 185, 129, 0.1);
    border: 1px dashed var(--accent);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.add-positive-btn:hover {
    background: rgba(16, 185, 129, 0.2);
}

.positive-answer-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent);
    border-radius: 4px;
    font-size: 0.8rem;
    margin-right: 0.25rem;
}

.positive-answer-tag .remove-tag {
    cursor: pointer;
    opacity: 0.7;
}

.positive-answer-tag .remove-tag:hover {
    opacity: 1;
}

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

/* Saved Thresholds Grid */
.saved-thresholds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.saved-threshold-item {
    transition: all 0.2s;
}

.saved-threshold-item:hover {
    background: var(--bg-card) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: #dc2626;
    transform: scale(1.05);
}

/* Animations & IA Enhancements */
@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.pulse-optimized {
    animation: pulse-green 2s infinite;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.variable-detail-row:hover {
    background: #f1f5f9 !important;
    transform: translateX(4px);
    border-color: var(--primary) !important;
}

/* Glassmorphism utility */
.glass-panel {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Tri-state Toggle for Modalities */
.tri-state-toggle {
    display: flex;
    background: #f1f5f9;
    border-radius: 20px;
    padding: 2px;
    min-width: 100px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.btn-tri {
    flex: 1;
    border: none;
    background: transparent;
    border-radius: 18px;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 6px 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

.btn-tri:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.5);
}

.btn-tri.active {
    opacity: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.btn-tri.active[onclick*="'pos'"] {
    background: #22c55e !important;
    color: white;
}

.btn-tri.active[onclick*="'neg'"] {
    background: #ef4444 !important;
    color: white;
}

.btn-tri.active[onclick*="'neu'"] {
    background: #94a3b8 !important;
    color: white;
}

.modality-row {
    transition: background 0.2s;
    border-radius: 6px;
}

.modality-row:hover {
    background: #f1f5f9;
}