/* ── ORLA AI Chat Widget ────────────────────────────────────────────────────── */

/* Reset scope */
#orla-ai-chat-root *,
#orla-ai-chat-root *::before,
#orla-ai-chat-root *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Launcher bubble ─────────────────────────────────────────────────────────── */
#orla-ai-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    z-index: 99998;
    transition: transform .2s ease, box-shadow .2s ease;
}
#orla-ai-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
#orla-ai-launcher:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* ── Chat panel ──────────────────────────────────────────────────────────────── */
#orla-ai-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 340px;
    max-height: 540px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    z-index: 99997;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 14px;
}
#orla-ai-panel[hidden] { display: none !important; }

/* Mobile */
@media (max-width: 420px) {
    #orla-ai-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-height: 100dvh;
        border-radius: 14px 14px 0 0;
    }
    #orla-ai-launcher {
        bottom: 16px;
        right: 16px;
    }
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
#orla-ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    color: #fff;
    flex-shrink: 0;
}
#orla-ai-header-text strong {
    display: block;
    font-size: 15px;
    font-weight: 600;
}
#orla-ai-status {
    font-size: 12px;
    opacity: .85;
}

/* ── Language toggle ─────────────────────────────────────────────────────────── */
#orla-ai-lang-toggle {
    display: flex;
    gap: 4px;
}
.orla-lang-btn {
    background: rgba(255,255,255,.2);
    border: 1px solid rgba(255,255,255,.5);
    color: #fff;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: background .15s;
}
.orla-lang-btn.active,
.orla-lang-btn:hover {
    background: rgba(255,255,255,.4);
}

/* ── Message thread ──────────────────────────────────────────────────────────── */
#orla-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.orla-msg {
    max-width: 88%;
    padding: 9px 12px;
    border-radius: 12px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    font-size: 13.5px;
}
.orla-msg-assistant {
    background: #f0f0f0;
    color: #1a1a1a;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.orla-msg-assistant a {
    color: var(--orla-accent, #1B4D2E);
    text-decoration: underline;
    word-break: break-all;
}
.orla-msg-assistant a:hover {
    opacity: .8;
}
.orla-msg-user {
    background: var(--orla-accent, #1B4D2E);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* ── Typing indicator ────────────────────────────────────────────────────────── */
#orla-ai-typing {
    padding: 10px 14px 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
#orla-ai-typing[hidden] { display: none !important; }
#orla-ai-typing span {
    width: 7px;
    height: 7px;
    background: #bbb;
    border-radius: 50%;
    animation: orla-bounce .9s infinite;
}
#orla-ai-typing span:nth-child(2) { animation-delay: .15s; }
#orla-ai-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes orla-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%            { transform: translateY(-6px); }
}

/* ── Ticket form ─────────────────────────────────────────────────────────────── */
#orla-ai-ticket-form {
    padding: 12px 14px;
    background: #fafafa;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}
#orla-ai-ticket-form[hidden] { display: none !important; }
#orla-ai-ticket-label {
    font-size: 13px;
    color: #444;
    font-weight: 500;
}
#orla-ai-ticket-form input,
#orla-ai-ticket-form textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    color: #1a1a1a;
}
#orla-ai-ticket-form input:focus,
#orla-ai-ticket-form textarea:focus {
    outline: 2px solid #1B4D2E;
    border-color: transparent;
}
#orla-ai-ticket-submit {
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 9px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}
#orla-ai-ticket-submit:hover  { opacity: .88; }
#orla-ai-ticket-submit:disabled { opacity: .5; cursor: not-allowed; }

/* ── Input area ──────────────────────────────────────────────────────────────── */
#orla-ai-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}
#orla-ai-input {
    flex: 1;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13.5px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.4;
    color: #1a1a1a;
}
#orla-ai-input:focus {
    outline: 2px solid #1B4D2E;
    border-color: transparent;
}
#orla-ai-send {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s;
}
#orla-ai-send:hover    { opacity: .85; }
#orla-ai-send:disabled { opacity: .4; cursor: not-allowed; }
