@import url('https://fonts.googleapis.com/css2?family=Cairo+Play:wght@200..1000&display=swap');
/* Chiffres et ponctuation en Cairo monochrome (Cairo Play les colore) */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@200..1000&text=0123456789%D9%A0%D9%A1%D9%A2%D9%A3%D9%A4%D9%A5%D9%A6%D9%A7%D9%A8%D9%A9-%E2%80%93%E2%80%94.%2C%3A%3B%2F%5C%2B%2A%3D%25%28%29%5B%5D%7B%7D%3C%3E%23%26%40%21%3F%27%22_%7C%E2%80%A2%C2%B7%E2%80%A6%24%E2%82%AC&display=swap');

:root {
    --bg-main: #0b0f19;
    --bg-surface: #111827;
    --bg-card: #1e293b;
    --bg-card-hover: #243248;
    --border-color: #334155;
    --border-subtle: #1e293b;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-blue: #38bdf8;
    --accent-indigo: #6366f1;
    --accent-purple: #a855f7;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;

    /* Nœuds - Thèmes spécifiques */
    --node-mobile-accent: #10b981;
    --node-mobile-bg: rgba(16, 185, 129, 0.08);
    --node-mobile-border: rgba(16, 185, 129, 0.25);

    --node-bank-accent: #38bdf8;
    --node-bank-bg: rgba(56, 189, 248, 0.08);
    --node-bank-border: rgba(56, 189, 248, 0.25);

    --node-ai-accent: #f59e0b;
    --node-ai-bg: rgba(245, 158, 11, 0.08);
    --node-ai-border: rgba(245, 158, 11, 0.25);

    --node-llm-accent: #c084fc;
    --node-llm-bg: rgba(192, 132, 252, 0.08);
    --node-llm-border: rgba(192, 132, 252, 0.25);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.5), 0 2px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.6), 0 4px 10px -2px rgba(0, 0, 0, 0.4);
    --shadow-glow-blue: 0 0 20px rgba(56, 189, 248, 0.15);
}

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

body {
    font-family: 'Cairo', 'Cairo Play', sans-serif;
    background: radial-gradient(circle at top, #111827 0%, #080a0f 100%);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 24px;
    box-sizing: border-box;
}

/* Header SaaS Ultra-Compact */
.app-header {
    position: relative;
    z-index: 200; /* au-dessus des nœuds : le menu des modèles s'affiche devant */
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    background: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 8px 20px;
    margin-bottom: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    gap: 16px;
    min-height: 54px;
    flex-shrink: 0;
}

.brand-section {
    display: flex;
    align-items: center;
    justify-self: center;
    gap: 10px;
}

.brand-logo {
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo img {
    height: 100%;
    width: auto;
    max-width: 160px;
    object-fit: contain;
}

.header-action-group {
    display: flex;
    gap: 8px;
}

.header-square-btn {
    width: 62px;
    height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.55rem;
    font-weight: 600;
    font-family: 'Cairo', 'Cairo Play', sans-serif;
    transition: all 0.2s ease;
}

.header-square-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.header-square-btn svg {
    width: 1.2em;
    height: 1.2em;
}

/* Architecture Flow Pills */
.architecture-flow-pills {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 0 16px;
    height: 44px;
    border-radius: 12px;
    font-size: 0.75rem;
    justify-self: start;
    width: fit-content;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.flow-step {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px;
    border-radius: 4px;
}

.flow-step.step-mobile {
    color: #34d399;
}

.flow-step.step-bank {
    color: #38bdf8;
}

.flow-step.step-ai {
    color: #fbbf24;
}

.flow-step.step-llm {
    color: #c084fc;
}

.flow-arrow {
    color: #64748b;
    font-size: 0.65rem;
}

.header-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    justify-self: end;
    gap: 16px;
}

.model-select {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    height: 44px;
    max-width: 200px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    padding: 0 28px 0 12px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    font-family: 'Cairo', 'Cairo Play', sans-serif;
    appearance: none;
    outline: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.model-select:focus {
    border-color: var(--text-muted);
}

.btn-header-config {
    text-decoration: none !important;
    color: #cbd5e1 !important;
}

.btn-header-config:hover {
    color: #38bdf8 !important;
    border-color: rgba(56, 189, 248, 0.4) !important;
}

.api-key-box {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 4px 10px;
    transition: all 0.2s;
}

.api-key-box:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.api-key-box label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.api-key-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.api-key-box input {
    background: transparent;
    border: none;
    color: #ffffff;
    font-family: 'Cairo', 'Cairo Play', sans-serif;
    font-size: 0.74rem;
    width: 175px;
    padding-right: 22px;
    outline: none;
}

.api-key-box input::placeholder {
    color: #64748b;
    font-size: 0.7rem;
}

.toggle-pwd-btn {
    position: absolute;
    right: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px;
}

.toggle-pwd-btn:hover {
    color: var(--text-primary);
}

.btn-header-action {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-header-action:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: #64748b;
}

/* Architecture Layout Maximisé - Aucun débordement possible */
.architecture-container {
    display: grid;
    grid-template-columns: minmax(320px, 360px) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 24px;
    position: relative;
    flex: 1 1 0%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

/* Nœud mobile transparent pour laisser briller le mockup iPhone */
#node-mobile {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    display: flex;
    align-items: stretch;
    justify-content: center;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

@media (max-width: 1350px) {
    .architecture-container {
        grid-template-columns: 330px repeat(3, minmax(200px, 1fr));
        gap: 10px;
    }

    .architecture-flow-pills {
        display: none;
    }
}

@media (max-width: 1050px),
(max-height: 650px) {
    body {
        overflow-y: auto;
        height: auto;
    }

    .app-header {
        flex-wrap: wrap;
    }

    .architecture-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    #node-mobile {
        min-height: 620px;
    }
}

/* Disabled states for header controls */
.header-square-btn[disabled],
.model-select[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Police Cairo Play partout (chiffres/ponctuation : Cairo), y compris dans les champs de formulaire */
button,
input,
select,
textarea,
code,
pre,
kbd {
    font-family: 'Cairo', 'Cairo Play', sans-serif;
}
/* Switch « Multi-requests » du header */
.header-switch {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.header-switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.header-switch-track {
    position: relative;
    width: 28px;
    height: 16px;
    border-radius: 9999px;
    background: #334155;
    transition: background 0.2s;
    flex-shrink: 0;
}

.header-switch-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e2e8f0;
    transition: transform 0.2s;
}

.header-switch input:checked + .header-switch-track { background: #10b981; }
.header-switch input:checked + .header-switch-track::after { transform: translateX(12px); }
.header-switch input:checked ~ .header-switch-label { color: var(--text-primary); }
.header-switch input:focus-visible + .header-switch-track { outline: 2px solid #38bdf8; outline-offset: 2px; }
.header-switch:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }

/* Sélecteur de modèle premium */
.model-select.model-select-native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; overflow: hidden; }
.model-picker { position: relative; }
.model-picker-trigger {
    display: flex; align-items: center; gap: 10px;
    height: 44px; width: 230px; padding: 0 12px 0 8px;
    border-radius: 12px; border: 1px solid var(--border-color);
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.9));
    color: var(--text-primary); font-family: 'Cairo', 'Cairo Play', sans-serif; cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.model-picker-trigger:hover { border-color: rgba(56, 189, 248, 0.45); }
.model-picker.open .model-picker-trigger { border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15); }
.model-picker.disabled { opacity: 0.5; pointer-events: none; }
.mp-trigger-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(99, 102, 241, 0.25)); color: #7dd3fc; }
.mp-trigger-icon svg { width: 15px; height: 15px; }
.mp-trigger-text { display: flex; flex-direction: column; min-width: 0; flex: 1; text-align: start; line-height: 1.15; }
.mp-trigger-label { font-size: 0.56rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.mp-trigger-name { font-size: 0.74rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-trigger-chevron { display: inline-flex; color: var(--text-secondary); transition: transform 0.2s; }
.mp-trigger-chevron svg { width: 14px; height: 14px; }
.model-picker.open .mp-trigger-chevron { transform: rotate(180deg); }

.model-picker-panel {
    position: absolute; top: calc(100% + 8px); left: 0; z-index: 1000;
    width: 380px; max-width: calc(100vw - 24px);
    border-radius: 14px; border: 1px solid rgba(71, 85, 105, 0.6);
    background: rgba(15, 23, 42, 0.97); backdrop-filter: blur(16px);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
    overflow: hidden; animation: mpIn 0.16s ease-out;
}
.model-picker-panel[hidden] { display: none; }
@keyframes mpIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.mp-search { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); color: var(--text-muted); }
.mp-search svg { width: 14px; height: 14px; flex-shrink: 0; }
.mp-search input { flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--text-primary); font: inherit; font-size: 0.76rem; }
.mp-search input::placeholder { color: var(--text-muted); }
.mp-count { font-size: 0.6rem; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--bg-card); color: var(--text-secondary); }
.mp-list { max-height: 400px; overflow-y: auto; padding: 6px; scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.mp-group + .mp-group { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border-subtle); }
.mp-group-head { display: flex; align-items: baseline; justify-content: space-between; padding: 6px 8px 4px; font-size: 0.58rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-secondary); }
.mp-group-head em { font-style: normal; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-muted); }
.mp-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: none; border-radius: 9px; background: none; color: var(--text-primary); font: inherit; text-align: start; cursor: pointer; }
.mp-item:hover, .mp-item.active { background: rgba(56, 189, 248, 0.08); }
.mp-item.selected { background: rgba(56, 189, 248, 0.14); }
.mp-item-main { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.mp-item-name { font-size: 0.74rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-item-id { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.6rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-item-tags { display: flex; gap: 4px; flex-shrink: 0; }
.mp-tag { font-size: 0.54rem; font-weight: 600; padding: 2px 6px; border-radius: 999px; }
.mp-tag.amber { background: rgba(245, 158, 11, 0.14); color: #fbbf24; }
.mp-tag.blue { background: rgba(56, 189, 248, 0.14); color: #7dd3fc; }
.mp-tag.muted { background: rgba(148, 163, 184, 0.12); color: var(--text-secondary); }
.mp-item-check { display: inline-flex; width: 16px; height: 16px; color: var(--accent-blue); opacity: 0; flex-shrink: 0; }
.mp-item-check svg { width: 16px; height: 16px; }
.mp-item.selected .mp-item-check { opacity: 1; }
.mp-group.muted .mp-item-name { color: var(--text-secondary); }
.mp-empty { padding: 24px 12px; text-align: center; font-size: 0.72rem; color: var(--text-muted); }
.mp-foot { padding: 8px 12px; border-top: 1px solid var(--border-subtle); font-size: 0.58rem; color: var(--text-muted); }

/* Sélecteur de modèle : variante réglages de l'iPhone (thème clair) */
.model-picker.mp-phone { width: 100%; }
.model-picker.mp-phone .model-picker-trigger { width: 100%; height: 40px; padding: 0 10px 0 6px; border-radius: 10px; border-color: #e2e8f0; background: #fff; color: #0f172a; }
.model-picker.mp-phone .model-picker-trigger:hover { border-color: #93b4f0; }
.model-picker.mp-phone.open .model-picker-trigger { border-color: #1d5bd8; box-shadow: 0 0 0 3px rgba(29, 91, 216, 0.14); }
.model-picker.mp-phone .mp-trigger-icon { width: 26px; height: 26px; background: #eaf1fd; color: #1d5bd8; }
.model-picker.mp-phone .mp-trigger-label { color: #94a3b8; }
.model-picker.mp-phone .mp-trigger-name { color: #0f172a; }
.model-picker.mp-phone .model-picker-panel { width: 100%; background: #fff; border-color: #e2e8f0; box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16); }
.model-picker.mp-phone .mp-search { border-bottom-color: #eef2f7; color: #94a3b8; }
.model-picker.mp-phone .mp-search input { color: #0f172a; }
.model-picker.mp-phone .mp-count { background: #f1f5f9; color: #64748b; }
.model-picker.mp-phone .mp-list { max-height: 250px; scrollbar-color: #cbd5e1 transparent; }
.model-picker.mp-phone .mp-group + .mp-group { border-top-color: #eef2f7; }
.model-picker.mp-phone .mp-group-head { color: #64748b; }
.model-picker.mp-phone .mp-group-head em { color: #94a3b8; }
.model-picker.mp-phone .mp-item { color: #0f172a; }
.model-picker.mp-phone .mp-item:hover, .model-picker.mp-phone .mp-item.active { background: #f1f5fb; }
.model-picker.mp-phone .mp-item.selected { background: #eaf1fd; }
.model-picker.mp-phone .mp-item-id { color: #94a3b8; }
.model-picker.mp-phone .mp-item-check { color: #1d5bd8; }
.model-picker.mp-phone .mp-group.muted .mp-item-name { color: #64748b; }
.model-picker.mp-phone .mp-tag.amber { background: #fef3c7; color: #b45309; }
.model-picker.mp-phone .mp-tag.blue { background: #e0ecff; color: #1d5bd8; }
.model-picker.mp-phone .mp-tag.muted { background: #f1f5f9; color: #64748b; }
.model-picker.mp-phone .mp-foot { border-top-color: #eef2f7; color: #94a3b8; }
.model-picker.mp-phone .mp-item-tags { display: none; }
.model-picker.mp-phone .mp-item.selected .mp-item-tags, .model-picker.mp-phone .mp-item:hover .mp-item-tags { display: flex; }
