/* Sophie Chat Widget - South Beach Resort
 * Uses site CSS variables from variables.css
 * Prefix: sophie- to avoid conflicts
 */

/* ===========================================
   Modal Container
   =========================================== */
.sophie-chat-modal {
    display: none;
    position: fixed;
    bottom: 80px;  /* Above sticky footer */
    right: 20px;
    width: 350px;
    height: 450px;
    background: var(--color-white, #ffffff);
    border-radius: var(--radius-xl, 12px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    flex-direction: column;
    z-index: 1100;  /* Above sticky footer (1000) */
    overflow: hidden;
    font-family: var(--font-primary, 'Open Sans', sans-serif);
}

.sophie-chat-modal.active {
    display: flex;
    animation: sophie-slideUp 0.3s ease;
}

@keyframes sophie-slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===========================================
   Header
   =========================================== */
.sophie-chat-header {
    background: var(--color-primary, #03233d);
    color: var(--color-white, #ffffff);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.sophie-chat-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-white, #ffffff);
}

.sophie-close-btn {
    background: none;
    border: none;
    color: var(--color-white, #ffffff);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.sophie-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ===========================================
   Chat History
   =========================================== */
.sophie-chat-history {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: var(--color-light, #f5f5f5);
    -webkit-overflow-scrolling: touch;
}

/* ===========================================
   Messages
   =========================================== */
.sophie-chat-message {
    margin: 8px 0;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 0.9375rem;
}

.sophie-user-message {
    background: var(--color-primary, #03233d);
    color: var(--color-white, #ffffff);
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.sophie-assistant-message {
    background: var(--color-white, #ffffff);
    color: var(--color-gray-dark, #333333);
    margin-right: auto;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* ===========================================
   Typing Indicator
   =========================================== */
.sophie-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--color-white, #ffffff);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin: 8px 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.sophie-dot {
    width: 8px;
    height: 8px;
    background: var(--color-gray, #666666);
    border-radius: 50%;
    animation: sophie-bounce 1.4s infinite ease-in-out;
}

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

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

@keyframes sophie-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ===========================================
   Input Area
   =========================================== */
.sophie-chat-input {
    display: flex;
    padding: 12px 15px;
    border-top: 1px solid var(--color-gray-lighter, #dddddd);
    background: var(--color-white, #ffffff);
    gap: 10px;
    flex-shrink: 0;
}

.sophie-chat-input input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--color-gray-lighter, #dddddd);
    border-radius: 24px;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--color-gray-dark, #333333);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sophie-chat-input input::placeholder {
    color: var(--color-gray-light, #aaaaaa);
}

.sophie-chat-input input:focus {
    outline: none;
    border-color: var(--color-accent, #C9A227);
    box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.15);
}

.sophie-chat-input input:disabled {
    background: var(--color-light, #f5f5f5);
    cursor: not-allowed;
}

.sophie-chat-input button {
    background: var(--color-accent, #C9A227);
    color: var(--color-white, #ffffff);
    border: none;
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    white-space: nowrap;
}

.sophie-chat-input button:hover {
    background: var(--color-accent-hover, #A8871F);
}

.sophie-chat-input button:active {
    transform: scale(0.98);
}

/* ===========================================
   Button Indicator (Unread Messages)
   =========================================== */
#chat_with_us.has-unread {
    position: relative;
}

#chat_with_us.has-unread::after {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 10px;
    height: 10px;
    background: var(--color-error, #dc3545);
    border-radius: 50%;
    border: 2px solid var(--color-white, #ffffff);
    animation: sophie-pulse-dot 2s ease-in-out 3;
}

@keyframes sophie-pulse-dot {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.4);
        opacity: 0.8;
    }
}

/* ===========================================
   Mobile Full-Width Mode (matches sticky footer pattern)
   Breakpoint: 1000px (same as site's mobile breakpoint)
   =========================================== */
@media (max-width: 999px) {
    .sophie-chat-modal {
        /* Full-width panel from bottom */
        position: fixed;
        bottom: 60px;  /* Height of collapsed sticky footer */
        left: 0;
        right: 0;
        width: 100%;
        height: 70vh;
        max-height: none;
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }

    .sophie-chat-modal.active {
        animation: sophie-slideUpMobile 0.3s ease;
    }

    .sophie-chat-message {
        max-width: 90%;
        font-size: 0.9375rem;
    }

    .sophie-chat-input input {
        font-size: 16px; /* Prevent iOS zoom */
    }
}

@keyframes sophie-slideUpMobile {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Small mobile adjustments */
@media (max-width: 480px) {
    .sophie-chat-modal {
        height: 65vh;
    }

    .sophie-chat-header {
        padding: 12px 15px;
    }

    .sophie-chat-history {
        padding: 10px;
    }

    .sophie-chat-input {
        padding: 10px;
        gap: 8px;
    }

    .sophie-chat-input button {
        padding: 10px 16px;
    }
}

/* Links in chat messages */
.sophie-chat-modal .sophie-chat-history .sophie-assistant-message a {
    color: #c9a227 !important;
    text-decoration: underline;
    word-break: break-all;
}

.sophie-chat-modal .sophie-chat-history .sophie-assistant-message a:hover {
    color: #4a90d9 !important;
    text-decoration: none;
}
