/**
 * Thomas AI Chat Widget Styles
 * Denver Broncos Theme: Navy (#002244), Orange (#FB4F14)
 */

:root {
    --thomas-navy: #002244;
    --thomas-navy-light: #003366;
    --thomas-orange: #FB4F14;
    --thomas-orange-hover: #E04510;
    --thomas-white: #FFFFFF;
    --thomas-gray-light: #F5F5F5;
    --thomas-gray: #E0E0E0;
    --thomas-gray-dark: #666666;
    --thomas-text: #1a1a1a;
    --thomas-shadow: 0 4px 20px rgba(0, 34, 68, 0.25);
    --thomas-radius: 16px;
}

/* ============================================
   CHAT TOGGLE BUTTON
   ============================================
   Stack below Bootstrap 5 modals (--bs-backdrop-zindex: 1050,
   --bs-modal-zindex: 1055) so #popup_cont and other modals are not obscured. */

.thomas-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px 12px 12px;
    background: linear-gradient(135deg, var(--thomas-navy) 0%, var(--thomas-navy-light) 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: var(--thomas-shadow);
    transition: all 0.3s ease;
    font-family: inherit;
}

.thomas-chat-toggle:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 34, 68, 0.35);
}

.thomas-chat-toggle:hover .chat-toggle-text {
    max-width: 200px;
    opacity: 1;
    margin-left: 8px;
}

.chat-toggle-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--thomas-orange);
    background: var(--thomas-gray-light);
    flex-shrink: 0;
}

.chat-toggle-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--thomas-orange);
    color: var(--thomas-white);
    font-weight: 700;
    font-size: 18px;
}

.chat-toggle-badge {
    position: absolute;
    top: 8px;
    right: 8px;
}

.pulse-dot {
    display: block;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--thomas-white);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

.chat-toggle-text {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    color: var(--thomas-white);
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
}

/* ============================================
   CHAT WINDOW
   ============================================ */

.thomas-chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 1035;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 550px;
    max-height: calc(100vh - 150px);
    background: var(--thomas-white);
    border-radius: var(--thomas-radius);
    box-shadow: 0 10px 50px rgba(0, 34, 68, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, var(--thomas-navy) 0%, var(--thomas-navy-light) 100%);
    color: var(--thomas-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.chat-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--thomas-orange);
    background: var(--thomas-gray-light);
}

.chat-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-header-text h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.status-online {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
}

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

.chat-action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--thomas-white);
    transition: background 0.2s;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--thomas-gray-light);
}

.chat-message {
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

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

.chat-message.assistant {
    align-self: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.user .message-bubble {
    background: var(--thomas-orange);
    color: var(--thomas-white);
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .message-bubble {
    background: var(--thomas-white);
    color: var(--thomas-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message-bubble a {
    color: inherit;
    text-decoration: underline;
}

.chat-message.assistant .message-bubble a {
    color: var(--thomas-orange);
}

.message-time {
    font-size: 11px;
    color: var(--thomas-gray-dark);
    margin-top: 4px;
    padding: 0 4px;
}

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

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
    background: var(--thomas-white);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--thomas-gray-dark);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Chat Input */
.chat-input-container {
    padding: 16px 20px;
    background: var(--thomas-white);
    border-top: 1px solid var(--thomas-gray);
    flex-shrink: 0;
}

.chat-form {
    margin: 0;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--thomas-gray-light);
    border-radius: 24px;
    padding: 8px 8px 8px 20px;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--thomas-orange);
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    color: var(--thomas-text);
}

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

.chat-input::placeholder {
    color: var(--thomas-gray-dark);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--thomas-orange);
    color: var(--thomas-white);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: var(--thomas-orange-hover);
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    background: var(--thomas-gray);
    cursor: not-allowed;
    transform: none;
}

.chat-recaptcha-hint {
    margin: 8px 0 0;
    font-size: 10px;
    line-height: 1.35;
    color: var(--thomas-gray-dark);
    opacity: 0.9;
    max-width: 100%;
    padding: 0 4px;
    text-align: center;
}

.chat-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 11px;
    color: var(--thomas-gray-dark);
}

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

.chat-footer a:hover {
    text-decoration: underline;
}

.chat-footer .separator {
    opacity: 0.5;
}

/* ============================================
   QUICK ACTIONS
   ============================================ */

.thomas-quick-actions {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 1025;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.thomas-quick-actions.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.quick-action-btn {
    background: var(--thomas-white);
    border: 1px solid var(--thomas-gray);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    color: var(--thomas-text);
}

.quick-action-btn:hover {
    background: var(--thomas-navy);
    color: var(--thomas-white);
    border-color: var(--thomas-navy);
    transform: translateX(-5px);
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 480px) {
    .thomas-chat-toggle {
        bottom: 16px;
        right: 16px;
        padding: 8px;
    }

    .chat-toggle-avatar {
        width: 44px;
        height: 44px;
    }

    .chat-toggle-text {
        display: none;
    }

    .thomas-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .thomas-quick-actions {
        right: 16px;
        bottom: 80px;
    }

    .quick-action-btn {
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */

@media (prefers-color-scheme: dark) {
    .chat-messages {
        background: #1a1a2e;
    }

    .chat-message.assistant .message-bubble {
        background: #16213e;
        color: #e6e6e6;
    }

    .chat-input-container {
        background: #0f0f23;
        border-top-color: #30363d;
    }

    .chat-input-wrapper {
        background: #1a1a2e;
    }

    .chat-input {
        color: #e6e6e6;
    }

    .quick-action-btn {
        background: #16213e;
        border-color: #30363d;
        color: #e6e6e6;
    }
}

/* Calendly booking button in chat messages */
.calendly-booking-btn {
    display: inline-block;
    padding: 8px 16px;
    margin: 6px 0;
    background: linear-gradient(135deg, #006bff, #0052cc);
    color: #fff !important;
    border-radius: 8px;
    text-decoration: none !important;
    font-weight: 600;
    font-size: 0.875rem;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 2px 6px rgba(0, 107, 255, 0.25);
}

.calendly-booking-btn:hover {
    background: linear-gradient(135deg, #0052cc, #003d99);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 107, 255, 0.35);
}

