/**
 * EVI Chat Widget Styles
 * Matches the existing glass morphism design language
 */

/* Chat Button */
.evi-chat-button {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    z-index: 1000 !important;
    
    display: flex !important;
    align-items: center;
    gap: 12px;
    
    background: rgba(255, 255, 255, 0.025) !important;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 1rem !important;
    
    padding: 16px 20px !important;
    cursor: pointer;
    
    color: #ffffff !important;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    user-select: none;
    -webkit-user-select: none;
}

.evi-chat-button:hover {
    background: rgba(255, 255, 255, 0.045) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5) !important;
    transform: translateY(-2px);
}

.evi-chat-button:active {
    transform: translateY(-1px);
}

.evi-chat-button.active {
    background: rgba(255, 255, 255, 0.045) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}

.chat-button-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: rgba(255, 255, 255, 0.85) !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.evi-chat-button:hover .chat-button-icon {
    color: #ffffff !important;
}

.chat-button-text {
    white-space: nowrap;
    letter-spacing: 0.01em;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Chat Modal */
.evi-chat-modal {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    z-index: 1001 !important;
    
    width: 400px;
    height: 600px;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 48px);
    
    background: rgba(255, 255, 255, 0.025) !important;
    backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 1rem !important;
    
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5) !important;
    
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: none !important;
    
    overflow: hidden;
}

.evi-chat-modal.open {
    /* Styles handled by JavaScript to prevent conflicts */
}

.evi-chat-modal.loading {
    pointer-events: none;
}

.chat-modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
    background: rgba(255, 255, 255, 0.025) !important;
}

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

.chat-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.045) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.85) !important;
}

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

.chat-title {
    font-size: 1rem !important;
    font-weight: 600;
    color: #ffffff !important;
    letter-spacing: -0.01em;
}

.chat-status {
    font-size: 0.75rem !important;
    color: rgba(255, 255, 255, 0.65) !important;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-close-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 0.5rem !important;
    color: rgba(255, 255, 255, 0.65) !important;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-close-button:hover {
    background: rgba(255, 255, 255, 0.045) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #ffffff !important;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: auto;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.06) !important;
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.12) !important;
}

/* Message Styles */
.chat-message {
    display: flex;
    gap: 12px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.chat-message.message-appear {
    opacity: 1;
    transform: translateY(0);
}

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

.chat-message-user .message-content {
    background: rgba(255, 255, 255, 0.045) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 0.75rem 0.75rem 0.375rem 0.75rem !important;
    padding: 12px 16px;
    max-width: 280px;
}

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

.chat-message-ai .message-content {
    background: rgba(255, 255, 255, 0.015) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 0.75rem 0.75rem 0.75rem 0.375rem !important;
    padding: 12px 16px;
    max-width: 320px;
}

.message-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.025) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.65) !important;
    flex-shrink: 0;
    margin-top: 4px;
}

.message-text {
    font-size: 0.875rem !important;
    line-height: 1.5;
    color: #ffffff !important;
    word-wrap: break-word;
}

.message-text strong {
    font-weight: 600;
    color: #ffffff !important;
}

.message-text em {
    font-style: italic;
    color: rgba(255, 255, 255, 0.85) !important;
}

.message-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.message-time {
    font-size: 0.75rem !important;
    color: rgba(255, 255, 255, 0.45) !important;
}

.message-confidence {
    font-size: 0.75rem !important;
    padding: 2px 6px;
    border-radius: 0.375rem !important;
    font-weight: 500;
}

.confidence-high {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.confidence-medium {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.confidence-low {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.message-sources {
    font-size: 0.75rem !important;
    color: rgba(255, 255, 255, 0.45) !important;
}

/* Typing Indicator */
.typing-indicator .message-content {
    padding: 16px;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.65) !important;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

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

@keyframes typing-bounce {
    0%, 80%, 100% {
        opacity: 0.5;
    }
    40% {
        opacity: 1;
    }
}

/* Contact Suggestion */
.chat-contact-suggestion {
    background: rgba(255, 255, 255, 0.025) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 0.75rem !important;
    padding: 16px;
    margin: 8px 0;
}

.contact-suggestion-content {
    text-align: center;
}

.contact-suggestion-text {
    font-size: 0.875rem !important;
    color: rgba(255, 255, 255, 0.85) !important;
    margin-bottom: 12px;
}

.contact-suggestion-button {
    background: rgba(255, 255, 255, 0.045) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 0.5rem !important;
    padding: 8px 16px;
    font-size: 0.875rem !important;
    font-weight: 500;
    color: #ffffff !important;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.contact-suggestion-button:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    transform: translateY(-1px);
}

/* Chat Input */
.chat-input-container {
    border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
    background: rgba(255, 255, 255, 0.025) !important;
    padding: 16px 24px;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: rgba(255, 255, 255, 0.015) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 0.75rem !important;
    padding: 12px 16px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-input-wrapper:focus-within {
    border-color: rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff !important;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem !important;
    line-height: 1.5;
    resize: none;
    min-height: 20px;
    max-height: 120px;
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.45) !important;
}

.chat-send-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.045) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 0.5rem !important;
    color: rgba(255, 255, 255, 0.85) !important;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.chat-send-button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

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

.chat-input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.75rem !important;
    color: rgba(255, 255, 255, 0.45) !important;
}

.character-count {
    font-family: 'JetBrains Mono', monospace;
}

.chat-powered-by {
    display: flex;
    align-items: center;
    gap: 4px;
}

.contact-link {
    color: rgba(255, 255, 255, 0.85) !important;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.contact-link:hover {
    color: #ffffff !important;
    text-decoration: underline;
}

/* Contact Modal */
.chat-contact-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1002;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.contact-modal-content {
    background: rgba(255, 255, 255, 0.025) !important;
    backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 1rem !important;
    padding: 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5) !important;
}

.contact-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.contact-modal-header h3 {
    font-size: 1.25rem !important;
    font-weight: 600;
    color: #ffffff !important;
    margin: 0;
}

.contact-modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: rgba(255, 255, 255, 0.65) !important;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.contact-modal-close:hover {
    color: #ffffff !important;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.875rem !important;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85) !important;
}

.form-group input,
.form-group textarea {
    background: rgba(255, 255, 255, 0.015) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 0.5rem !important;
    padding: 12px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem !important;
    color: #ffffff !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.45) !important;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 8px;
}

.btn-secondary,
.btn-primary {
    padding: 12px 24px;
    border-radius: 0.5rem !important;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem !important;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid;
}

.btn-secondary {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.06) !important;
    color: rgba(255, 255, 255, 0.85) !important;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.025) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #ffffff !important;
}

.btn-primary {
    background: rgba(255, 255, 255, 0.045) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #ffffff !important;
}

.btn-primary:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    transform: translateY(-1px);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .evi-chat-button {
        bottom: 16px;
        right: 16px;
        padding: 12px 16px;
    }
    
    .chat-button-text {
        display: none;
    }
    
    .evi-chat-modal {
        bottom: 16px;
        right: 16px;
        left: 16px;
        width: auto;
        height: calc(100vh - 120px);
        max-height: 600px;
    }
    
    .chat-header {
        padding: 16px 20px;
    }
    
    .chat-messages {
        padding: 16px 20px;
    }
    
    .chat-input-container {
        padding: 12px 20px;
    }
    
    .contact-modal-content {
        padding: 24px;
        margin: 16px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn-secondary,
    .btn-primary {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .evi-chat-modal {
        bottom: 0;
        right: 0;
        left: 0;
        top: 80px;
        width: 100%;
        height: auto;
        max-height: none;
        border-radius: 1rem 1rem 0 0 !important;
    }
    
    .chat-message-user .message-content,
    .chat-message-ai .message-content {
        max-width: calc(100vw - 120px);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .evi-chat-button,
    .evi-chat-modal,
    .chat-message,
    .chat-send-button,
    .typing-dots span {
        transition: none;
        animation: none;
    }
    
    .evi-chat-button:hover {
        transform: none;
    }
    
    .chat-send-button:hover:not(:disabled) {
        transform: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .evi-chat-button,
    .evi-chat-modal,
    .chat-input-wrapper {
        border-width: 2px;
    }
    
    .message-text {
        color: #ffffff !important;
    }
    
    .chat-send-button:disabled {
        opacity: 0.7;
    }
}

/* Focus Styles */
.evi-chat-button:focus-visible,
.chat-close-button:focus-visible,
.chat-send-button:focus-visible,
.contact-suggestion-button:focus-visible,
.btn-secondary:focus-visible,
.btn-primary:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.15) !important;
    outline-offset: 2px;
}

.chat-input:focus-visible {
    outline: none; /* Handled by wrapper focus-within */
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}