/* ---------- Chat widget ---------- */
.chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 100;
}

.chat-widget__launcher {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: var(--navy-dark);
    font-size: 1.6rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    display: grid;
    place-items: center;
    transition: transform 0.2s ease;
}

.chat-widget__launcher:hover {
    transform: scale(1.05);
}

.chat-widget__launcher-icon--close {
    display: none;
}

.chat-widget__launcher--open .chat-widget__launcher-icon--open {
    display: none;
}

.chat-widget__launcher--open .chat-widget__launcher-icon--close {
    display: block;
}

.chat-widget__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #e14b4b;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: grid;
    place-items: center;
}

.chat-widget__badge--hidden {
    display: none;
}

.chat-widget__panel {
    position: absolute;
    right: 0;
    bottom: 78px;
    width: 340px;
    max-width: calc(100vw - 48px);
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.chat-widget__panel--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chat-widget__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, var(--navy), var(--navy-light));
    color: #fff;
}

.chat-widget__header strong {
    display: block;
    font-family: var(--font-heading);
    font-size: 0.95rem;
}

.chat-widget__header span {
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.7);
}

.chat-widget__avatar {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: grid;
    place-items: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    overflow: hidden;
}

.chat-widget__avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chat-widget__close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 0.95rem;
}

.chat-widget__messages {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 360px;
    overflow-y: auto;
    background: var(--bg);
}

.chat-widget__bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.45;
}

.chat-widget__bubble--bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    color: var(--text);
}

.chat-widget__bubble--user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--navy), var(--navy-light));
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Markdown formatting inside chat bubbles */
.chat-widget__bubble strong {
    font-weight: 700;
}

.chat-widget__bubble em {
    font-style: italic;
}

.chat-widget__bubble code {
    background: rgba(0, 0, 0, 0.08);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
}

.chat-widget__bubble--user code {
    background: rgba(255, 255, 255, 0.2);
}

.chat-widget__bubble ul {
    margin: 6px 0 0;
    padding-left: 18px;
    list-style: disc;
}

.chat-widget__bubble ul li {
    margin-bottom: 2px;
}

.chat-widget__bubble--typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 14px;
}

.chat-widget__bubble--typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: chat-typing 1s infinite ease-in-out;
}

.chat-widget__bubble--typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.chat-widget__bubble--typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes chat-typing {

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

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

.chat-widget__input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: #fff;
}

.chat-widget__input-row input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 10px 16px;
    font-family: var(--font-body);
    font-size: 0.88rem;
    outline: none;
}

.chat-widget__input-row input:focus {
    border-color: var(--gold);
}

.chat-widget__send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--navy);
    color: var(--gold-light);
    cursor: pointer;
    flex-shrink: 0;
    display: grid;
    place-items: center;
}

.chat-widget__note {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    margin: 0;
    padding: 8px 12px 12px;
    background: #fff;
}

/* ---------- Appointment confirmation card ---------- */
.chat-widget__bubble--appointment {
    max-width: 90%;
    padding: 0;
    overflow: hidden;
}

.chat-widget__appointment-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-widget__appointment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(201, 161, 92, 0.15), rgba(185, 141, 94, 0.1));
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.chat-widget__appointment-icon {
    font-size: 1.1rem;
}

.chat-widget__appointment-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 14px;
}

.chat-widget__appointment-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
}

.chat-widget__appointment-label {
    color: var(--text-muted);
    font-weight: 500;
    min-width: 64px;
}

.chat-widget__appointment-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

.chat-widget__appointment-status--pendente {
    background: rgba(201, 161, 92, 0.2);
    color: #8a6d3b;
}

.chat-widget__appointment-status--confirmado {
    background: rgba(76, 175, 80, 0.15);
    color: #2e7d32;
}

.chat-widget__appointment-status--cancelado {
    background: rgba(244, 67, 54, 0.15);
    color: #c62828;
}

.chat-widget__appointment-note {
    margin: 0;
    padding: 8px 14px 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    border-top: 1px solid var(--border);
}

/* Dark mode adjustments for the appointment card */
[data-theme="dark"] .chat-widget__appointment-header {
    background: linear-gradient(135deg, rgba(201, 161, 92, 0.2), rgba(185, 141, 94, 0.12));
}

[data-theme="dark"] .chat-widget__appointment-status--pendente {
    background: rgba(201, 161, 92, 0.25);
    color: #d4af7a;
}

/* ---------- Chat widget responsive ---------- */
@media (max-width: 720px) {
    .chat-widget {
        right: 16px;
        bottom: 16px;
    }

    .chat-widget__panel {
        right: -8px;
    }
}