/**
 * TISSA Bruno — floating chat widget styles.
 * v1.3.0 — Oleada B / 2026-04-23
 * Token corrections: carbon #252628, cream #FBF9F5, amber #252628.
 * Motion corrections: no infinite loops (§6), square corners (§5).
 * Scoped under .tissa-bruno-root to avoid theme collisions.
 */

/* ---- Design tokens (aligned with tissa theme — canonical values) ---- */
.tissa-bruno-root {
    /* Scoped tokens — reference global vars set by tissa-vars.css */
    --_carbon:       #252628;   /* canonical --tissa-carbon */
    --_cream:        #FBF9F5;   /* canonical --tissa-offwhite */
    --_line:         #E5E5E5;   /* canonical --tissa-border */
    --_muted:        #6B6B6F;   /* canonical --tissa-carbon-muted */
    --_amber:        #252628;   /* canonical --tissa-amber */
    --_amber-hover:  #b45309;   /* amber-dark for hover */
}

.tissa-bruno-root,
.tissa-bruno-root * {
    box-sizing: border-box;
}

.tissa-bruno-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: "Source Serif 4", "Source Serif Pro", Georgia, serif;
}

/* ---- Toggle button ---- */
.tissa-bruno-toggle {
    width: 60px;
    height: 60px;
    border-radius: 4px;                          /* was 50% — §5 square corners */
    background: var(--_carbon);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,0.08);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28), 0 1px 4px rgba(0,0,0,0.14);
    transition: box-shadow 0.2s linear;          /* no transform on toggle */
    padding: 0;
    position: relative;
}
.tissa-bruno-toggle:hover {
    /* color shift only — no translateY (§6 no scale transforms) */
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.34);
}
.tissa-bruno-toggle:focus-visible {
    outline: 2px solid var(--_amber);            /* §9 amber focus ring */
    outline-offset: 2px;
}

.tissa-bruno-toggle-seal {
    width: 34px;
    height: 34px;
    object-fit: contain;
    display: block;
    filter: brightness(0) invert(1);
    opacity: 0.92;
    transition: opacity 0.15s linear;
}
.tissa-bruno-toggle:hover .tissa-bruno-toggle-seal { opacity: 1; }

/* Hide seal when open (show close X) */
.tissa-bruno-root.is-open .tissa-bruno-toggle-seal { display: none; }
.tissa-bruno-icon-close { display: none; }
.tissa-bruno-root.is-open .tissa-bruno-icon-close { display: inline-block; }

/* ---- Panel ---- */
.tissa-bruno-panel {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 388px;
    height: 530px;
    max-height: calc(100vh - 120px);
    background: var(--_cream);
    border-radius: 2px;                          /* §5: square corners, ≤2px */
    border: 1px solid var(--_line);
    box-shadow: 0 20px 54px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0,0,0,0.08);
    overflow: hidden;
    display: none;
    flex-direction: column;
}
.tissa-bruno-root.is-open .tissa-bruno-panel { display: flex; }

/* ---- Header ---- */
.tissa-bruno-header {
    background: var(--_carbon);
    color: var(--_cream);
    padding: 14px 16px 13px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.tissa-bruno-avatar {
    width: 38px;
    height: 38px;
    border-radius: 2px;                          /* square */
    background: rgba(255,255,255,0.07);
    border: 1.5px solid rgba(255,255,255,0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.tissa-bruno-avatar img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

.tissa-bruno-title-wrap { flex: 1; min-width: 0; }

.tissa-bruno-title {
    font-family: "Playfair Display", "Playfair", Georgia, serif;
    font-style: italic;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.01em;
    color: var(--_cream);
}

.tissa-bruno-subtitle {
    font-family: "Geist Mono", "JetBrains Mono", ui-monospace, "Courier New", monospace;
    font-size: 9.5px;
    font-weight: 400;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(251, 249, 245, 0.55);
    margin-top: 3px;
}

.tissa-bruno-close {
    background: transparent;
    border: 0;
    color: var(--_cream);
    cursor: pointer;
    padding: 5px;
    border-radius: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: .55;
    transition: opacity .15s linear;
    flex-shrink: 0;
}
.tissa-bruno-close:hover { opacity: 1; }

/* ---- Messages ---- */
.tissa-bruno-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--_cream);
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--_line) transparent;
}
.tissa-bruno-messages::-webkit-scrollbar { width: 4px; }
.tissa-bruno-messages::-webkit-scrollbar-track { background: transparent; }
.tissa-bruno-messages::-webkit-scrollbar-thumb { background: var(--_line); border-radius: 2px; }

.tissa-bruno-msg {
    max-width: 82%;
    padding: 10px 13px;
    border-radius: 2px;                          /* §5 square corners */
    font-family: "Source Serif 4", "Source Serif Pro", Georgia, serif;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.tissa-bruno-msg-bot {
    background: #fff;
    color: var(--_carbon);
    align-self: flex-start;
    border: 1px solid var(--_line);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.tissa-bruno-msg-user {
    background: var(--_carbon);
    color: var(--_cream);
    align-self: flex-end;
    font-family: "Source Serif 4", "Source Serif Pro", Georgia, serif;
}
.tissa-bruno-msg-error {
    background: #fdecea;
    color: #86251f;
    align-self: flex-start;
    font-size: 13px;
    border: 1px solid #f5c6c2;
    border-radius: 2px;
}

/* ---- Typing indicator (M-12 fix) ----
 * No infinite loop. Static staggered opacity — editorial dots.
 * §6: "Never loop." Infinite animations are prohibited.
 */
.tissa-bruno-typing {
    align-self: flex-start;
    background: #fff;
    border: 1px solid var(--_line);
    border-radius: 2px;
    padding: 12px 14px;
    display: inline-flex;
    gap: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.tissa-bruno-typing span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--_muted);
    /* No animation — static staggered opacity instead */
}
.tissa-bruno-typing span:nth-child(1) { opacity: 0.3; }
.tissa-bruno-typing span:nth-child(2) { opacity: 0.55; }
.tissa-bruno-typing span:nth-child(3) { opacity: 0.8; }

/* ---- Form ---- */
.tissa-bruno-form {
    border-top: 1px solid var(--_line);
    padding: 10px;
    display: flex;
    gap: 8px;
    background: #fff;
    align-items: flex-end;
}
.tissa-bruno-input {
    flex: 1;
    border: 1px solid var(--_line);
    border-radius: 4px;                          /* inputs: 4–6px per §5 */
    padding: 9px 12px;
    font-size: 14px;
    font-family: "Source Serif 4", "Source Serif Pro", Georgia, serif;
    line-height: 1.4;
    color: var(--_carbon);
    background: var(--_cream);
    resize: none;
    max-height: 120px;
    min-height: 38px;
    outline: none;
    transition: border-color 0.15s linear, box-shadow 0.15s linear;
}
.tissa-bruno-input:focus {
    border-color: var(--_carbon);
    box-shadow: 0 0 0 2px rgba(37, 38, 40, 0.06);
    background: #fff;
}
.tissa-bruno-input::placeholder { color: var(--_muted); }

.tissa-bruno-send {
    width: 38px;
    height: 38px;
    border-radius: 4px;
    background: var(--_carbon);
    color: #fff;
    border: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s linear, opacity 0.15s linear;
}
.tissa-bruno-send:hover { background: var(--_amber); }       /* canonical amber on action */
.tissa-bruno-send:disabled { opacity: .35; cursor: not-allowed; }

/* ---- Privacy footer ---- */
.tissa-bruno-privacy {
    font-family: "Geist Mono", "JetBrains Mono", ui-monospace, "Courier New", monospace;
    font-size: 9.5px;
    letter-spacing: 0.04em;
    color: var(--_muted);
    padding: 7px 12px 9px;
    background: #fff;
    text-align: center;
    border-top: 1px solid var(--_line);
    line-height: 1.5;
    text-transform: uppercase;
}
.tissa-bruno-privacy a {
    color: var(--_carbon);
    text-decoration: underline;
    text-decoration-color: var(--_line);
    text-underline-offset: 2px;
    margin-left: 4px;
    transition: text-decoration-color 0.15s linear;
}
.tissa-bruno-privacy a:hover { text-decoration-color: var(--_carbon); }

/* ---- Mobile ---- */
@media (max-width: 640px) {
    .tissa-bruno-root { bottom: 16px; right: 16px; }
    .tissa-bruno-panel {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100vh;
        max-height: none;
        border-radius: 0;
        border: none;
        bottom: 0;
        right: 0;
    }
    .tissa-bruno-root.is-open .tissa-bruno-toggle {
        position: fixed;
        top: 12px;
        right: 12px;
        z-index: 1000000;
        width: 40px;
        height: 40px;
    }
}
