/* Tamagn Bet — corporate white & navy AI chat widget */
.chatbot-wrapper {
    --tb-navy-900: #061424;
    --tb-navy-800: #0c2744;
    --tb-navy-700: #123a5c;
    --tb-blue-accent: #006aff;
    --tb-blue-soft: #e8f1ff;

    position: fixed;
    right: 1rem;
    bottom: calc(4.75rem + 1.25rem + env(safe-area-inset-bottom, 0px));
    z-index: 10050;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Inter", sans-serif;
}

@media (min-width: 768px) {
    .chatbot-wrapper {
        right: 1.875rem;
        bottom: 1.875rem;
    }
}

.chat-trigger {
    position: relative;
    z-index: 3;
    width: 60px;
    height: 60px;
    background: linear-gradient(145deg, var(--tb-blue-accent) 0%, #0050d4 100%);
    color: white;
    border-radius: 50%;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow:
        0 4px 16px rgba(0, 106, 255, 0.42),
        0 0 0 2px rgba(255, 255, 255, 0.95);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.chat-trigger svg {
    width: 1.35rem;
    height: 1.35rem;
    fill: currentColor;
}

/* ─── Launcher periodic tooltip (above FAB — positioned with right:, not launcher) ─ */
@keyframes tb-launcher-tooltip-in {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tb-launcher-tooltip-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(16px);
    }
}

.chat-launcher-tooltip {
    position: absolute;
    left: auto !important;
    right: 40px !important;
    bottom: calc(60px + 13px);
    width: 280px;
    max-width: none;
    min-width: 0;
    margin: 0 !important;
    padding: 0;
    box-sizing: border-box;
    z-index: 2;
    cursor: pointer;
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid rgba(12, 55, 100, 0.12);
    box-shadow:
        0 10px 28px rgba(6, 20, 36, 0.14),
        0 2px 8px rgba(0, 106, 255, 0.08);
    opacity: 0;
    transform: translateY(16px);
    visibility: hidden;
    pointer-events: none;
    overflow: visible;
    -webkit-tap-highlight-color: transparent;
}

/* Tail tip aligned with FAB center (wrapper ~60px; FAB axis at 100% − 40px inset +30px ⇒ 100% − 10px inside box). */
.chat-launcher-tooltip::before {
    content: "";
    position: absolute;
    left: calc(100% - 10px);
    right: auto;
    bottom: -8px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(12, 55, 100, 0.12);
    pointer-events: none;
    z-index: 0;
}

.chat-launcher-tooltip::after {
    content: "";
    position: absolute;
    left: calc(100% - 10px);
    right: auto;
    bottom: -6px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 7px solid #ffffff;
    pointer-events: none;
    z-index: 1;
}

.chat-launcher-tooltip-inner {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 18px 20px 20px;
    position: relative;
    z-index: 2;
}

.chat-launcher-tooltip-avatar {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    margin-right: 14px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 15%;
    border: 2px solid #ffffff;
    box-shadow:
        0 0 0 1px var(--tb-blue-accent),
        0 4px 10px rgba(0, 106, 255, 0.2);
    overflow: hidden;
}

.chat-launcher-tooltip-text {
    margin: 0;
    flex: 1;
    min-width: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--tb-blue-accent);
    letter-spacing: 0.01em;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Inter", sans-serif;
}

.chat-launcher-tooltip.tb-launcher-tooltip--visible {
    visibility: visible;
    pointer-events: auto;
    animation: tb-launcher-tooltip-in 0.45s ease forwards;
}

.chat-launcher-tooltip.tb-launcher-tooltip--visible.tb-launcher-tooltip--leave {
    animation: tb-launcher-tooltip-out 0.42s ease forwards;
}

@media (max-width: 768px) {
    .tooltip-box {
        right: 20px !important;
        width: 240px;
    }

    /* FAB center lands just past tooltip right edge: offset tail outward by 10px */
    .chat-launcher-tooltip::before {
        left: calc(100% + 10px);
    }

    .chat-launcher-tooltip::after {
        left: calc(100% + 10px);
    }

    .chat-launcher-tooltip-inner {
        padding: 16px 18px 18px;
    }

    .chat-launcher-tooltip-avatar {
        width: 60px;
        height: 60px;
        margin-right: 12px;
    }

    .chat-launcher-tooltip-text {
        font-size: 0.875rem;
    }
}

.chat-box {
    position: absolute;
    bottom: 80px;
    right: 0;
    z-index: 2;
    width: 320px;
    height: 440px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow:
        0 12px 40px rgba(6, 20, 36, 0.18),
        0 0 0 1px rgba(12, 55, 100, 0.08);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(12, 55, 100, 0.12);
}
.chat-box.active {
    display: flex;
}

.chat-header {
    background: linear-gradient(145deg, var(--tb-navy-700) 0%, var(--tb-navy-800) 45%, var(--tb-navy-900) 100%);
    color: #ffffff;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header-main {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    flex: 1;
}

.chat-header-avatar-wrap {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.42);
    box-shadow:
        0 0 0 1px rgba(0, 106, 255, 0.35),
        0 4px 14px rgba(0, 0, 0, 0.28);
}

.chat-header-avatar {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 15%;
}

.chat-header-title {
    margin: 0;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: 0.02em;
    color: #ffffff;
}

.chat-header button {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.chat-header button:hover {
    background: rgba(255, 255, 255, 0.18);
}

.chat-body {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--tb-blue-soft) 0%, #ffffff 52%);    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bot-msg,
.user-msg {
    padding: 10px 12px;
    border-radius: 10px;
    max-width: 85%;
    font-size: 0.84rem;
    line-height: 1.45;
    word-wrap: break-word;
}

.bot-msg {
    background: #ffffff;
    border: 1px solid rgba(0, 106, 255, 0.14);
    align-self: flex-start;
    color: #1e293b;
    box-shadow: 0 1px 4px rgba(6, 20, 36, 0.06);
}

.chat-welcome-block {    display: flex;
    flex-direction: column;
    gap: 10px;
    align-self: stretch;
    max-width: 100%;
}

.chat-welcome-block .bot-msg {
    max-width: 100%;
}

.chat-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-quick-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: #ffffff;
    border: 1.5px solid var(--tb-blue-accent);
    color: var(--tb-blue-accent);
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.chat-quick-btn:hover {
    background: linear-gradient(180deg, #f7fbff 0%, var(--tb-blue-soft) 100%);
    box-shadow:
        0 2px 10px rgba(0, 106, 255, 0.12),
        0 0 0 1px rgba(0, 106, 255, 0.08);
}
.chat-quick-btn:active {
    transform: scale(0.99);
}

.chat-quick-btn-icon {
    flex-shrink: 0;
    font-size: 1.05rem;
    line-height: 1;
}

.chat-quick-btn-label {
    flex: 1;
}

.bot-msg-intent {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tb-navy-700);
    margin-bottom: 6px;
}

.bot-msg-text {
    font-size: inherit;
    line-height: inherit;
}

.user-msg {
    background: var(--tb-blue-accent);
    color: white;
    align-self: flex-end;
}

.user-msg.voice-msg {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-notice {
    background: #fff3cd;
    color: #856404;
    font-size: 0.78rem;
    border: 1px solid #ffc107;
}

.bot-msg img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    margin-top: 6px;
}

/* ─── Voice Indicator / Waveform ──────────────────────────────────────── */
.voice-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    background: linear-gradient(90deg, var(--tb-blue-soft) 0%, #ffffff 100%);
    border-top: 1px solid rgba(12, 55, 100, 0.1);
}

.voice-indicator.active {
    display: flex;
}

.waveform {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}

.waveform span {
    display: inline-block;
    width: 3px;
    height: 6px;
    background: var(--tb-blue-accent);
    border-radius: 2px;
    animation: waveform-bar 0.6s ease-in-out infinite;
}

.waveform span:nth-child(1) { animation-delay: 0s; }
.waveform span:nth-child(2) { animation-delay: 0.1s; }
.waveform span:nth-child(3) { animation-delay: 0.2s; }
.waveform span:nth-child(4) { animation-delay: 0.3s; }
.waveform span:nth-child(5) { animation-delay: 0.4s; }

@keyframes waveform-bar {
    0%, 100% { height: 4px; }
    50% { height: 18px; }
}

.voice-indicator small {
    font-size: 0.72rem;
    color: var(--tb-navy-700);
    font-weight: 500;
}

/* ─── Chat Footer ─────────────────────────────────────────────────────── */
.chat-footer {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-top: 1px solid rgba(12, 55, 100, 0.1);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.chat-footer input {
    flex: 1;
    border: 1px solid rgba(12, 55, 100, 0.12);
    padding: 8px 10px;
    outline: none;
    min-width: 0;
    font-size: 0.84rem;
    background: #ffffff;
    border-radius: 18px;
}

.chat-footer input:focus {
    background: var(--tb-blue-soft);
    border-color: rgba(0, 106, 255, 0.35);
}

/* ─── Microphone Button ───────────────────────────────────────────────── */
.chat-footer .mic-btn {
    background: none;
    border: none;
    color: #006aff;
    cursor: pointer;
    padding: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s, transform 0.2s;
}

.chat-footer .mic-btn svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: currentColor;
}

.chat-footer .mic-btn:hover {
    background: rgba(0, 106, 255, 0.1);
}

.chat-footer .mic-btn.recording {
    color: #e53e3e;
    background: rgba(229, 62, 62, 0.12);
    animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.18); }
}

/* ─── Send Button ─────────────────────────────────────────────────────── */
.chat-footer .send-icon {
    background: var(--tb-blue-accent);
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 3px 10px rgba(0, 106, 255, 0.35);
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.chat-footer .send-icon:hover {
    background: #005ce6;
    box-shadow: 0 4px 14px rgba(0, 106, 255, 0.45);
}

.chat-footer .send-icon:active {
    transform: scale(0.96);
}

.chat-footer .send-icon svg {
    width: 1.05rem;
    height: 1.05rem;
    fill: currentColor;
}

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 400px) {
    .chat-box {
        width: calc(100vw - 2rem);
        height: 380px;
        right: -0.5rem;
    }

    .chat-header-title {
        font-size: 0.78rem;
    }
}
