/* Chat Widget – design aligned with data-ai-intelligent-solutions chat */
:root {
    --chat-primary: #e85c29;
    --chat-body-bg: #f8f8f8;
    --chat-user-bubble: #e85c29;
    --chat-assistant-bubble: #f3f4f6;
    --chat-text: #374151;
    --chat-meta: #9ca3af;
    --chat-processing-bg: #f0f0f0;
    --chat-online-dot: #4ade80;
    --chat-border: #e5e7eb;
}

.fab-chat {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--chat-primary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 1001;
    transition: transform 0.3s ease;
}

.fab-chat:hover {
    transform: scale(1.1);
}

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

.chat-panel {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 360px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(232, 92, 41, 0.12), 0 12px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--chat-border);
    z-index: 1002;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.chat-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Header – orange, avatar + name + status, Online, close */
.chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    background: var(--chat-primary);
    color: #fff;
}

.chat-panel-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.chat-panel-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-panel-avatar-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.chat-panel-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--chat-primary);
}

.chat-panel-avatar-sm .chat-panel-avatar-icon {
    width: 16px;
    height: 16px;
}

.chat-panel-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-panel-name {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.chat-panel-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
}

.chat-panel-online {
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.chat-panel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chat-online-dot);
}

.chat-panel-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.chat-panel-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Response time bar – above messages */
.chat-response-time {
    text-align: center;
    font-size: 12px;
    color: #b45309;
    padding: 10px 16px;
    background: #fff;
    border-bottom: 1px solid var(--chat-border);
}

/* Messages area */
.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #fff;
    color: var(--chat-text);
}

/* Quick Actions & Popular questions */
.chat-actions-heading {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin: 20px 0 10px;
}

.chat-actions-heading:first-child {
    margin-top: 0;
}

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

.chat-quick-actions .chat-action-btn {
    padding: 8px 12px;
}

.chat-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: #f3f4f6;
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.chat-action-btn:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.chat-action-icon {
    flex-shrink: 0;
    font-size: 16px;
}

.chat-popular-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-action-btn--text {
    flex: 0 1 auto;
    width: auto;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
}

/* Testimonial – above input */
.chat-testimonial {
    padding: 10px 20px;
    background: #f9fafb;
    border-top: 1px solid var(--chat-border);
}

.chat-testimonial-quote {
    font-size: 12px;
    font-style: italic;
    color: #374151;
    margin: 0 0 2px 0;
}

.chat-testimonial-attribution {
    font-size: 11px;
    color: var(--chat-meta);
    margin: 0;
}

/* User message – right-aligned, orange bubble */
.chat-msg--user {
    align-self: flex-end;
    text-align: right;
}

.chat-msg--user .chat-msg-bubble {
    background: var(--chat-user-bubble);
    color: #fff;
    margin-left: auto;
    display: inline-block;
    max-width: 100%;
}

.chat-msg--user .chat-msg-meta {
    margin-left: auto;
}

/* Assistant message – left, avatar + gray bubble */
.chat-msg--assistant .chat-msg-assistant-wrap {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.chat-msg--assistant .chat-msg-bubble {
    flex: 1;
    max-width: none;
    background: var(--chat-assistant-bubble);
    color: var(--chat-text);
    margin: 0;
}

.chat-msg--assistant .chat-msg-meta {
    margin-top: 4px;
    margin-left: 38px;
}

.chat-msg-bubble {
    display: inline-block;
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-msg-bubble p {
    margin: 0 0 8px 0;
    color: var(--chat-text);
}

.chat-msg-bubble p:last-child {
    margin-bottom: 0;
}

.chat-msg-bubble a {
    color: var(--chat-primary);
    font-weight: 600;
    text-decoration: none;
}

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

.chat-msg-meta {
    display: block;
    font-size: 11px;
    color: var(--chat-meta);
    margin-top: 4px;
}

/* Processing state – centered pill */
.chat-processing {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    color: #404040;
    background: var(--chat-processing-bg);
    border: 1px solid var(--chat-border);
    border-radius: 999px;
    padding: 8px 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    align-self: center;
}

.chat-processing-icon {
    width: 16px;
    height: 16px;
}

/* Input */
.chat-input-wrap {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--chat-border);
    background: #fff;
}

.chat-input {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid var(--chat-border);
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    background: #f9fafb;
    color: #111;
}

.chat-input:focus {
    border-color: var(--chat-primary);
}

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

.chat-send {
    padding: 14px 20px;
    background: var(--chat-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.chat-send:hover {
    filter: brightness(1.05);
}

.chat-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Mobile: popup-style panel (not full-screen), 16px input to prevent iOS zoom */
@media (max-width: 768px) {
    .chat-panel {
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(10px);
        width: calc(100vw - 32px);
        max-width: 400px;
        bottom: 90px;
        top: auto;
        height: 75vh;
        max-height: 600px;
        border-radius: 16px;
        box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
    }

    .chat-panel.is-open {
        transform: translateX(-50%) translateY(0);
    }

    .chat-input {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .chat-panel {
        width: calc(100vw - 24px);
        bottom: 85px;
        height: 70vh;
    }

    .fab-chat {
        right: 16px;
        bottom: max(20px, env(safe-area-inset-bottom));
    }
}
