﻿/* --------- Base bubble --------- */
#arch-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #000;
    color: #fff;
    border-radius: 999px;
    padding: 8px 14px 8px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    font-size: 13px;
}

    #arch-chat-bubble img {
        width: 26px;
        height: 26px;
        border-radius: 6px;
        object-fit: cover;
    }

/* Intro bubble: force left alignment and normal wrapping */
.arch-chat-bubble-intro {
    white-space: normal !important;
    text-align: left;
}

    .arch-chat-bubble-intro p {
        margin: 0 0 6px;
    }

        .arch-chat-bubble-intro p:last-child {
            margin-bottom: 0;
        }

/* --------- Window with blurred-glass effect --------- */
#arch-chat-window {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 360px;
    max-height: 520px;
    background: rgba(10,10,10,0.9);
    color: #fff;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    box-shadow: 0 18px 40px rgba(0,0,0,0.55);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255,255,255,0.04);
}

.arch-hidden {
    display: none !important;
}

/* --------- Header --------- */
.arch-chat-header {
    background: rgba(0,0,0,0.9);
    border-bottom: 1px solid #222;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.arch-chat-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

    .arch-chat-brand img {
        height: 26px;
        margin-left: 6px;
    }

.arch-chat-title {
    display: flex;
    flex-direction: column;
}

.arch-chat-name {
    font-size: 13px;
    font-weight: 600;
}

.arch-chat-subtitle {
    font-size: 11px;
    color: #bbbbbb;
}

#arch-chat-close {
    background: transparent;
    border: none;
    color: #888;
    font-size: 18px;
    cursor: pointer;
}

    #arch-chat-close:hover {
        color: #f15b44;
    }

/* --------- Body --------- */
.arch-chat-body {
    padding: 12px;
    overflow-y: auto;
    background: rgba(22,22,22,0.9);
}

.arch-chat-message {
    margin-bottom: 10px;
    max-width: 90%;
}

.arch-chat-message-bot {
    align-self: flex-start;
    margin-left: 4px;
}

.arch-chat-message-user {
    align-self: flex-end;
    text-align: right;
}

.arch-chat-bot-name {
    font-size: 11px;
    margin-bottom: 2px;
    color: #cccccc;
}

/* Force bot messages to be left aligned */
.arch-chat-message-bot .arch-chat-bubble {
    text-align: left !important;
}

.arch-chat-bubble {
    padding: 10px 14px;
    border-radius: 10px;
    background: #202020;
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.arch-chat-message-user .arch-chat-bubble {
    background: #f15b44;
    color: #fff;
}

/* Typing animation */
.arch-chat-typing {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0;
    margin-top: 4px;
    margin-left: 6px;
}

    .arch-chat-typing span {
        width: 5px;
        height: 5px;
        border-radius: 50%;
        background: #aaa;
        display: inline-block;
        animation: arch-typing 1s infinite ease-in-out;
    }

        .arch-chat-typing span:nth-child(2) {
            animation-delay: 0.15s;
        }

        .arch-chat-typing span:nth-child(3) {
            animation-delay: 0.3s;
        }

@keyframes arch-typing {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    40% {
        transform: translateY(-3px);
        opacity: 1;
    }
}

/* ---------- iOS / Safari tweaks ---------- */
@supports (-webkit-touch-callout: none) {
    .arch-chat-body {
        -webkit-overflow-scrolling: touch;
    }

    #arch-chat-input {
        font-size: 16px;
    }
    /* prevent zoom */
}

/* --------- Footer --------- */
.arch-chat-footer {
    border-top: 1px solid #222;
    padding: 8px;
    display: flex;
    gap: 6px;
    align-items: flex-end;
    background: rgba(17,17,17,0.95);
}

#arch-chat-input {
    flex: 1;
    resize: none;
    border-radius: 8px;
    border: 1px solid #333;
    padding: 6px 8px;
    font-size: 13px;
    background: #1a1a1a;
    color: #fff;
}

    #arch-chat-input::placeholder {
        color: #777;
    }

    #arch-chat-input:focus {
        min-height: 52px;
        outline: 2px solid #2a65ff;
    }

#arch-chat-input {
    transition: min-height 0.18s ease;
}

#arch-chat-send {
    background: #f15b44;
    border: none;
    color: #fff;
    font-size: 13px;
    padding: 7px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
}

    #arch-chat-send:hover {
        filter: brightness(1.05);
    }

.arch-chat-secondary-btn {
    border-radius: 999px;
    border: 1px solid #444;
    background: transparent;
    color: #ddd;
    font-size: 11px;
    padding: 5px 10px;
    cursor: pointer;
}

    .arch-chat-secondary-btn:hover {
        background: rgba(255,255,255,0.05);
    }

.arch-chat-status {
    padding: 2px 12px 8px;
    font-size: 10px;
    color: #888;
    text-align: right;
    background: rgba(17,17,17,0.95);
}

/* --------- Overlay --------- */
.arch-chat-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.76);
    display: flex;
    align-items: center;
    justify-content: center;
}

.arch-chat-overlay-inner {
    width: 95%;
    max-width: 320px;
    background: #151515;
    border-radius: 12px;
    border: 1px solid #333;
    box-shadow: 0 12px 30px rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
}

.arch-chat-overlay-header {
    padding: 10px 12px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.arch-chat-overlay-title {
    font-size: 13px;
    font-weight: 600;
}

.arch-chat-overlay-header button {
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 18px;
    cursor: pointer;
}

.arch-chat-overlay-body {
    padding: 10px 12px 4px;
    max-height: 260px;
    overflow-y: auto;
    font-size: 12px;
}

.arch-step-title {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
}

.arch-chat-overlay-body label {
    display: block;
    margin-bottom: 8px;
}

.arch-chat-overlay-body input,
.arch-chat-overlay-body textarea {
    width: 100%;
    margin-top: 3px;
    border-radius: 6px;
    border: 1px solid #444;
    background: #1a1a1a;
    color: #fff;
    padding: 5px 7px;
    font-size: 12px;
}

.arch-chat-overlay-footer {
    padding: 8px 12px 10px;
    border-top: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.arch-chat-primary-btn {
    background: #f15b44;
    border-radius: 999px;
    padding: 6px 14px;
    border: none;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
}

/* --------- Mobile Enhancements --------- */
@media (max-width: 600px) {

    #arch-chat-window {
        right: 0;
        left: 0;
        bottom: 0;
        top: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
        box-shadow: none;
        border: none;
    }

    .arch-chat-body {
        max-height: calc(100vh - 210px);
    }

    .arch-chat-footer {
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        gap: 8px;
    }

    #arch-chat-bubble {
        right: 12px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    /* DO NOT set font-size here (so 16px from iOS rule stays active) */
    #arch-chat-input {
        min-height: 40px;
    }

        #arch-chat-input:focus {
            min-height: 60px;
        }

    #arch-chat-send {
        padding: 9px 18px;
        font-size: 14px;
    }

    .arch-chat-secondary-btn {
        font-size: 12px;
        padding: 7px 12px;
    }

    .arch-chat-bubble {
        font-size: 14px;
        line-height: 1.6;
    }

    .arch-chat-overlay-inner {
        max-width: 360px;
        width: 94%;
    }
}
