/* reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* base */
body {
    font-family: "DM Sans", sans-serif;
    background: #001932;
    min-height: 100vh;
    color: #fff;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 760px;
    margin: 0 auto;
}

/* =====================
   Écran 1 — Setup
   ===================== */

.setup {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 1.25rem;
}

.logo {
    font-family: "Syne", sans-serif;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .15em;
    color: #019ee0;
    text-transform: uppercase;
    margin-bottom: 2rem;
}

.setup h1 {
    font-family: "Syne", sans-serif;
    font-size: clamp(1.5rem, 5vw, 2.4rem);
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: .5rem;
}

.setup h1 span {
    color: #e2017a;
}

.setup > p {
    color: rgba(255, 255, 255, .55);
    font-size: .9rem;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.field {
    margin-bottom: 1rem;
}

.field label {
    display: block;
    font-size: .75rem;
    font-weight: 500;
    letter-spacing: .06em;
    color: rgba(255, 255, 255, .5);
    margin-bottom: .4rem;
    text-transform: uppercase;
}

.field input,
.field textarea {
    width: 100%;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 8px;
    padding: .75rem 1rem;
    color: #fff;
    font-family: "DM Sans", sans-serif;
    font-size: .95rem;
    outline: none;
    transition: border-color .2s;
}

.field input:focus,
.field textarea:focus {
    border-color: #019ee0;
}

.field textarea {
    resize: vertical;
    min-height: 90px;
    line-height: 1.5;
}

.field input::placeholder,
.field textarea::placeholder {
    color: rgba(255, 255, 255, .25);
}

.row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.btn-primary {
    width: 100%;
    margin-top: 1rem;
    background: #e2017a;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    font-family: "Syne", sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: .04em;
    transition: opacity .2s, transform .1s;
}

.btn-primary:hover {
    opacity: .9;
}

.btn-primary:active {
    transform: scale(.98);
}

.btn-primary:disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* =====================
   Écran 2 — Chat
   ===================== */

.chat-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.chat-header {
    background: rgba(0, 25, 50, .97);
    padding: .875rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    align-items: center;
    gap: .875rem;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.avatar-rec {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #019ee0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Syne", sans-serif;
    font-weight: 700;
    font-size: .75rem;
    flex-shrink: 0;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-header-info strong {
    display: block;
    font-family: "Syne", sans-serif;
    font-size: .85rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-info span {
    font-size: .75rem;
    color: rgba(255, 255, 255, .5);
}

.progress {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

.progress-label {
    font-size: .7rem;
    color: rgba(255, 255, 255, .45);
    font-weight: 500;
}

.progress-dots {
    display: flex;
    gap: 4px;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    transition: background .3s;
}

.dot.done {
    background: #019ee0;
}

.dot.active {
    background: #e2017a;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
    width: 4px;
}

.messages::-webkit-scrollbar-track {
    background: transparent;
}

.messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .15);
    border-radius: 2px;
}

.msg {
    display: flex;
    gap: .625rem;
    align-items: flex-end;
    max-width: 88%;
}

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

.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    font-weight: 700;
    font-family: "Syne", sans-serif;
}

.msg.assistant .msg-avatar {
    background: #019ee0;
}

.msg.user .msg-avatar {
    background: #e2017a;
}

.bubble {
    padding: .7rem .9rem;
    border-radius: 16px;
    line-height: 1.55;
    font-size: .875rem;
}

.msg.assistant .bubble {
    background: rgba(255, 255, 255, .08);
    border-bottom-left-radius: 4px;
    color: #fff;
}

.msg.user .bubble {
    background: #e2017a;
    border-bottom-right-radius: 4px;
    color: #fff;
}

/* indicateur de frappe */
.typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: .5rem .6rem;
}

.typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .4);
    animation: bounce .8s infinite;
}

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

.typing span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-6px); }
}

/* pied de page chat */
.chat-footer {
    background: rgba(0, 25, 50, .97);
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding: .875rem 1.25rem;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
}

.input-row {
    display: flex;
    gap: .625rem;
    align-items: flex-end;
}

.input-row textarea {
    flex: 1;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 10px;
    padding: .65rem .9rem;
    color: #fff;
    font-family: "DM Sans", sans-serif;
    font-size: .875rem;
    outline: none;
    resize: none;
    transition: border-color .2s;
    line-height: 1.5;
    max-height: 100px;
}

.input-row textarea:focus {
    border-color: #019ee0;
}

.input-row textarea::placeholder {
    color: rgba(255, 255, 255, .25);
}

.btn-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #e2017a;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .2s, transform .1s;
    color: #fff;
}

.btn-send:hover {
    opacity: .9;
}

.btn-send:active {
    transform: scale(.95);
}

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

.btn-end {
    font-size: .7rem;
    color: rgba(255, 255, 255, .35);
    background: none;
    border: none;
    cursor: pointer;
    padding: .25rem .5rem;
    margin-top: .35rem;
    text-decoration: underline;
    display: block;
}

.btn-end:hover {
    color: rgba(255, 255, 255, .6);
}

/* =====================
   Écran 3 — Résultats
   ===================== */

.results {
    flex: 1;
    padding: 2rem 1.25rem;
    overflow-y: auto;
}

.results-header {
    text-align: center;
    padding: 2rem 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    margin-bottom: 1.5rem;
}

.score-ring {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: linear-gradient(135deg, #019ee0, #e2017a);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.8rem;
}

.results-header h2 {
    font-family: "Syne", sans-serif;
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    font-weight: 700;
    margin-bottom: .3rem;
}

.results-header p {
    font-size: .82rem;
    color: rgba(255, 255, 255, .5);
}

.reco-raw {
    font-size: .875rem;
    line-height: 1.75;
    color: rgba(255, 255, 255, .85);
    white-space: pre-wrap;
}

.btn-restart {
    width: 100%;
    margin-top: 2rem;
    background: transparent;
    color: #019ee0;
    border: 1px solid #019ee0;
    border-radius: 8px;
    padding: .85rem 1.5rem;
    font-family: "Syne", sans-serif;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: .04em;
    transition: background .2s, color .2s;
}

.btn-restart:hover {
    background: #019ee0;
    color: #fff;
}

.loading-results {
    text-align: center;
    padding: 3rem 1rem;
    color: rgba(255, 255, 255, .5);
    font-size: .9rem;
}

.loading-results .spin {
    font-size: 2rem;
    display: block;
    margin-bottom: 1rem;
    animation: spin 1.5s linear infinite;
}

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

.error-msg {
    background: rgba(226, 1, 122, .15);
    border: 1px solid rgba(226, 1, 122, .4);
    border-radius: 8px;
    padding: .75rem 1rem;
    font-size: .85rem;
    color: #ffb3d9;
    margin-top: .5rem;
}

/* =====================
   Breakpoint 1000px
   ===================== */

@media (min-width: 1000px) {
    .setup {
        padding: 3rem 2rem;
    }

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

    .chat-header {
        padding: 1rem 2rem;
    }

    .messages {
        padding: 1.5rem 2rem;
    }

    .chat-footer {
        padding: 1rem 2rem;
    }

    .results {
        padding: 2rem;
    }

    .msg {
        max-width: 78%;
    }
}
