/* ═══════════════════════════════════════════════════════
   BERTINI & SALAS — AI Chat Widget
   Premium dark glass aesthetic
   ═══════════════════════════════════════════════════════ */

/* Container — must not affect parent flex layouts or block touches */
#ai-chat-widget {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    overflow: visible;
    z-index: 9995;
}



/* ─── Trigger Button ───────────────────────────────────── */
.ai-chat-trigger {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(26, 26, 26, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.ai-chat-trigger:hover {
    transform: scale(1.08);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.ai-chat-trigger svg {
    width: 24px;
    height: 24px;
    color: #f0ece4;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ai-chat-trigger .ai-chat-trigger__close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.ai-chat-trigger.is-open .ai-chat-trigger__open {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.ai-chat-trigger.is-open .ai-chat-trigger__close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Subtle pulse ring */
.ai-chat-trigger::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 1px solid rgba(200, 168, 110, 0.3);
    animation: aiPulse 3s ease-in-out infinite;
}

.ai-chat-trigger.is-open::before {
    animation: none;
    opacity: 0;
}

@keyframes aiPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.4;
    }

    50% {
        transform: scale(1.15);
        opacity: 0;
    }
}

/* ─── Chat Panel ───────────────────────────────────────── */
.ai-chat-panel {
    position: fixed;
    bottom: 6.5rem;
    right: 2rem;
    z-index: 9997;
    width: 400px;
    max-width: calc(100vw - 2rem);
    height: 560px;
    max-height: calc(100vh - 10rem);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.ai-chat-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Backdrop blur when chat is open */
.ai-chat-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9994;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.ai-chat-backdrop.is-visible {
    opacity: 1;
    pointer-events: all;
}

/* ─── Header ───────────────────────────────────────────── */
.ai-chat__header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.ai-chat__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(200, 168, 110, 0.2), rgba(200, 168, 110, 0.05));
    border: 1px solid rgba(200, 168, 110, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-chat__avatar svg {
    width: 18px;
    height: 18px;
    color: #c8a86e;
}

.ai-chat__header-info {
    flex: 1;
    min-width: 0;
}

.ai-chat__header-name {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: #f0ece4;
    line-height: 1.2;
}

.ai-chat__header-status {
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    font-weight: 300;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8a8378;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ai-chat__new-chat {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    color: #8a8378;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.ai-chat__new-chat:hover {
    color: #f0ece4;
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
}

.ai-chat__new-chat svg {
    width: 14px;
    height: 14px;
}

.ai-chat__reset {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    color: #8a8378;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.ai-chat__reset:hover {
    color: #f0ece4;
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
}

.ai-chat__reset svg {
    width: 14px;
    height: 14px;
}

.ai-chat__input-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.ai-chat__status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #5cb85c;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ─── Messages Area ────────────────────────────────────── */
.ai-chat__messages {
    flex: 0 1 auto;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.ai-chat__messages::-webkit-scrollbar {
    width: 4px;
}

.ai-chat__messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat__messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

/* Message bubbles */
.ai-chat__msg {
    max-width: 85%;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 300;
    line-height: 1.55;
    color: #f0ece4;
    animation: msgIn 0.3s ease forwards;
    opacity: 0;
    transform: translateY(8px);
}

@keyframes msgIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chat__msg--ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom-left-radius: 4px;
}

.ai-chat__msg--user {
    align-self: flex-end;
    background: rgba(200, 168, 110, 0.1);
    border: 1px solid rgba(200, 168, 110, 0.12);
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.ai-chat__typing {
    align-self: flex-start;
    display: none;
    align-items: center;
    gap: 0.35rem;
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.ai-chat__typing.is-visible {
    display: flex;
}

.ai-chat__typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8a8378;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.ai-chat__typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-chat__typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* ─── Suggestion Chips ─────────────────────────────────── */
.ai-chat__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0 1.5rem 0.75rem;
    flex-shrink: 0;
}

.ai-chat__chip {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.03em;
    padding: 0.5rem 0.9rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: #ccc5ba;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.ai-chat__chip:hover {
    border-color: rgba(200, 168, 110, 0.3);
    background: rgba(200, 168, 110, 0.06);
    color: #f0ece4;
}

.ai-chat__chip-badge {
    font-size: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #c8a86e;
    vertical-align: super;
    margin-left: 0.15rem;
}

/* ─── Input Area ───────────────────────────────────────── */
.ai-chat__input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-shrink: 0;
}

.ai-chat__input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 0.6rem 0;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 300;
    line-height: 1.5;
    color: #f0ece4;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    scrollbar-width: none;
}

.ai-chat__input::-webkit-scrollbar {
    display: none;
}

.ai-chat__input::placeholder {
    color: #6b6660;
    font-weight: 300;
}

.ai-chat__send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(200, 168, 110, 0.2);
    background: rgba(200, 168, 110, 0.08);
    color: #c8a86e;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.ai-chat__send:hover {
    background: rgba(200, 168, 110, 0.15);
    border-color: rgba(200, 168, 110, 0.35);
}

.ai-chat__send:active {
    transform: scale(0.92);
}

.ai-chat__send:disabled {
    opacity: 0.3;
    cursor: default;
    transform: none;
}

.ai-chat__send svg {
    width: 16px;
    height: 16px;
}

/* ─── Pre-chat Form ────────────────────────────────────── */
.ai-chat__prechat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 2rem 1.5rem;
    gap: 1rem;
    flex: 1;
}

.ai-chat__welcome-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(200, 168, 110, 0.15), rgba(200, 168, 110, 0.03));
    border: 1px solid rgba(200, 168, 110, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat__welcome-icon svg {
    width: 22px;
    height: 22px;
    color: #c8a86e;
}

.ai-chat__welcome-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.3rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: #f0ece4;
}

.ai-chat__welcome-text {
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 300;
    line-height: 1.6;
    color: #8a8378;
    max-width: 280px;
}

.ai-chat__prechat-form {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    width: 100%;
    max-width: 280px;
    margin-top: 0.25rem;
}

.ai-chat__prechat-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 300;
    color: #f0ece4;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease;
}

.ai-chat__prechat-input::placeholder {
    color: #6b6660;
}

.ai-chat__prechat-input:focus {
    border-color: rgba(200, 168, 110, 0.3);
}

.ai-chat__phone-row {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.ai-chat__prechat-select {
    width: 5.5rem;
    flex-shrink: 0;
    padding: 0.75rem 0.5rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 300;
    color: #f0ece4;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.ai-chat__prechat-select:focus {
    border-color: rgba(200, 168, 110, 0.3);
}

.ai-chat__prechat-select option {
    background: #1a1a1a;
    color: #f0ece4;
}

.ai-chat__prechat-phone {
    flex: 1;
    min-width: 0;
}

.ai-chat__prechat-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #f0ece4;
    background: rgba(200, 168, 110, 0.1);
    border: 1px solid rgba(200, 168, 110, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    margin-top: 0.25rem;
}

.ai-chat__prechat-btn:hover {
    background: rgba(200, 168, 110, 0.18);
    border-color: rgba(200, 168, 110, 0.35);
}

/* ─── Inline Confirm Bar ───────────────────────────────── */
.ai-chat__confirm {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: rgba(200, 168, 110, 0.06);
    border-bottom: 1px solid rgba(200, 168, 110, 0.1);
    flex-shrink: 0;
    animation: msgIn 0.2s ease forwards;
}

.ai-chat__confirm-text {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 300;
    color: #ccc5ba;
}

.ai-chat__confirm-btns {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.ai-chat__confirm-yes,
.ai-chat__confirm-no {
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.ai-chat__confirm-yes {
    color: #f0ece4;
    background: rgba(200, 168, 110, 0.15);
    border: 1px solid rgba(200, 168, 110, 0.25);
}

.ai-chat__confirm-yes:hover {
    background: rgba(200, 168, 110, 0.25);
}

.ai-chat__confirm-no {
    color: #8a8378;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-chat__confirm-no:hover {
    border-color: rgba(255, 255, 255, 0.12);
    color: #f0ece4;
}

/* ─── Completion Card ──────────────────────────────────── */
.ai-chat__completion {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(200, 168, 110, 0.1);
    background: rgba(200, 168, 110, 0.03);
    flex-shrink: 0;
    animation: msgIn 0.3s ease forwards;
}

.ai-chat__completion-text {
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 300;
    color: #ccc5ba;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.ai-chat__completion-btns {
    display: flex;
    gap: 0.5rem;
}

.ai-chat__completion-submit {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #f0ece4;
    background: rgba(200, 168, 110, 0.15);
    border: 1px solid rgba(200, 168, 110, 0.25);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.ai-chat__completion-submit:hover {
    background: rgba(200, 168, 110, 0.25);
    border-color: rgba(200, 168, 110, 0.4);
}

.ai-chat__completion-submit:disabled {
    opacity: 0.5;
    cursor: default;
}

.ai-chat__completion-continue {
    padding: 0.7rem 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #8a8378;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.ai-chat__completion-continue:hover {
    color: #f0ece4;
    border-color: rgba(255, 255, 255, 0.12);
}

.ai-chat__completion-done {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 300;
    color: #5cb85c;
    line-height: 1.5;
}

.ai-chat__completion.is-done {
    background: rgba(92, 184, 92, 0.04);
    border-top-color: rgba(92, 184, 92, 0.1);
}

.ai-chat__completion-portal {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.65rem 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #c8a86e;
    background: rgba(200, 168, 110, 0.08);
    border: 1px solid rgba(200, 168, 110, 0.18);
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.ai-chat__completion-portal:hover {
    background: rgba(200, 168, 110, 0.15);
    border-color: rgba(200, 168, 110, 0.3);
}

/* ─── Error State ──────────────────────────────────────── */
.ai-chat__error {
    display: none;
    padding: 0.6rem 1rem;
    margin: 0 1.5rem;
    border-radius: 8px;
    background: rgba(163, 107, 94, 0.1);
    border: 1px solid rgba(163, 107, 94, 0.15);
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 300;
    color: #c49080;
    text-align: center;
    flex-shrink: 0;
}

.ai-chat__error.is-visible {
    display: block;
}

/* ─── Mobile Responsive ────────────────────────────────── */
@media (max-width: 480px) {
    .ai-chat-trigger {
        bottom: 1.25rem;
        right: 1.25rem;
        width: 50px;
        height: 50px;
    }

    .ai-chat-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .ai-chat-panel.is-open {
        border-radius: 0;
    }

    .ai-chat__header {
        padding: 1rem 1.25rem;
    }

    .ai-chat__messages {
        padding: 1rem 1.25rem;
    }

    .ai-chat__suggestions {
        padding: 0 1.25rem 0.5rem;
    }

    .ai-chat__input-area {
        padding: 0.875rem 1.25rem;
        padding-bottom: max(0.875rem, env(safe-area-inset-bottom));
    }
}

/* ─── Markdown in AI messages ──────────────────────────── */
.ai-chat__msg--ai strong {
    font-weight: 500;
    color: #f0ece4;
}

.ai-chat__msg--ai em {
    font-style: italic;
    color: #c8a86e;
}

.ai-chat__msg--ai ul,
.ai-chat__msg--ai ol {
    margin: 0.5rem 0;
    padding-left: 1.2rem;
}

.ai-chat__msg--ai li {
    margin-bottom: 0.25rem;
}

.ai-chat__msg--ai p {
    margin: 0;
}

.ai-chat__msg--ai p+p {
    margin-top: 0.5rem;
}

.ai-chat__msg--ai code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8em;
    padding: 0.15em 0.4em;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
}