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

body {
    font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f0f2f5;
    color: #111;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 700px;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 0 30px rgba(0,58,88,0.08);
}

/* ── Header ── */
.chat-header {
    background: #003A58;
    color: #fff;
    padding: 14px 20px;
    flex-shrink: 0;
    z-index: 10;
}

.header-inner {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.header-sub {
    font-size: 13px;
    opacity: 0.7;
    font-weight: 400;
}

/* ── Chat wrapper ── */
.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Messages ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f0f2f5;
}

/* ── Message bubbles ── */
.message {
    max-width: 85%;
    animation: msgIn 0.25s ease;
}

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

.msg-bot {
    align-self: flex-start;
}

.msg-user {
    align-self: flex-end;
}

.bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

.msg-bot .bubble {
    background: #fff;
    border: 1px solid #e0e4e8;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.msg-user .bubble {
    background: #003A58;
    color: #fff;
    border-bottom-right-radius: 6px;
}

/* ── Options (chips) ── */
.options-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chip {
    display: inline-block;
    padding: 10px 16px;
    background: #fff;
    border: 1.5px solid #25B1E6;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    max-width: 100%;
    user-select: none;
}

.chip:hover {
    background: #e6f7fd;
    border-color: #1B79A0;
}

.chip.selected {
    background: #25B1E6;
    color: #fff;
    border-color: #25B1E6;
}

.chip-multi-hint {
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
    font-weight: 500;
}

.chip-confirm {
    padding: 8px 20px;
    margin-top: 10px;
    background: #25B1E6;
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    font-family: "Poppins", sans-serif;
}

.chip-confirm:hover:not(:disabled) {
    background: #1B79A0;
}

.chip-confirm:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Typing indicator ── */
.typing {
    align-self: flex-start;
    padding: 12px 18px;
    background: #fff;
    border: 1px solid #e0e4e8;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    display: flex;
    gap: 4px;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #bbb;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.5); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Input ── */
.chat-footer {
    flex-shrink: 0;
    padding: 12px 16px 20px;
    background: #fff;
    border-top: 1px solid #e0e4e8;
}

.input-area {
    display: flex;
    gap: 10px;
    align-items: center;
}

#user-input {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid #d0d0d0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    background: #f5f5f5;
    transition: border-color 0.15s, background 0.15s;
    font-family: "Poppins", sans-serif;
}

#user-input:disabled {
    background: #f8f9fa;
    color: #999;
    cursor: not-allowed;
    border-color: #e8e8e8;
}

#user-input:focus:not(:disabled) {
    border-color: #25B1E6;
    background: #fff;
}

.btn-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #003A58;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-send:hover:not(:disabled) {
    background: #25B1E6;
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Restart ── */
.restart-area {
    text-align: center;
    margin-top: 6px;
}

.restart-area.hidden {
    display: none;
}

.btn-restart {
    padding: 12px 28px;
    background: #003A58;
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    font-family: "Poppins", sans-serif;
}

.btn-restart:hover {
    background: #25B1E6;
}

/* ── Results card ── */
.results-card {
    background: #fff;
    border: 1px solid #e0e4e8;
    border-radius: 14px;
    padding: 16px;
    margin-top: 6px;
    font-size: 14px;
    overflow-x: auto;
}

.results-card h3 {
    font-size: 16px;
    color: #003A58;
    margin-bottom: 12px;
}

.segment-badge {
    display: inline-block;
    background: #e6f7fd;
    color: #003A58;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 13px;
    margin-bottom: 14px;
    font-weight: 600;
}

.category-title {
    font-size: 14px;
    font-weight: 700;
    color: #1B79A0;
    margin-top: 16px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1.5px solid #25B1E6;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.results-table th {
    background: #f5f5f5;
    text-align: left;
    padding: 7px 10px;
    font-weight: 600;
    color: #555;
    font-size: 12px;
}

.results-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
}

.product-name {
    font-weight: 600;
}

.prio {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.prio-prioritaire { background: #ffebee; color: #c62828; }
.prio-reglementaire { background: #e3f2fd; color: #1565c0; }
.prio-secondaire { background: #f5f5f5; color: #888; }
.prio-none { background: transparent; color: #ccc; }

.variant-name { font-weight: 600; color: #1B79A0; font-size: 12px; }
.variant-reason { color: #888; font-size: 11px; font-style: italic; }

.just-tag {
    display: block;
    font-size: 11px;
    background: #f0fff0;
    border-left: 3px solid #25B1E6;
    padding: 3px 8px;
    margin: 2px 0;
    border-radius: 3px;
    color: #555;
}

.global-note {
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 13px;
}

/* ── Mobile ── */
@media (max-width: 480px) {
    body {
        height: 100dvh;
        background: #f0f2f5;
    }

    #app {
        max-width: 100%;
        box-shadow: none;
        border-radius: 0;
    }

    /* Header */
    .chat-header {
        padding: 10px 14px;
    }
    .logo {
        font-size: 18px;
    }
    .header-sub {
        display: none;
    }

    /* Messages */
    .chat-messages {
        padding: 10px 8px;
        gap: 6px;
    }
    .message {
        max-width: 90%;
    }
    .bubble {
        font-size: 15px;
        padding: 10px 13px;
        line-height: 1.45;
    }
    .msg-bot .bubble {
        border-bottom-left-radius: 4px;
    }
    .msg-user .bubble {
        border-bottom-right-radius: 4px;
    }

    /* Typing */
    .typing {
        padding: 10px 14px;
    }
    .typing-dot {
        width: 7px;
        height: 7px;
    }

    /* Chips */
    .options-list {
        gap: 6px;
        margin-top: 8px;
    }
    .chip {
        padding: 11px 15px;
        font-size: 14px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    .chip-multi-hint {
        font-size: 13px;
        margin-bottom: 6px;
    }
    .chip-confirm {
        width: 100%;
        text-align: center;
        font-size: 15px;
        padding: 14px 0;
        margin-top: 8px;
    }

    /* Input */
    .chat-footer {
        padding: 8px 10px calc(12px + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid #dde;
    }
    #user-input {
        font-size: 16px;
        padding: 11px 14px;
    }

    /* Results — card layout instead of table */
    .results-card {
        padding: 10px;
        border-radius: 10px;
        font-size: 13px;
    }
    .results-card h3 {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .segment-badge {
        font-size: 13px;
        padding: 4px 10px;
        margin-bottom: 10px;
    }

    .category-title {
        font-size: 14px;
        margin-top: 14px;
        margin-bottom: 8px;
    }

    .results-table thead {
        display: none;
    }

    .results-table,
    .results-table tbody,
    .results-table tr,
    .results-table td {
        display: block;
    }

    .results-table tr {
        background: #fff;
        border: 1px solid #e8eaed;
        border-radius: 10px;
        padding: 10px 12px;
        margin-bottom: 8px;
    }

    .results-table td {
        padding: 3px 0;
        border: none;
    }

    .product-name {
        font-size: 14px;
        font-weight: 700;
        color: #003A58;
        margin-bottom: 4px;
    }

    .results-table td:nth-child(2)::before {
        content: "Priorité : ";
        font-size: 11px;
        color: #999;
        font-weight: 600;
    }

    .results-table td:nth-child(3)::before {
        content: "Variante : ";
        font-size: 11px;
        color: #999;
        font-weight: 600;
    }

    .prio {
        display: inline-block;
        margin: 2px 0;
    }

    .variant-cell {
        font-size: 12px;
    }

    .variant-name {
        font-size: 13px;
    }

    .just-tag {
        margin-top: 5px;
        font-size: 12px;
        padding: 4px 8px;
    }

    .global-note {
        font-size: 13px;
        padding: 6px 10px;
    }

    /* Restart */
    .btn-restart {
        width: 100%;
        padding: 14px 28px;
        font-size: 16px;
    }
}
