/* Avise AI Chat Widget Styles */
:root {
    --avise-primary: #2563eb;
    --avise-secondary: #1e40af;
}

/* Reset for widget scope */
.avise-chat-widget,
.avise-chat-widget * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
}

/* Floating toggle button */
.avise-chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--avise-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.avise-chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.avise-chat-toggle:focus-visible {
    outline: 3px solid var(--avise-primary);
    outline-offset: 3px;
}

/* Chat panel */
.avise-chat-panel {
    position: fixed;
    bottom: 88px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 99998;
    border: 1px solid #e5e7eb;
}

/* Header */
.avise-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--avise-primary);
    color: #fff;
    flex-shrink: 0;
}

.avise-chat-header-title {
    font-weight: 600;
    font-size: 15px;
}

.avise-chat-header-status {
    font-size: 12px;
    opacity: 0.8;
    display: block;
}

.avise-chat-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

.avise-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.avise-chat-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Privacy notice */
.avise-chat-privacy {
    padding: 12px 16px;
    background: #fef3c7;
    border-bottom: 1px solid #fcd34d;
    font-size: 13px;
    color: #92400e;
}

.avise-chat-privacy p {
    margin: 0 0 8px 0;
}

.avise-chat-privacy a {
    color: #92400e;
    text-decoration: underline;
}

.avise-chat-privacy-btn {
    background: #92400e;
    color: #fff;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

/* Messages area */
.avise-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Individual message */
.avise-chat-message {
    max-width: 85%;
    animation: avise-fade-in 0.2s ease;
}

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

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

.avise-chat-message-content {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    word-break: break-word;
}

.avise-chat-message-user .avise-chat-message-content {
    background: var(--avise-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.avise-chat-message-assistant .avise-chat-message-content {
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

/* Links in assistant messages */
.avise-chat-message-assistant .avise-chat-message-content a {
    color: var(--avise-primary);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.15s, text-decoration 0.15s;
}

.avise-chat-message-assistant .avise-chat-message-content a:hover {
    text-decoration: underline;
    color: var(--avise-secondary);
}

/* Chat history loading indicator */
.avise-chat-loading {
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
    padding: 20px;
}

.avise-chat-message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 4px;
}

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

/* Suggestions */
.avise-chat-suggestions {
    padding: 8px 16px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-top: 1px solid #f3f4f6;
    position: relative;
}

.avise-suggestion-chip {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    color: #374151;
    transition: background 0.15s;
    text-align: left;
}

.avise-suggestion-chip:hover {
    background: #e5e7eb;
}

.avise-suggestion-chip:focus-visible {
    outline: 2px solid var(--avise-primary);
    outline-offset: 1px;
}

.avise-suggestions-dismiss {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}

.avise-suggestions-dismiss:hover {
    color: #6b7280;
    background: #e5e7eb;
}

/* Lead capture form */
.avise-chat-lead-form {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.avise-lead-form-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #1f2937;
}

/* Nudge link */
.avise-nudge-lead-link {
    color: var(--avise-primary);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
}

.avise-nudge-lead-link:hover {
    color: var(--avise-secondary);
}

/* Email transcript form */
.avise-chat-email-transcript {
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
}

.avise-chat-header-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    border-radius: 4px;
}

.avise-chat-header-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

.avise-chat-email-transcript input,
.avise-chat-lead-form input,
.avise-chat-lead-form select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 6px;
    background: #fff;
}

.avise-chat-lead-form input:focus,
.avise-chat-lead-form select:focus {
    outline: none;
    border-color: var(--avise-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.avise-lead-dismiss {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
    margin-top: 4px;
}

.avise-lead-dismiss:hover {
    color: #374151;
}

/* Typing indicator */
.avise-chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
}

.avise-typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: avise-typing 1.2s infinite;
}

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

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

/* Input area */
.avise-chat-input-area {
    display: flex;
    align-items: flex-end;
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    gap: 8px;
    flex-shrink: 0;
}

.avise-chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    min-height: 38px;
    outline: none;
}

.avise-chat-input:focus {
    border-color: var(--avise-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.avise-chat-send-btn {
    background: var(--avise-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.avise-chat-send-btn:hover {
    background: var(--avise-secondary);
}

.avise-chat-send-btn:focus-visible {
    outline: 2px solid var(--avise-primary);
    outline-offset: 2px;
}

/* Footer */
.avise-chat-footer {
    text-align: center;
    padding: 6px;
    font-size: 11px;
    color: #9ca3af;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
}

/* Animations */
@keyframes avise-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes avise-typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* Mobile responsive */
@media (max-width: 480px) {
    .avise-chat-panel {
        width: calc(100vw - 16px);
        height: calc(100vh - 80px);
        bottom: 72px;
        right: 8px;
        border-radius: 8px;
    }

    .avise-chat-toggle {
        bottom: 12px;
        right: 12px;
    }
}

/* Focus trap — ensures keyboard users stay within chat when open */
.avise-chat-panel:focus-within {
    /* Visual indicator that panel is focused */
}

/* High contrast / accessibility */
@media (prefers-contrast: high) {
    .avise-chat-message-assistant .avise-chat-message-content {
        border: 1px solid #000;
    }

    .avise-suggestion-chip {
        border: 2px solid #000;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .avise-chat-message,
    .avise-typing-dot,
    .avise-chat-toggle {
        animation: none;
        transition: none;
    }
}
