/* ===== AI Chat Widget Styles ===== */

/* Floating Action Button */
.chat-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--gradient-1);
    border: none;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 30px rgba(99, 102, 241, 0.5);
}

.chat-fab svg {
    width: 28px;
    height: 28px;
    color: white;
    transition: var(--transition);
}

.chat-fab .chat-fab-close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.chat-fab.active .chat-fab-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.chat-fab.active .chat-fab-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.chat-fab-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--primary-light);
    animation: chatPulse 3s ease-in-out infinite;
    pointer-events: none;
}

.chat-fab.active .chat-fab-pulse {
    display: none;
}

@keyframes chatPulse {
    0%, 100% { opacity: 0; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.15); }
}

/* Chat Modal */
.chat-modal {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 400px;
    height: 560px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), 0 0 60px rgba(99, 102, 241, 0.1);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

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

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

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: white;
    font-weight: 700;
    flex-shrink: 0;
}

.chat-agent-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    display: block;
    line-height: 1.2;
}

.chat-agent-status {
    font-size: 0.75rem;
    color: var(--accent-light);
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-agent-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
    animation: livePulse 2s infinite;
}

.chat-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.chat-close-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.chat-close-btn svg {
    width: 16px;
    height: 16px;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* Message Bubbles */
.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: msgFadeIn 0.3s ease;
}

@keyframes msgFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg-user {
    align-self: flex-end;
}

.chat-msg-bot {
    align-self: flex-start;
}

.chat-msg-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.55;
    word-wrap: break-word;
}

.chat-msg-user .chat-msg-bubble {
    background: var(--gradient-1);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg-bot .chat-msg-bubble {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.chat-msg-time {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 4px;
    padding: 0 4px;
}

.chat-msg-user .chat-msg-time {
    text-align: right;
}

/* Typing Indicator */
.chat-typing .chat-msg-bubble {
    display: flex;
    gap: 4px;
    padding: 14px 20px;
}

.chat-typing .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingBounce 1.4s ease-in-out infinite;
}

.chat-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Input Area */
.chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    background: var(--bg-card);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.chat-input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.chat-input::placeholder {
    color: var(--text-dim);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--gradient-1);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chat-send-btn svg {
    width: 20px;
    height: 20px;
}

/* Booking Form Overlay */
.chat-booking-overlay {
    position: absolute;
    inset: 0;
    background: var(--bg-card);
    padding: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.chat-booking-header {
    padding: 20px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-booking-header h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px;
}

.chat-booking-header p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

.chat-booking-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.chat-booking-body .form-group {
    margin-bottom: 14px;
}

.chat-booking-body label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 5px;
    font-weight: 500;
}

.chat-booking-body input,
.chat-booking-body select,
.chat-booking-body textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition);
    box-sizing: border-box;
}

.chat-booking-body input:focus,
.chat-booking-body select:focus,
.chat-booking-body textarea:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.chat-booking-body textarea {
    resize: vertical;
    min-height: 70px;
}

.chat-booking-body select {
    appearance: none;
    cursor: pointer;
}

.chat-booking-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.chat-booking-actions {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.chat-booking-submit {
    width: 100%;
    padding: 12px;
    background: var(--gradient-1);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.chat-booking-submit:hover {
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    transform: translateY(-1px);
}

.chat-booking-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.chat-booking-back {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.chat-booking-back:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

/* Notification badge on FAB */
.chat-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-dark);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .chat-modal {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100dvh;
        border-radius: 0;
    }

    .chat-fab {
        bottom: 20px;
        right: 20px;
        width: 54px;
        height: 54px;
    }

    .chat-fab svg {
        width: 24px;
        height: 24px;
    }

    .chat-modal.open ~ .chat-fab {
        display: none;
    }
}

@media (max-width: 768px) and (min-width: 481px) {
    .chat-modal {
        width: 360px;
        height: 500px;
        right: 16px;
        bottom: 90px;
    }
}
