/**
 * Chatbot Widget Styles for JazzEdge AI Chatbot
 * Updated with modern chat interface design and mobile fixes
 * 
 * File: chatbot-widget.css
 * Path: /wp-jeai-chatbot/assets/css/chatbot-widget.css
 * Version: 3.4.0
 */

/* Font Awesome Import (if not already loaded by theme) */
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');

/* CSS Variables for dynamic theming */
:root {
    --wp-jeai-primary-color: #2c5282;
    --wp-jeai-secondary-color: #e6d5ff;
    --wp-jeai-text-color: #ffffff;
    --wp-jeai-background-color: #ffffff;
    --wp-jeai-bot-message-bg: #e6d5ff;
    --wp-jeai-bot-message-text: #1a202c;
    --wp-jeai-user-message-bg: #2c5282;
    --wp-jeai-user-message-text: #ffffff;
    --wp-jeai-input-bg-color: #ffffff;
    --wp-jeai-chat-window-width: 380px;
}

/* Chatbot Container */
#wp-jeai-chatbot-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Position variations */
#wp-jeai-chatbot-container.bottom-right {
    bottom: 20px;
    right: 20px;
}

#wp-jeai-chatbot-container.bottom-left {
    bottom: 20px;
    left: 20px;
}

#wp-jeai-chatbot-container.bottom-center {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

/* Chat Button */
.wp-jeai-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--wp-jeai-primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    border: none;
}

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

/* Chat button icon styling - supports both Font Awesome and custom images */
.wp-jeai-chat-button i {
    font-size: 28px;
    color: var(--wp-jeai-text-color);
}

.wp-jeai-chat-button img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 50%;
}

/* Notification Badge */
.wp-jeai-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
    font-weight: bold;
    animation: wp-jeai-pulse 2s infinite;
}

@keyframes wp-jeai-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Chat Window */
.wp-jeai-chat-window {
    position: absolute;
    bottom: 80px;
    width: var(--wp-jeai-chat-window-width);
    height: 600px;
    background: var(--wp-jeai-background-color);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: wp-jeai-slideUp 0.3s ease-out;
}

/* Position adjustments for chat window */
#wp-jeai-chatbot-container.bottom-right .wp-jeai-chat-window {
    right: 0;
}

#wp-jeai-chatbot-container.bottom-left .wp-jeai-chat-window {
    left: 0;
}

#wp-jeai-chatbot-container.bottom-center .wp-jeai-chat-window {
    left: 50%;
    transform: translateX(-50%);
}

.wp-jeai-chat-window.active {
    display: flex;
}

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

/* Chat Header */
.wp-jeai-chat-header {
    background: var(--wp-jeai-primary-color);
    color: var(--wp-jeai-text-color);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.wp-jeai-chat-info {
    display: flex;
    align-items: center;
}

.wp-jeai-chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.wp-jeai-chat-avatar i {
    font-size: 20px;
    color: var(--wp-jeai-text-color);
}

.wp-jeai-chat-avatar img {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 50%;
}

.wp-jeai-chat-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 2px;
}

.wp-jeai-chat-status {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    align-items: center;
}

.wp-jeai-status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    margin-right: 6px;
    animation: wp-jeai-blink 2s infinite;
}

@keyframes wp-jeai-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Chat Controls */
.wp-jeai-chat-controls {
    display: flex;
    gap: 10px;
}

.wp-jeai-control-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    color: var(--wp-jeai-text-color);
    font-size: 16px;
}

.wp-jeai-control-btn:hover {
    opacity: 0.7;
}

/* Chat Body */
.wp-jeai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--wp-jeai-background-color);
    scroll-behavior: smooth;
}

.wp-jeai-chat-body::-webkit-scrollbar {
    width: 6px;
}

.wp-jeai-chat-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.wp-jeai-chat-body::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.wp-jeai-chat-body::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Messages */
.wp-jeai-message {
    margin-bottom: 16px;
    display: flex;
    align-items: flex-end;
    animation: wp-jeai-fadeIn 0.3s ease-out;
}

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

.wp-jeai-message.user {
    justify-content: flex-end;
}

.wp-jeai-message.bot {
    justify-content: flex-start;
}

/* Bot Avatar for messages */
.wp-jeai-message.bot .wp-jeai-bot-avatar {
    width: 32px;
    height: 32px;
    background: var(--wp-jeai-bot-message-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    flex-shrink: 0;
}

.wp-jeai-message.bot .wp-jeai-bot-avatar i {
    font-size: 16px;
    color: var(--wp-jeai-primary-color);
}

.wp-jeai-message.bot .wp-jeai-bot-avatar img {
    width: 20px;
    height: 20px;
    object-fit: cover;
    border-radius: 50%;
}

.wp-jeai-message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.wp-jeai-message.user .wp-jeai-message-content {
    background: var(--wp-jeai-user-message-bg);
    color: var(--wp-jeai-user-message-text);
    border-bottom-right-radius: 4px;
}

.wp-jeai-message.bot .wp-jeai-message-content {
    background: var(--wp-jeai-bot-message-bg);
    color: var(--wp-jeai-bot-message-text);
    border-bottom-left-radius: 4px;
}

.wp-jeai-message-time {
    font-size: 11px;
    color: #a0aec0;
    margin-top: 4px;
    padding: 0 16px;
}

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

.wp-jeai-message.bot .wp-jeai-message-time {
    text-align: left;
    margin-left: 40px;
}

/* Typing Indicator */
.wp-jeai-typing-indicator {
    display: none;
    align-items: center;
    margin-left: 40px;
}

.wp-jeai-typing-indicator.active {
    display: flex;
}

.wp-jeai-typing-bubble {
    background: var(--wp-jeai-bot-message-bg);
    padding: 12px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    display: inline-flex;
    align-items: center;
}

.wp-jeai-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--wp-jeai-primary-color);
    border-radius: 50%;
    margin: 0 2px;
    animation: wp-jeai-typing 1.4s infinite;
}

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

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

@keyframes wp-jeai-typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Chat Footer */
.wp-jeai-chat-footer {
    padding: 16px;
    background: var(--wp-jeai-background-color);
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.wp-jeai-input-group {
    display: flex;
    align-items: center;
    background: var(--wp-jeai-input-bg-color);
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    transition: border-color 0.2s;
}

.wp-jeai-input-group:focus-within {
    border-color: var(--wp-jeai-primary-color);
}

.wp-jeai-input-icon {
    color: #a0aec0;
    margin-right: 8px;
    font-size: 18px;
}

.wp-jeai-message-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    background: transparent;
    padding: 8px 0;
    color: var(--wp-jeai-bot-message-text);
}

.wp-jeai-message-input::placeholder {
    color: #a0aec0;
}

.wp-jeai-send-button {
    width: 36px;
    height: 36px;
    background: var(--wp-jeai-primary-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    color: var(--wp-jeai-text-color);
}

.wp-jeai-send-button:hover {
    background: var(--wp-jeai-primary-color);
    filter: brightness(0.9);
    transform: scale(1.05);
}

.wp-jeai-send-button:disabled {
    background: #e2e8f0;
    cursor: not-allowed;
    transform: scale(1);
}

.wp-jeai-send-button i {
    font-size: 16px;
}

/* Welcome Screen */
.wp-jeai-welcome-screen {
    text-align: center;
    padding: 40px 20px;
}

.wp-jeai-welcome-icon {
    width: 80px;
    height: 80px;
    background: var(--wp-jeai-bot-message-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.wp-jeai-welcome-icon i {
    font-size: 40px;
    color: var(--wp-jeai-primary-color);
}

.wp-jeai-welcome-icon img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 50%;
}

.wp-jeai-welcome-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--wp-jeai-bot-message-text);
    margin-bottom: 10px;
}

.wp-jeai-welcome-message {
    font-size: 14px;
    color: var(--wp-jeai-bot-message-text);
    opacity: 0.8;
    line-height: 1.5;
    margin-bottom: 20px;
}

/* Quick Actions - FIXED HOVER STYLES */
.wp-jeai-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
}

.wp-jeai-quick-action {
    padding: 12px 16px;
    background: var(--wp-jeai-background-color);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    text-align: left;
    font-size: 14px;
    color: var(--wp-jeai-bot-message-text);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wp-jeai-quick-action:hover {
    background: var(--wp-jeai-bot-message-bg);
    border-color: var(--wp-jeai-primary-color);
    transform: translateX(4px);
    /* Keep text color consistent on hover */
    color: var(--wp-jeai-bot-message-text);
}

.wp-jeai-quick-action i {
    color: var(--wp-jeai-primary-color);
    font-size: 16px;
}

/* ===================================
   MOBILE RESPONSIVE - IMPROVED PARTIAL OVERLAY
   =================================== */

/* Mobile Backdrop */
.wp-jeai-chat-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    display: none;
}

.wp-jeai-chat-backdrop.active {
    opacity: 1;
    pointer-events: auto;
    display: block;
}

/* Mobile Styles (up to 767px) */
@media (max-width: 767px) {
    /* Chat window as partial overlay */
    .wp-jeai-chat-window {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        
        /* Partial height with maximum cap */
        height: 85vh !important;
        height: 85dvh !important; /* Dynamic viewport height */
        max-height: 600px !important;
        min-height: 400px !important;
        
        /* Remove rounded corners on bottom, keep on top */
        border-radius: 20px 20px 0 0 !important;
        
        /* Smooth slide-up animation */
        transform: translateY(100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        
        /* High z-index */
        z-index: 999999 !important;
        
        /* Add subtle shadow for depth */
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15) !important;
    }
    
    /* When active, slide up */
    .wp-jeai-chat-window.active {
        transform: translateY(0) !important;
    }
    
    /* Ensure proper positioning regardless of parent container position */
    #wp-jeai-chatbot-container.bottom-right .wp-jeai-chat-window,
    #wp-jeai-chatbot-container.bottom-left .wp-jeai-chat-window,
    #wp-jeai-chatbot-container.bottom-center .wp-jeai-chat-window {
        left: 0 !important;
        right: 0 !important;
    }
    
    /* Chat header optimizations */
    .wp-jeai-chat-header {
        position: sticky;
        top: 0;
        z-index: 100;
        padding: 12px 16px;
        padding-top: max(12px, env(safe-area-inset-top));
        
        /* Add visual drag handle */
        position: relative;
    }
    
    .wp-jeai-chat-header::before {
        content: '';
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
    }
    
    /* Ensure controls are visible and tappable */
    .wp-jeai-chat-controls {
        display: flex;
        gap: 8px;
        margin-right: 0;
    }
    
    .wp-jeai-control-btn {
        width: 40px !important;
        height: 40px !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 50%;
    }
    
    .wp-jeai-control-btn i {
        font-size: 18px !important;
    }
    
    /* Optimize chat body for mobile */
    .wp-jeai-chat-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 16px;
        /* Calculate height considering header and footer */
        height: calc(100% - 120px);
        /* Ensure content doesn't get hidden under footer */
        padding-bottom: 20px;
    }
    
    /* Chat footer optimizations */
    .wp-jeai-chat-footer {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        background: var(--wp-jeai-background-color);
        z-index: 10;
        
        /* Add subtle top shadow for depth */
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }
    
    /* Smaller chat button on mobile */
    .wp-jeai-chat-button {
        width: 56px;
        height: 56px;
        bottom: 20px;
        right: 20px;
        /* Ensure it's above safe areas */
        bottom: max(20px, calc(env(safe-area-inset-bottom) + 10px));
    }
    
    .wp-jeai-chat-button i {
        font-size: 24px;
    }
    
    /* Message adjustments for mobile */
    .wp-jeai-message-content {
        max-width: 85%;
        font-size: 15px; /* Slightly larger for readability */
    }
    
    /* Welcome screen adjustments */
    .wp-jeai-welcome-screen {
        padding: 20px 16px;
    }
    
    .wp-jeai-welcome-icon {
        width: 60px;
        height: 60px;
        margin-bottom: 16px;
    }
    
    .wp-jeai-welcome-title {
        font-size: 18px;
    }
    
    .wp-jeai-welcome-message {
        font-size: 14px;
    }
    
    /* Quick actions on mobile */
    .wp-jeai-quick-action {
        padding: 14px 16px;
        font-size: 15px;
    }
    
    /* Input adjustments for mobile */
    .wp-jeai-input-group {
        padding: 4px 4px 4px 12px;
    }
    
    .wp-jeai-message-input {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 10px 8px;
        max-height: 80px; /* Limit expansion on mobile */
    }
    
    /* Notification badge position */
    .wp-jeai-notification-badge {
        top: -3px;
        right: -3px;
        width: 18px;
        height: 18px;
        font-size: 11px;
    }
}

/* Small Mobile Devices (320px - 480px) */
@media (max-width: 480px) {
    .wp-jeai-chat-window {
        /* Even more constrained height for small devices */
        height: 80vh !important;
        height: 80dvh !important;
        max-height: 500px !important;
        min-height: 380px !important;
    }
    
    /* Reduce padding on small screens */
    .wp-jeai-chat-header {
        padding: 10px 12px;
        padding-top: max(10px, env(safe-area-inset-top));
    }
    
    .wp-jeai-chat-body {
        padding: 10px 12px;
    }
    
    .wp-jeai-chat-footer {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    
    /* Smaller text for space efficiency */
    .wp-jeai-message-content {
        font-size: 14px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 767px) and (orientation: landscape) {
    .wp-jeai-chat-window {
        /* More aggressive height constraint in landscape */
        height: 90vh !important;
        height: 90dvh !important;
        max-height: 400px !important;
        min-height: 300px !important;
        
        /* Optionally make it wider but shorter */
        max-width: 600px !important;
        left: 50% !important;
        transform: translateX(-50%) translateY(100%) !important;
    }
    
    /* When active in landscape */
    .wp-jeai-chat-window.active {
        transform: translateX(-50%) translateY(0) !important;
    }
    
    /* More compact header in landscape */
    .wp-jeai-chat-header {
        padding: 8px 12px;
        padding-top: max(8px, env(safe-area-inset-top));
    }
    
    .wp-jeai-chat-body {
        padding: 8px 12px;
    }
    
    .wp-jeai-chat-footer {
        padding: 8px 12px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
    
    /* Hide less critical elements */
    .wp-jeai-welcome-icon {
        display: none;
    }
    
    /* Smaller text in landscape */
    .wp-jeai-welcome-title {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .wp-jeai-welcome-message {
        font-size: 13px;
        margin-bottom: 12px;
    }
    
    /* Reduce message spacing */
    .wp-jeai-message {
        margin-bottom: 8px;
    }
}

/* Tablet and small desktop adjustments */
@media (min-width: 768px) and (max-width: 1024px) {
    .wp-jeai-chat-window {
        width: 100%;
        max-width: 400px;
        height: calc(100vh - 40px);
        max-height: 600px;
        bottom: 20px;
    }
    
    /* Center position adjustment for tablets */
    #wp-jeai-chatbot-container.bottom-center .wp-jeai-chat-window {
        left: 50%;
        transform: translateX(-50%);
    }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles */
    .wp-jeai-chat-window {
        /* Prevent rubber band scrolling on the window itself */
        position: fixed;
        overflow: hidden;
    }
    
    .wp-jeai-chat-body {
        /* Enable momentum scrolling */
        -webkit-overflow-scrolling: touch;
        overflow-y: scroll;
    }
    
    /* Prevent input zoom on iOS */
    .wp-jeai-message-input,
    .wp-jeai-message-input:focus {
        font-size: 16px !important;
    }
}

/* Handle notch/safe areas on modern devices */
@supports (padding: max(0px)) {
    .wp-jeai-chat-window {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Full-screen mobile mode (optional class for backwards compatibility) */
.wp-jeai-mobile-fullscreen .wp-jeai-chat-window {
    height: 100vh !important;
    height: 100dvh !important;
    max-height: none !important;
    border-radius: 0 !important;
}

/* Non-fullscreen mobile mode (for specific override) */
@media (max-width: 768px) {
    #wp-jeai-chatbot-container:not(.wp-jeai-mobile-fullscreen) .wp-jeai-chat-window {
        /* Uses the default partial overlay styles */
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    /* Dark mode overrides if background is set to dark */
    #wp-jeai-chatbot-container[data-dark-mode="true"] {
        --wp-jeai-background-color: #1a202c;
        --wp-jeai-bot-message-bg: #4a5568;
        --wp-jeai-bot-message-text: #f7fafc;
        --wp-jeai-input-bg-color: #2d3748;
    }
    
    #wp-jeai-chatbot-container[data-dark-mode="true"] .wp-jeai-chat-footer {
        border-top-color: #4a5568;
    }
    
    #wp-jeai-chatbot-container[data-dark-mode="true"] .wp-jeai-input-group {
        border-color: #4a5568;
    }
    
    #wp-jeai-chatbot-container[data-dark-mode="true"] .wp-jeai-quick-action {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    #wp-jeai-chatbot-container[data-dark-mode="true"] .wp-jeai-quick-action:hover {
        background: #4a5568;
        color: #e2e8f0;
    }
}

/* Loading State */
.wp-jeai-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #e2e8f0;
    border-radius: 50%;
    border-top-color: var(--wp-jeai-primary-color);
    animation: wp-jeai-spin 1s ease-in-out infinite;
}

@keyframes wp-jeai-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Message Links */
.wp-jeai-message-link {
    color: inherit;
    text-decoration: underline;
    font-weight: 500;
    transition: opacity 0.2s;
}

.wp-jeai-message-link:hover {
    opacity: 0.8;
}

.wp-jeai-message.user .wp-jeai-message-link {
    color: var(--wp-jeai-user-message-text);
}

.wp-jeai-message.bot .wp-jeai-message-link {
    color: var(--wp-jeai-primary-color);
}

/* Error State */
.wp-jeai-error-message {
    background: #fed7d7;
    color: #9b2c2c;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    margin: 10px 0;
    text-align: center;
}

/* Inline Chatbot Mode */
.wp-jeai-chatbot-inline {
    position: relative;
    width: 100%;
    background: var(--wp-jeai-background-color);
    border-radius: 16px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.wp-jeai-chatbot-inline .wp-jeai-chat-window {
    position: relative;
    width: 100%;
    height: 100%;
    bottom: auto;
    animation: none;
    display: flex;
}

.wp-jeai-chatbot-inline .wp-jeai-chat-button {
    display: none;
}

/* Settings Page Color Preview Support */
.color-field {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-input {
    width: 120px;
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    vertical-align: middle;
}

.color-picker {
    width: 50px;
    height: 34px;
    padding: 2px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    vertical-align: middle;
    margin-left: 10px;
}

.color-input:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 1px #007cba;
    outline: none;
}

/* Utility class for hiding elements */
.wp-jeai-hidden {
    display: none !important;
}

/* Accessibility improvements */
@media (prefers-contrast: high) {
    .wp-jeai-chat-window {
        border: 2px solid currentColor;
    }
    
    .wp-jeai-chat-header {
        border-bottom: 2px solid currentColor;
    }
    
    .wp-jeai-chat-footer {
        border-top: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .wp-jeai-chat-window,
    .wp-jeai-chat-backdrop,
    .wp-jeai-message,
    .wp-jeai-quick-action {
        transition: none !important;
        animation: none !important;
    }
}

/* Performance optimizations */
.wp-jeai-chat-window {
    will-change: transform;
}

.wp-jeai-chat-body {
    will-change: scroll-position;
}

/* Fallback for browsers without dvh support */
@supports not (height: 100dvh) {
    @media (max-width: 767px) {
        .wp-jeai-chat-window {
            height: 85vh !important;
        }
    }
}

/* Fallback for browsers without env() support */
@supports not (padding: env(safe-area-inset-top)) {
    .wp-jeai-chat-header {
        padding-top: 12px !important;
    }
    
    .wp-jeai-chat-footer {
        padding-bottom: 12px !important;
    }
}