/* ===================================
   Buddy - Premium Chat Interface
   =================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #5c7fb8;
    --primary-light: #e3ecf7;
    --primary-lighter: #f0f5fa;
    --primary-dark: #4a6da8;
    --bg-main: #ffffff;
    --bg-chat: #f8fafc;
    --bg-user: linear-gradient(135deg, #5c7fb8 0%, #7b9fd4 100%);
    --bg-ai: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-muted: #86868b;
    --border-light: rgba(92, 127, 184, 0.1);
    --border-medium: rgba(92, 127, 184, 0.15);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.chat-page {
    font-family: var(--font);
    background: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

/* ============ CONTAINER ============ */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 520px;
    margin: 0 auto;
    background: var(--bg-main);
    border-left: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
}

/* ============ HEADER ============ */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-main);
    border-bottom: 1px solid var(--border-light);
    min-height: 60px;
}

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

.brand-logo {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.brand-logo svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.brand-logo::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: #34c759;
    border: 2px solid white;
    border-radius: 50%;
}

.brand-info .brand-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.brand-info .brand-status {
    font-size: 12px;
    color: #34c759;
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* Bigger header icons */
.header-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border-medium);
    background: var(--bg-main);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-btn svg {
    width: 20px;
    height: 20px;
    fill: var(--primary);
}

.header-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.header-btn:hover svg {
    fill: white;
}

/* ============ MESSAGES AREA ============ */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    background: var(--bg-chat);
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 0;
}

#messages-container {
    display: flex;
    flex-direction: column;
}

/* ============ MESSAGES ============ */
.message {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
    animation: msgSlide 0.35s ease;
}

@keyframes msgSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.message.user {
    align-items: flex-end;
}

.message.user .message-bubble {
    background: var(--bg-user);
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 6px var(--radius-lg);
    max-width: 75%;
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
}

.message.user .message-bubble::before {
    content: attr(data-time);
    position: absolute;
    bottom: -18px;
    right: 8px;
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message.user:hover .message-bubble::before {
    opacity: 1;
}

.message.assistant {
    align-items: flex-start;
}

.message.assistant .message-bubble {
    background: var(--bg-ai);
    color: var(--text-primary);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 6px;
    max-width: 98%;
    padding: 14px 18px;
    font-size: 17px; /* Increased for better readability */
    line-height: 1.6;
    border: 1px solid var(--border-light);
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

.message-bubble .message-text {
    display: inline;
}

/* Feedback */
.message-feedback {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.feedback-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.feedback-btn svg {
    fill: var(--text-muted);
}

.feedback-btn:hover {
    background: var(--primary-light);
}

.feedback-btn:hover svg {
    fill: var(--primary);
}

.feedback-thanks {
    font-size: 11px;
    color: #34c759;
    display: flex;
    align-items: center;
    gap: 4px;
}

.feedback-thanks svg {
    fill: #34c759;
}

/* ============ PAIR DIVIDER ============ */
.pair-divider {
    height: 1px;
    background: var(--border-light);
    margin: 14px 0;
}

/* ============ TYPING LOADER ============ */
.typing-indicator {
    display: none;
    align-items: flex-start;
    margin-bottom: 8px;
    animation: msgSlide 0.25s ease;
}

.typing-bubble {
    background: var(--bg-ai);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 6px;
    padding: 14px 20px;
    display: flex;
    gap: 6px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

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

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

@keyframes dotPulse {

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

    30% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============ WELCOME SECTION ============ */
.welcome-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 160px);
    padding: 50px 24px;
    text-align: center;
}

/* H3 with font-weight 300 - BIGGER */
.welcome-title {
    font-size: 32px;
    font-weight: 300;
    color: var(--text-primary);
    margin-bottom: 40px;
    letter-spacing: -0.02em;
}

/* Buttons with SVG icons - BIGGER LAYOUT */
.welcome-suggestions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 460px;
}

.welcome-row {
    display: flex;
    justify-content: center;
    gap: 14px;
    width: 100%;
}

.welcome-suggestion {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 22px;
    border-radius: 28px;
    font-family: var(--font);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    border: 1px solid transparent;
}

/* Services - Blue */
.welcome-suggestion.btn-services {
    background: #e8f4fc;
    color: #2563eb;
    border-color: #bfdbfe;
}

.welcome-suggestion.btn-services svg {
    fill: #2563eb;
}

.welcome-suggestion.btn-services:hover {
    background: #dbeafe;
    border-color: #93c5fd;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.15);
}

/* About Us - Purple */
.welcome-suggestion.btn-about {
    background: #f3e8ff;
    color: #7c3aed;
    border-color: #ddd6fe;
}

.welcome-suggestion.btn-about svg {
    fill: #7c3aed;
}

.welcome-suggestion.btn-about:hover {
    background: #ede9fe;
    border-color: #c4b5fd;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.15);
}

/* Get Started - Green */
.welcome-suggestion.btn-start {
    background: #ecfdf5;
    color: #059669;
    border-color: #a7f3d0;
}

.welcome-suggestion.btn-start svg {
    fill: #059669;
}

.welcome-suggestion.btn-start:hover {
    background: #d1fae5;
    border-color: #6ee7b7;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.15);
}

/* Contact - Orange */
.welcome-suggestion.btn-contact {
    background: #fff7ed;
    color: #ea580c;
    border-color: #fed7aa;
}

.welcome-suggestion.btn-contact svg {
    fill: #ea580c;
}

.welcome-suggestion.btn-contact:hover {
    background: #ffedd5;
    border-color: #fdba74;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(234, 88, 12, 0.15);
}

/* Book Call - Rose/Pink */
.welcome-suggestion.btn-book {
    background: #fff1f2;
    color: #e11d48;
    border-color: #fecdd3;
}

.welcome-suggestion.btn-book svg {
    fill: #e11d48;
}

.welcome-suggestion.btn-book:hover {
    background: #ffe4e6;
    border-color: #fda4af;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(225, 29, 72, 0.15);
}

.welcome-suggestion svg {
    width: 16px;
    height: 16px;
    fill: var(--primary);
    flex-shrink: 0;
}

.welcome-suggestion:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* ============ SUGGESTIONS ============ */
.suggestions-container {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0;
}

.suggestion-chip {
    padding: 8px 14px;
    background: var(--primary-lighter);
    border: 1px solid var(--primary-light);
    border-radius: 20px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-chip:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

/* ============ INPUT (Compact) ============ */
.chat-input-area {
    padding: 8px 12px 10px;
    background: var(--bg-main);
    border-top: 1px solid var(--border-light);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 6px 6px 14px;
    background: var(--bg-chat);
    border: 1px solid var(--border-medium);
    border-radius: 22px;
    transition: all 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text-primary);
    resize: none;
    min-height: 20px;
    max-height: 60px;
    line-height: 1.4;
    padding: 0;
}

.chat-input:focus {
    outline: none;
}

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

.send-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.send-btn svg {
    width: 14px;
    height: 14px;
    fill: white;
}

.send-btn:hover:not(:disabled) {
    background: var(--primary-dark);
}

.send-btn:disabled {
    background: #d1d5db;
}

/* ============ FOOTER ============ */
.chat-footer {
    padding: 5px 12px 8px;
    text-align: center;
    font-size: 10px;
    color: var(--text-muted);
}

.chat-footer a {
    color: var(--text-muted);
    text-decoration: none;
}

.chat-footer a:hover {
    color: var(--primary);
}

/* ============ BOOKING MODAL ============ */
.booking-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.booking-modal.visible {
    display: flex;
}

.booking-modal-content {
    width: 95%;
    max-width: 500px;
    height: 85vh;
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.booking-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--primary);
    color: white;
}

.booking-modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.booking-close-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.booking-modal-body {
    height: calc(100% - 60px);
}

.booking-modal-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ============ TABLES (PREMIUM & MODERN) ============ */
.message.assistant:has(table) .message-bubble {
    max-width: 95% !important;
}

.message-content table {
    display: table !important;
    min-width: 750px !important;
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    margin: 18px 0 !important;
    font-size: 13px !important; /* Increased from 11px */
    background: white !important;
    border: 1px solid var(--border-medium) !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    table-layout: auto !important;
    box-shadow: var(--shadow-sm);
}

.message-content th {
    display: table-cell !important;
    background: #f8fafc !important;
    color: #000 !important;
    font-weight: 700 !important;
    text-align: left !important;
    padding: 10px 12px !important;
    border-bottom: 0.5px solid rgba(0,0,0,0.2) !important;
    border-right: 0.5px solid rgba(0,0,0,0.2) !important;
    text-transform: uppercase !important;
    font-size: 10px !important;
    letter-spacing: 0.03em !important;
    white-space: nowrap !important; /* Prevent header wrapping */
}

.message-content td {
    display: table-cell !important;
    padding: 10px 12px !important;
    border-bottom: 0.5px solid rgba(0,0,0,0.1) !important;
    border-right: 0.5px solid rgba(0,0,0,0.1) !important;
    color: #000 !important;
    line-height: 1.4 !important;
    vertical-align: middle !important;
}

/* Remove right border on last column */
.message-content th:last-child,
.message-content td:last-child {
    border-right: none !important;
}

/* Remove bottom border on last row */
.message-content tr:last-child td {
    border-bottom: none !important;
}

.message-content tr:hover td {
    background: #fdfdfd !important;
}

.message-content p {
    margin-bottom: 12px;
}

.message-content a {
    color: #0000ee !important; /* Classic link blue */
    text-decoration: underline !important;
    font-style: italic !important;
    font-weight: 500;
    font-size: inherit;
    background: transparent !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

.message-content a:hover {
    color: #0000aa !important;
    text-decoration: underline !important;
}

/* Ensure source column is single line */
.message-content td:last-child {
    white-space: nowrap !important;
}

/* Row highlight on hover */
.message-content tr:hover {
    background-color: rgba(37, 99, 235, 0.05) !important;
}

/* Premium Loader Animations */
#dynamic-loader-svg, #dynamic-loader-text {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes spin-fast {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin-fast {
    animation: spin-fast 0.5s linear infinite;
}

/* Make tables scroll on mobile */
@media (max-width: 640px) {
    .message-content {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .message-content table {
        min-width: 580px !important;
    }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 520px) {
    .chat-container {
        max-width: 100%;
        border: none;
    }

    .welcome-suggestion {
        padding: 10px 14px;
        font-size: 13px;
    }
}