/* ═══════════════════════════════════════
   FTS Chat Agent – Widget Styles
   ═══════════════════════════════════════ */

:root {
    --fts-chat-bg: #ffffff;
    --fts-chat-surface: #f7f5f2;
    --fts-chat-border: #e5e0d8;
    --fts-chat-text: #1a1a1a;
    --fts-chat-muted: #6b635a;
    --fts-chat-accent: #b8860b;
    --fts-chat-accent-light: rgba(184, 134, 11, 0.09);
    --fts-chat-accent-text: #ffffff;
    --fts-chat-user-bubble: #b8860b;
    --fts-chat-bot-bubble: #f7f5f2;
    --fts-chat-success: #2d8a4e;
    --fts-chat-whatsapp: #25d366;
    --fts-chat-error: #e53e3e;
    --fts-chat-radius: 14px;
    --fts-chat-width: 400px;
    --fts-chat-height: 660px;
}

/* ── Floating Button ── */

.fts-chat-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
}

.fts-chat-bubble-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--fts-chat-accent), #8a6e10);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 0 0 3px rgba(184,134,11,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.2s;
    position: relative;
}

.fts-chat-bubble-btn:hover {
    transform: scale(1.06);
}

.fts-chat-bubble-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--fts-chat-success);
    border: 2px solid #fff;
}

/* ── Chat Window ── */

.fts-chat-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: var(--fts-chat-width);
    height: var(--fts-chat-height);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    background: var(--fts-chat-bg);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--fts-chat-border);
    box-shadow: 0 8px 40px rgba(0,0,0,0.12);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    z-index: 99999;
    animation: fts-chat-slide-up 0.3s ease-out;
}

@keyframes fts-chat-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Header ── */

.fts-chat-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--fts-chat-surface);
    border-bottom: 1px solid var(--fts-chat-border);
    flex-shrink: 0;
}

.fts-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fts-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fts-chat-accent), #8a6e10);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.fts-chat-avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 14px;
}

.fts-chat-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--fts-chat-text);
}

.fts-chat-status {
    font-size: 11px;
    color: var(--fts-chat-success);
    display: flex;
    align-items: center;
    gap: 4px;
}

.fts-chat-status-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--fts-chat-success);
}

.fts-chat-header-actions {
    display: flex;
    gap: 4px;
}

.fts-chat-header-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: transparent;
    color: var(--fts-chat-muted);
    text-decoration: none;
}

.fts-chat-header-btn:hover {
    background: var(--fts-chat-accent-light);
}

.fts-chat-wa-btn {
    background: rgba(37, 211, 102, 0.09);
}

/* ── Messages ── */

.fts-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

.fts-chat-msg {
    display: flex;
    margin-bottom: 8px;
    max-width: 100%;
}

.fts-chat-msg-user {
    justify-content: flex-end;
    padding-left: 48px;
}

.fts-chat-msg-bot {
    justify-content: flex-start;
    padding-right: 32px;
    align-items: flex-end;
    gap: 6px;
}

.fts-chat-msg-bubble {
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 85%;
}

.fts-chat-msg-user .fts-chat-msg-bubble {
    background: var(--fts-chat-user-bubble);
    color: var(--fts-chat-accent-text);
    border-radius: 14px 14px 4px 14px;
}

.fts-chat-msg-bot .fts-chat-msg-bubble {
    background: var(--fts-chat-bot-bubble);
    color: var(--fts-chat-text);
    border-radius: 14px 14px 14px 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* ── Typing Indicator ── */

.fts-chat-typing {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin-bottom: 8px;
}

.fts-chat-typing-dots {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--fts-chat-bot-bubble);
    border-radius: 14px 14px 14px 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.fts-chat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--fts-chat-accent);
    animation: fts-dot-pulse 1.2s ease-in-out infinite;
}

.fts-chat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.fts-chat-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes fts-dot-pulse {
    0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
    40% { opacity: 1; transform: scale(1); }
}

/* ── Quick Actions ── */

.fts-chat-quick-actions {
    padding: 0 12px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.fts-chat-quick-btn {
    background: var(--fts-chat-bg);
    border: 1px solid var(--fts-chat-border);
    color: var(--fts-chat-accent);
    padding: 6px 12px;
    border-radius: 18px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
}

.fts-chat-quick-btn:hover {
    background: var(--fts-chat-accent-light);
    border-color: var(--fts-chat-accent);
}

/* ── Input Area ── */

.fts-chat-input-area {
    padding: 10px 12px;
    border-top: 1px solid var(--fts-chat-border);
    display: flex;
    gap: 8px;
    background: var(--fts-chat-surface);
    flex-shrink: 0;
}

.fts-chat-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 20px;
    border: 1px solid var(--fts-chat-border);
    background: var(--fts-chat-bg);
    color: var(--fts-chat-text);
    font-size: 14px;
    outline: none;
    font-family: inherit;
}

.fts-chat-input:focus {
    border-color: rgba(184, 134, 11, 0.4);
}

.fts-chat-input::placeholder {
    color: var(--fts-chat-muted);
}

.fts-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--fts-chat-border);
    color: #999;
    font-size: 16px;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.fts-chat-send-btn.active {
    background: linear-gradient(135deg, var(--fts-chat-accent), #8a6e10);
    color: #fff;
    cursor: pointer;
}

/* ── Footer ── */

.fts-chat-footer {
    padding: 6px 12px 10px;
    text-align: center;
    font-size: 11px;
    color: var(--fts-chat-muted);
    background: var(--fts-chat-surface);
}

.fts-chat-footer a {
    color: var(--fts-chat-whatsapp);
    font-weight: 600;
    text-decoration: none;
}

/* ── Booking Form (inline) ── */

.fts-chat-booking-form {
    margin: 8px 0 8px 34px;
    padding: 16px 14px;
    background: var(--fts-chat-surface);
    border: 1px solid var(--fts-chat-border);
    border-radius: var(--fts-chat-radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.fts-chat-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.fts-chat-form-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--fts-chat-text);
}

.fts-chat-form-close {
    background: none;
    border: none;
    color: var(--fts-chat-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
}

.fts-chat-form-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fts-chat-form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--fts-chat-muted);
    margin-bottom: 3px;
    display: block;
}

.fts-chat-form-label .prefill-badge {
    font-size: 10px;
    color: var(--fts-chat-success);
    margin-left: 6px;
    font-weight: 400;
}

.fts-chat-form-input,
.fts-chat-form-select,
.fts-chat-form-textarea {
    width: 100%;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    border: 1px solid var(--fts-chat-border);
    background: var(--fts-chat-bg);
    color: var(--fts-chat-text);
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
}

.fts-chat-form-input:focus,
.fts-chat-form-select:focus,
.fts-chat-form-textarea:focus {
    border-color: rgba(184, 134, 11, 0.4);
}

.fts-chat-form-input.error,
.fts-chat-form-select.error {
    border-color: var(--fts-chat-error);
}

.fts-chat-form-row {
    display: flex;
    gap: 8px;
}

.fts-chat-form-row > * {
    flex: 1;
}

/* Tour selection cards */
.fts-chat-tour-option {
    padding: 10px 12px;
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    border: 1.5px solid var(--fts-chat-border);
    background: var(--fts-chat-bg);
    transition: all 0.15s;
    font-family: inherit;
    width: 100%;
    margin-bottom: 5px;
}

.fts-chat-tour-option:hover {
    border-color: var(--fts-chat-accent);
}

.fts-chat-tour-option.selected {
    border-color: var(--fts-chat-accent);
    background: var(--fts-chat-accent-light);
}

.fts-chat-tour-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--fts-chat-text);
}

.fts-chat-tour-meta {
    font-size: 12px;
    color: var(--fts-chat-muted);
    margin-top: 2px;
}

/* Price preview */
.fts-chat-price-preview {
    padding: 8px 12px;
    background: var(--fts-chat-accent-light);
    border-radius: 8px;
    font-size: 13px;
    color: var(--fts-chat-accent);
    font-weight: 600;
    text-align: center;
}

.fts-chat-price-per-person {
    font-weight: 400;
    font-size: 12px;
    margin-top: 2px;
}

.fts-chat-form-divider {
    height: 1px;
    background: var(--fts-chat-border);
    margin: 2px 0;
    border: none;
}

/* Submit button */
.fts-chat-form-submit {
    padding: 12px 0;
    border-radius: 10px;
    border: none;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    font-family: inherit;
    background: linear-gradient(135deg, var(--fts-chat-accent), #8a6e10);
    color: var(--fts-chat-accent-text);
    transition: opacity 0.2s;
    width: 100%;
}

.fts-chat-form-submit:hover {
    opacity: 0.9;
}

.fts-chat-form-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.fts-chat-form-footer {
    font-size: 11px;
    color: var(--fts-chat-muted);
    text-align: center;
    line-height: 1.4;
}

/* Success state */
.fts-chat-booking-success {
    margin: 8px 0 8px 34px;
    padding: 20px;
    background: #f0faf3;
    border: 1px solid rgba(45, 138, 78, 0.2);
    border-radius: var(--fts-chat-radius);
    text-align: center;
}

.fts-chat-success-icon {
    font-size: 22px;
    margin-bottom: 6px;
}

.fts-chat-success-title {
    font-weight: 600;
    color: var(--fts-chat-success);
    font-size: 15px;
    margin-bottom: 4px;
}

.fts-chat-success-text {
    font-size: 13px;
    color: var(--fts-chat-muted);
    line-height: 1.5;
}

/* ── Responsive ── */

@media (max-width: 480px) {
    .fts-chat-window {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .fts-chat-form-row {
        flex-direction: column;
    }
}
