/* ============================================================
   Chat asistent iStoma (doar text). Coloana: mesaje (scroll) + composer jos.
   ============================================================ */
.chat {
    /* Inaltime fixa = ecranul, ca zona de mesaje sa scrolleze INTERN, iar composer-ul
       (bara de scriere) sa ramana mereu vizibil jos ("float"). Footer-ul e ascuns pe /Assistant. */
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 820px;
    width: 100%;
    margin: 0 auto;
    padding: 8px 16px 16px;
    box-sizing: border-box;
}

/* Sub 900px apare topbar-ul mobil (fixed, 64px) peste continut -> lasam loc sus. */
@media (max-width: 900px) {
    .chat {
        padding-top: 72px;
    }
}

/* ─── Buton "Inchide chat": lipit de meniul lateral, sus-stanga, evidentiat (verde) ─── */
.chat__close {
    position: fixed;
    top: 16px;
    left: 300px;                     /* lipit de marginea sidebar-ului (desktop) */
    z-index: 40;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 11px 20px;
    border: none;
    border-radius: 0 24px 24px 0;    /* stanga drept (lipit de meniu), dreapta rotunjit */
    background-color: var(--color-cta);
    color: #fff;
    font-size: 14px;
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    transition: background-color var(--transition-base), transform var(--transition-base);
}

    .chat__close:hover {
        background-color: var(--color-cta-hover);
        transform: translateX(2px);
    }

    .chat__close .material-symbols-rounded {
        font-size: 20px;
    }

/* Sidebar restrans -> lipim butonul de noua margine. */
@media (min-width: 901px) {
    html.side-menu-pre-collapsed .chat__close,
    .app-shell.is-collapsed .chat__close {
        left: 88px;
    }
}

/* Mobil: sidebar e drawer (off-canvas) -> butonul la marginea stanga, sub topbar. */
@media (max-width: 900px) {
    .chat__close {
        left: 0;
        top: 72px;
    }
}

/* ─── Zona de mesaje ─────────────────────────────────────────── */
/* Umple inaltimea disponibila din .chat, cu scroll intern; composer-ul ramane jos. */
.chat__messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 8px 4px 16px;
    /* Bara de scroll ascunsa (ramane functionala). */
    scrollbar-width: none;          /* Firefox */
    -ms-overflow-style: none;       /* Edge/IE vechi */
}

    .chat__messages::-webkit-scrollbar {
        display: none;              /* Chrome / Safari / Edge */
    }

/* Pe pagina de chat nu vrem scroll de pagina - mesajele scrolleaza intern. */
html:has(.chat),
body:has(.chat) {
    overflow: hidden;
}

/* ─── Bula de mesaj ──────────────────────────────────────────── */
.chat-msg {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.chat-msg--user {
    align-self: flex-end;
    background-color: var(--color-cta);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg--assistant {
    align-self: flex-start;
    background-color: #F3F4F6;
    color: var(--color-text-primary);
    border-bottom-left-radius: 4px;
}

.chat-msg--error {
    background-color: #FEF3F2;
    color: #B42318;
    border: 1px solid #FECDCA;
}

.chat-msg a {
    color: inherit;
    text-decoration: underline;
}

/* ─── Indicator "scrie..." ───────────────────────────────────── */
.chat-typing {
    align-self: flex-start;
    display: inline-flex;
    gap: 5px;
    padding: 16px;
    background-color: #F3F4F6;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

    .chat-typing span {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background-color: #9CA3AF;
        animation: chatBlink 1.2s infinite both;
    }

        .chat-typing span:nth-child(2) { animation-delay: 0.2s; }
        .chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatBlink {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

/* ─── Ecran de bun venit + sugestii ──────────────────────────── */
.chat__welcome {
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    padding: 24px;
}

.chat__welcome-logo img {
    width: 56px;
    height: auto;
}

.chat__welcome-title {
    font-size: 24px;
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
}

.chat__welcome-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-text-secondary);
    max-width: 440px;
}

.chat__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 8px;
}

.chat__suggestion {
    padding: 10px 16px;
    border: 1px solid #E5E7EB;
    border-radius: 20px;
    background-color: #fff;
    font-size: 14px;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: border-color var(--transition-base), color var(--transition-base);
}

    .chat__suggestion:hover {
        border-color: var(--color-cta);
        color: var(--color-cta);
    }

/* ─── Composer (bara de input) ───────────────────────────────── */
.chat__composer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 8px 16px;
    border: 1px solid #E5E7EB;
    border-radius: 28px;
    background-color: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

    .chat__composer:focus-within {
        border-color: var(--color-cta);
    }

.chat__input {
    flex: 1 1 auto;
    border: none;
    outline: none;
    background: transparent;
    /* 16px: sub 16px iOS face auto-zoom la focus (bara pare deplasata/decentrata). */
    font-size: 16px;
    color: var(--color-text-primary);
    padding: 8px 0;
}

.chat__send {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background-color: var(--color-cta);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-base), opacity var(--transition-base);
}

    .chat__send:hover:not(:disabled) {
        background-color: var(--color-cta-hover);
    }

    .chat__send:disabled {
        opacity: 0.4;
        cursor: default;
    }

    .chat__send .material-symbols-rounded {
        font-size: 22px;
    }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 700px) {
    .chat {
        padding: 72px 10px 12px;
    }

    .chat-msg {
        max-width: 88%;
    }

    .chat__welcome-title {
        font-size: 20px;
    }
}
