/**
 * Ethan AI Learning Assistant - Enhanced Styles with Height Optimization
 *
 * @package    local_p20250811_2246_moodleethan
 * @copyright  2025 BlockU AI
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

/* ==========================================================================
   Fullscreen Chat Interface
   ========================================================================== */

/* ==========================================================================
   Help Menu Options - Clickable Menu Items
   ========================================================================== */

.help-menu-option {
    padding: 8px 16px !important;
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%) !important;
    border: 1px solid #4f46e5 !important;
    border-radius: 20px !important;
    cursor: pointer !important;
    font-size: 0.9rem !important;
    color: #4f46e5 !important;
    font-weight: 500 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.1) !important;
    text-decoration: none !important;
    display: inline-block !important;
    margin: 4px !important;
    position: relative !important;
    overflow: hidden !important;
    transform: translateZ(0) !important;
    backface-visibility: hidden !important;
    text-align: center !important;
    min-width: 140px !important;
    max-width: 220px !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
}

.help-menu-option::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: -100% !important;
    width: 100% !important;
    height: 100% !important;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent) !important;
    transition: left 0.5s !important;
}

.help-menu-option:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%) !important;
    color: white !important;
    border-color: #7c3aed !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3) !important;
}

.help-menu-option:hover::before {
    left: 100% !important;
}

.help-menu-option:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2) !important;
}

/* Help menu container for better organization */
.help-menu-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
    padding: 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(102, 126, 234, 0.02)) !important;
    border-radius: 16px !important;
    border: 2px solid rgba(102, 126, 234, 0.1) !important;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.08) !important;
    position: relative !important;
    overflow: hidden !important;
}

/* ==========================================================================
   Clickable Links - NO New Tab
   ========================================================================== */

.clickable-link {
    color: #4f46e5 !important;
    text-decoration: underline !important;
    cursor: pointer !important;
    font-weight: 600 !important;
    transition: all 0.3s ease !important;
    padding: 2px 4px !important;
    border-radius: 4px !important;
    background: rgba(79, 70, 229, 0.05) !important;
}

.clickable-link:hover {
    background: rgba(79, 70, 229, 0.1) !important;
    color: #6366f1 !important;
    transform: translateY(-1px) !important;
}

.clickable-link:active {
    transform: translateY(0) !important;
}

.help-menu-container::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 2px !important;
    background: linear-gradient(90deg, #4f46e5, #7c3aed, #4f46e5) !important;
    animation: shimmer 2s ease-in-out infinite !important;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Responsive help menu for mobile */
@media (max-width: 768px) {
    .help-menu-option {
        min-width: 100px !important;
        padding: 8px 10px !important;
        font-size: 13px !important;
    }
    
    .help-menu-container {
        padding: 10px;
        gap: 6px;
    }
}

.ethan-fullscreen-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f5f7fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Fullscreen Header */
.ethan-fullscreen-header {
    background: #ffffff;
    color: #000000;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    border: 2px solid #4f46e5;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.ethan-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
}

.ethan-avatar-fallback {
    width: 45px;
    height: 45px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
}

.header-info h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
}

.status-indicator {
    font-size: 0.9rem;
    opacity: 0.8;
}

.status-indicator.online::before {
    content: "●";
    color: #10b981;
    margin-right: 5px;
}

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

.action-btn {
    background: rgba(79, 70, 229, 0.1);
    border: 1px solid #4f46e5;
    color: #4f46e5;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: rgba(79, 70, 229, 0.2);
    transform: translateY(-1px);
}

.action-btn.close-btn:hover {
    background: #ef4444;
}

/* Main Content */
.ethan-fullscreen-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.ethan-sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
}

.ethan-sidebar.collapsed {
    width: 0;
    opacity: 0;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafbfc;
}

.sidebar-header h3 {
    margin: 0;
    color: #374151;
    font-size: 1.1rem;
}

.toggle-sidebar {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
}

.toggle-sidebar:hover {
    background: #e5e7eb;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.tool-section {
    padding: 20px;
    border-bottom: 1px solid #f3f4f6;
}

.tool-section h4 {
    margin: 0 0 15px 0;
    color: #374151;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool-btn {
    width: 100%;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #374151;
    font-size: 0.9rem;
    text-align: left;
}

.tool-btn:hover:not(.disabled) {
    background: #e0e7ff;
    border-color: #c7d2fe;
    transform: translateX(2px);
}

.tool-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tool-btn i {
    width: 16px;
    color: #667eea;
}

/* Chat Area */
.ethan-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.conversation-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Messages */
.message {
    display: flex;
    max-width: 80%;
    gap: 10px;
}

/* Fullscreen chat messages - use more width */
.ethan-fullscreen-container .message {
    max-width: 95% !important;
}

/* Widget messages - use more width */
.mini-conversation .message {
    max-width: 95% !important;
    gap: 8px;
}

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

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

/* Widget specific message alignment - use more width */
.mini-conversation .message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
    width: 95%; /* Use almost full width */
    justify-content: flex-start; /* Align content properly */
}

.mini-conversation .message.assistant {
    align-self: flex-start;
    width: 95%; /* Use almost full width */
    justify-content: flex-start;
}

.message-content {
    background: #ffffff;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    border: 1px solid #e5e7eb;
}

/* Override for widget messages - ensure full width usage */
.mini-conversation .message-content {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box;
}

.message.user .message-content {
    background: #ffffff;
    color: #000000;
    font-weight: 600;
    border: 2px solid #4f46e5;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
    transition: all 0.3s ease;
}

.message.user .message-content:hover {
    background: #f8fafc;
    border-color: #6366f1;
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.2);
}

.message.assistant .message-content {
    background: #ffffff;
    color: #1f2937;
    border: 2px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message-time {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 5px;
    text-align: right;
}

.message.assistant .message-time {
    text-align: left;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: #6b7280;
    font-style: italic;
}

.typing-animation {
    display: flex;
    gap: 3px;
}

.typing-animation span {
    width: 6px;
    height: 6px;
    background: #4f46e5;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Quick Actions */
.quick-actions-container {
    padding: 15px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: #fafbfc;
    border-top: 1px solid #e5e7eb;
}

.quick-action-btn {
    background: #e0e7ff;
    border: 1px solid #c7d2fe;
    color: #5b21b6;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.quick-action-btn:hover {
    background: #4f46e5;
    color: white;
    transform: translateY(-1px);
}

/* Input Container */
.input-container {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

.chat-form {
    display: flex;
    gap: 10px;
}

.input-group {
    display: flex;
    flex: 1;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 25px;
    padding: 8px;
    transition: all 0.2s ease;
}

.input-group:focus-within {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.message-input {
    flex: 1;
    border: none;
    background: none;
    padding: 8px 15px;
    font-size: 1rem;
    outline: none;
    color: #000000 !important; /* Pure black for maximum contrast */
    -webkit-text-fill-color: #000000 !important; /* For webkit browsers */
    font-weight: 500;
}

.message-input::placeholder {
    color: #9ca3af !important;
    -webkit-text-fill-color: #9ca3af !important;
}

.send-btn, .voice-btn, .help-btn {
    background: #4f46e5;
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.send-btn:hover, .voice-btn:hover, .help-btn:hover {
    background: #5a67d8;
    transform: scale(1.05);
}

.voice-btn, .help-btn {
    background: #64748b;
    margin-left: 5px;
}

.voice-btn:hover, .help-btn:hover {
    background: #475569;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #374151;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 20px;
}

.setting-group {
    margin-bottom: 15px;
}

.setting-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: #374151;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ethan-sidebar {
        position: absolute;
        left: -280px;
        top: 0;
        height: 100%;
        z-index: 1001;
    }
    
    .ethan-sidebar:not(.collapsed) {
        left: 0;
    }
    
    .ethan-fullscreen-header {
        padding: 12px 15px;
    }
    
    .header-info h2 {
        font-size: 1.2rem;
    }
    
    .ethan-avatar, .ethan-avatar-fallback {
        width: 35px;
        height: 35px;
    }
    
    .conversation-container {
        padding: 15px;
    }
    
    .input-container {
        padding: 15px;
    }
    
    .message {
        max-width: 90%;
    }
}

/* ==========================================================================
   Widget Controls & Minimized State
   ========================================================================== */

/* Widget Header Controls */
.widget-header {
    position: relative !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    color: #000000;
    padding: 12px 15px;
    cursor: pointer;
    border-radius: 12px 12px 0 0;
    border: 2px solid #4f46e5;
}

.widget-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.widget-title {
    font-size: 1rem;
    font-weight: 600;
}

.widget-status {
    font-size: 0.8rem;
    opacity: 0.8;
}

.widget-status.online::before {
    content: "●";
    color: #10b981;
    margin-right: 5px;
}

.widget-header-controls {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    display: flex !important;
    gap: 5px !important;
    opacity: 1 !important;
    transition: opacity 0.2s ease !important;
    z-index: 10 !important;
}

.widget-header:hover .widget-header-controls {
    opacity: 1;
}

.widget-control-btn {
    background: #ff0000 !important;
    border: 2px solid #000000 !important;
    color: #ffffff !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 18px !important;
    font-weight: bold !important;
    line-height: 1 !important;
    transition: all 0.2s ease !important;
    opacity: 1 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5) !important;
}

.widget-control-btn:hover {
    background: rgba(79, 70, 229, 0.2) !important;
    transform: scale(1.1) !important;
}

.widget-control-btn.close-widget:hover {
    background: #ef4444 !important;
    color: white !important;
}

/* Minimized Widget State */
.ethan-floating-widget.minimized {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.ethan-floating-widget.minimized .widget-header {
    border-radius: 12px;
    cursor: pointer;
}

.ethan-floating-widget.minimized .widget-header-controls {
    opacity: 0;
}

.ethan-floating-widget.minimized:hover .widget-header-controls {
    opacity: 1;
}

/* Widget positioning and responsive */
.ethan-floating-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    max-width: calc(100vw - 40px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    z-index: 9999;
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .ethan-floating-widget {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 10px;
    }
    
    .widget-header-controls {
        opacity: 1; /* Always show on mobile */
    }
}

/* ==========================================================================
   Main Interface Styles
   ========================================================================== */

.ethan-main-interface {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
}

.ethan-main-interface.minimized {
    height: 60px;
    overflow: hidden;
}

/* Header */
.ethan-header {
    background: #ffffff;
    color: #000000;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 2px solid #4f46e5;
    border-radius: 12px 12px 0 0;
}

.ethan-avatar img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.ethan-info h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.ethan-status {
    font-size: 0.9rem;
    opacity: 0.9;
}

.ethan-status.online::before {
    content: "●";
    color: #10b981;
    margin-right: 5px;
}

.ethan-controls {
    margin-left: auto;
}

/* Progress Bar */
.ethan-progress-bar {
    padding: 15px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.progress {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar {
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    height: 100%;
    transition: width 0.5s ease;
}

.step-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.current-step {
    font-weight: 600;
    color: #374151;
}

.step-description {
    color: #6b7280;
    font-size: 0.9rem;
}

/* Conversation Area */
.ethan-conversation {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
    background: #fefefe;
}

.message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.message.user {
    align-items: flex-end;
}

.message.assistant {
    align-items: flex-start;
}

.message.system {
    align-items: center;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
}

.message.user .message-content {
    background: #ffffff;
    color: #000000;
    border-bottom-right-radius: 4px;
    font-weight: 600;
    border: 2px solid #4f46e5;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.15);
    transition: all 0.3s ease;
}

.message.user .message-content:hover {
    background: #f8fafc;
    border-color: #6366f1;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.message.assistant .message-content {
    background: #ffffff;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    border: 2px solid #e5e7eb;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.message.system .message-content {
    background: #fef2f2;
    color: #991b1b;
    border-radius: 8px;
    font-size: 0.9rem;
    border: 1px solid #fecaca;
    font-weight: 500;
}

.message-time {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-top: 5px;
    margin-left: 10px;
    margin-right: 10px;
}

/* Input Area */
.ethan-input-area {
    padding: 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.chat-form .input-group {
    display: flex;
    gap: 10px;
}

.chat-form input[type="text"] {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    color: #000000 !important; /* Pure black for maximum contrast */
    -webkit-text-fill-color: #000000 !important; /* For webkit browsers */
    font-weight: 500;
}

.chat-form input[type="text"]:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
    background: #fafafa;
}

.chat-form button[type="submit"] {
    padding: 12px 20px;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-form button[type="submit"]:hover {
    background: #4338ca;
}

/* Typing Indicator */
.ethan-typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    color: #6b7280;
    font-size: 0.9rem;
}

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

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #4f46e5;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* ✅ ENHANCED: Quick Actions with Better Styling */
.ethan-quick-actions {
    padding: 15px 20px;
    background: #f8fafc;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    border-top: 1px solid #e2e8f0;
    max-height: 120px;
    overflow-y: auto;
}

.quick-action-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%);
    border: 1px solid #4f46e5;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #4f46e5;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.1);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.quick-action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.quick-action-btn:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border-color: #7c3aed;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.quick-action-btn:hover::before {
    left: 100%;
}

.quick-action-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

/* ✅ NEW: Quick Actions Container in Widget */
#ethan-quick-actions {
    display: none;
    padding: 10px 15px;
    background: #fafbfc;
    border-top: 1px solid #e2e8f0;
    max-height: 120px !important;
    overflow-y: auto;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0 !important;
}

#ethan-quick-actions.show {
    display: flex !important;
}

/* ==========================================================================
   Sidebar Styles
   ========================================================================== */

.ethan-sidebar {
    position: fixed;
    right: -350px;
    top: 0;
    width: 350px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.ethan-sidebar.open {
    right: 0;
}

.sidebar-header {
    background: #ffffff;
    color: #000000;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px solid #4f46e5;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.sidebar-content {
    padding: 20px;
}

.profile-section,
.workflow-section {
    margin-bottom: 30px;
}

.profile-section h4,
.workflow-section h4 {
    margin: 0 0 15px 0;
    color: #374151;
    font-size: 1.1rem;
}

.profile-section p {
    margin: 8px 0;
    color: #6b7280;
}

.workflow-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.workflow-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    background: #f8fafc;
}

.workflow-step.current {
    background: #eff6ff;
    border-left: 3px solid #4f46e5;
}

.workflow-step.completed {
    background: #f0fdf4;
    border-left: 3px solid #10b981;
}

.step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #d1d5db;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.workflow-step.current .step-number {
    background: #4f46e5;
}

.workflow-step.completed .step-number {
    background: #10b981;
}

.step-name {
    font-weight: 500;
    color: #374151;
}

/* ==========================================================================
   ✅ FIXED: Floating Widget Styles - HEIGHT OPTIMIZATION APPLIED
   ========================================================================== */

.ethan-floating-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    height: auto !important;
    max-height: 80vh !important;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ethan-floating-widget:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.widget-header {
    background: #ffffff;
    color: #000000;
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    border: 2px solid #4f46e5;
}

.widget-header:hover {
    background: #f8fafc;
    border-color: #6366f1;
}

.widget-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: transform 0.2s ease;
}

.widget-header:hover .widget-avatar {
    transform: scale(1.05);
}

/* ✅ Enhanced Avatar Fallback */
.widget-avatar-fallback {
    width: 35px;
    height: 35px;
    background: #4f46e5;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    border: 2px solid rgba(79, 70, 229, 0.3);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.widget-title {
    font-weight: 600;
    font-size: 1.1rem;
    flex: 1;
}

.widget-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    animation: pulse 2s infinite;
}

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

/* ✅ FIXED: Widget Content with Height Optimization */
.widget-content {
    height: auto !important;
    max-height: calc(80vh - 60px) !important;
    overflow-y: auto !important;
    display: flex !important;
    flex-direction: column !important;
    background: linear-gradient(180deg, #fefefe 0%, #f9fafb 100%);
}

/* ✅ FIXED: Mini Conversation with Optimized Height and Full Width */
.mini-conversation {
    flex: 1 !important;
    min-height: 200px !important;
    max-height: 300px !important;
    overflow-y: auto !important;
    padding: 8px 12px; /* Reduced padding for more space */
    background: transparent;
    scroll-behavior: smooth;
}

/* ✅ Enhanced Scrollbar for Conversation */
.mini-conversation::-webkit-scrollbar {
    width: 6px;
}

.mini-conversation::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.mini-conversation::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.mini-conversation::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ✅ FIXED: Better input layout - always visible at bottom */
.mini-input-area {
    padding: 15px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0 !important;
}

.mini-input-area form {
    display: flex;
    align-items: stretch; /* Match heights properly */
    gap: 8px; /* Smaller gap for more input space */
    background: white;
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.mini-input-area input {
    flex: 1; /* Take all available space */
    padding: 10px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 0; /* Allow proper flex shrinking */
    background: transparent;
    outline: none;
    color: #374151 !important; /* Dark text for visibility */
    -webkit-text-fill-color: #374151 !important; /* For webkit browsers */
}

.mini-input-area input::placeholder {
    color: #9ca3af !important;
    font-style: italic;
    -webkit-text-fill-color: #9ca3af !important;
}

.mini-input-area input:focus {
    background: #f9fafb;
}

.mini-input-area button {
    padding: 10px 16px; /* Slightly wider for better click target */
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0; /* Prevent button from shrinking */
    white-space: nowrap; /* Prevent text wrapping */
    font-size: 0.9rem;
    min-width: 45px; /* Minimum button width */
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.mini-input-area button:hover {
    background: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(79, 70, 229, 0.3);
}

.mini-input-area button:active {
    transform: translateY(0);
}

/* ✅ FIXED: Action Buttons - Always Visible at Bottom */
.mini-actions {
    padding: 12px 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
    border-radius: 0 0 12px 12px;
    display: flex;
    gap: 8px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 10 !important;
}

.mini-action-btn {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.mini-action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.1), transparent);
    transition: left 0.3s;
}

.mini-action-btn:hover {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.mini-action-btn:hover::before {
    left: 100%;
}

.mini-action-btn:active {
    transform: translateY(0);
}

/* ==========================================================================
   Enhanced Message Styles
   ========================================================================== */

.mini-conversation .message {
    margin-bottom: 12px; /* Reduced spacing for more content */
    animation: messageSlideIn 0.3s ease-out;
}

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

.mini-conversation .message.user .message-content {
    background: #4f46e5;
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
    padding: 10px 12px; /* Compact padding */
    border-radius: 12px;
    word-wrap: break-word;
    max-width: none; /* Use available width */
}

.mini-conversation .message.assistant .message-content {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #374151;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    padding: 10px 12px; /* Compact padding */
    border-radius: 12px;
    word-wrap: break-word;
    max-width: none; /* Use available width */
    line-height: 1.4; /* Better line spacing */
}

.mini-conversation .message.system .message-content {
    background: linear-gradient(135deg, #fef3cd 0%, #fde68a 100%);
    color: #92400e;
    border: 1px solid #f59e0b;
    font-size: 0.85rem;
    padding: 8px 10px; /* Compact padding for system messages */
    border-radius: 10px;
    word-wrap: break-word;
    max-width: none; /* Use available width */
}

/* ==========================================================================
   Responsive Design - ENHANCED
   ========================================================================== */

@media (max-width: 768px) {
    .ethan-main-interface {
        margin: 10px;
        border-radius: 8px;
    }
    
    .ethan-header {
        padding: 15px;
    }
    
    .ethan-conversation {
        height: 300px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .ethan-floating-widget {
        width: calc(100vw - 40px) !important;
        right: 20px;
        left: 20px;
        max-width: 400px !important;
        bottom: 10px;
        max-height: 85vh !important;
    }
    
    .widget-content {
        max-height: calc(85vh - 60px) !important;
    }
    
    .mini-conversation {
        min-height: 150px !important;
        max-height: 250px !important;
    }
    
    .ethan-sidebar {
        width: 100vw;
        right: -100vw;
    }
}

@media (max-width: 480px) {
    .ethan-header {
        padding: 12px;
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .ethan-avatar img {
        width: 40px;
        height: 40px;
    }
    
    .ethan-info h2 {
        font-size: 1.3rem;
    }
    
    .chat-form .input-group {
        flex-direction: column;
    }
    
    .quick-action-btn {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    
    /* Keep horizontal layout even on small screens for widget */
    .mini-input-area form {
        display: flex; /* Maintain horizontal layout */
        flex-direction: row; /* Force horizontal */
    }
    
    .mini-input-area input {
        font-size: 0.85rem; /* Slightly smaller text on mobile */
    }
    
    .mini-input-area button {
        padding: 10px 12px; /* Smaller button on mobile */
        min-width: 40px;
    }
    
    .ethan-floating-widget {
        width: calc(100vw - 20px) !important;
        right: 10px;
        left: 10px;
        bottom: 10px;
        max-height: 90vh !important;
    }
    
    .widget-content {
        max-height: calc(90vh - 60px) !important;
    }
    
    .mini-conversation {
        min-height: 120px !important;
        max-height: 200px !important;
    }
}

/* ==========================================================================
   Dark Theme Support - ENHANCED
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .ethan-main-interface {
        background: #ffffff;
        color: #000000;
    }
    
    .ethan-conversation {
        background: #f8fafc;
    }
    
    .message.assistant .message-content {
        background: #ffffff;
        color: #000000;
        border-color: #e5e7eb;
    }
    
    .ethan-input-area {
        background: #f8fafc;
        border-top-color: #e5e7eb;
    }
    
    .chat-form input[type="text"] {
        background: #ffffff;
        color: #000000;
        border-color: #d1d5db;
    }
    
    .ethan-quick-actions {
        background: #374151;
    }
    
    .quick-action-btn {
        background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
        color: #f9fafb;
        border-color: #4b5563;
    }
    
    .ethan-sidebar {
        background: #1f2937;
        color: #f9fafb;
    }
    
    .sidebar-content {
        background: #1f2937;
    }
    
    .workflow-step {
        background: #374151;
    }
    
    .ethan-floating-widget {
        background: #ffffff;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    }
    
    .widget-content {
        background: #ffffff;
    }
    
    .mini-conversation {
        background: transparent;
    }
    
    .mini-input-area {
        background: linear-gradient(180deg, #374151 0%, #1f2937 100%);
        border-top-color: #4b5563;
    }
    
    .mini-input-area form {
        background: #111827;
        border-color: #4b5563;
    }
    
    .mini-input-area input {
        color: #f9fafb;
        background: transparent;
    }
    
    .mini-input-area input::placeholder {
        color: #6b7280;
    }
    
    .mini-actions {
        background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
        border-top-color: #4b5563;
    }
    
    .mini-action-btn {
        background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
        color: #f9fafb;
        border-color: #4b5563;
    }
    
    .mini-conversation .message.assistant .message-content {
        background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
        color: #f9fafb;
    }
    
    .mini-conversation .message.system .message-content {
        background: linear-gradient(135deg, #451a03 0%, #92400e 100%);
        color: #fbbf24;
        border-color: #d97706;
    }
}

/* ==========================================================================
   Animation and Transitions - ENHANCED
   ========================================================================== */

.ethan-main-interface,
.ethan-sidebar,
.ethan-floating-widget {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.message {
    animation: fadeInUp 0.3s ease-out;
}

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

/* ✅ NEW: Quick Actions Animation */
@keyframes quickActionSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#ethan-quick-actions .quick-action-btn {
    animation: quickActionSlideIn 0.3s ease-out;
    animation-fill-mode: both;
}

#ethan-quick-actions .quick-action-btn:nth-child(1) { animation-delay: 0.1s; }
#ethan-quick-actions .quick-action-btn:nth-child(2) { animation-delay: 0.15s; }
#ethan-quick-actions .quick-action-btn:nth-child(3) { animation-delay: 0.2s; }
#ethan-quick-actions .quick-action-btn:nth-child(4) { animation-delay: 0.25s; }
#ethan-quick-actions .quick-action-btn:nth-child(5) { animation-delay: 0.3s; }
#ethan-quick-actions .quick-action-btn:nth-child(6) { animation-delay: 0.35s; }

/* ==========================================================================
   Accessibility - ENHANCED
   ========================================================================== */

.ethan-main-interface:focus-within,
.ethan-floating-widget:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.quick-action-btn:focus,
.chat-form button:focus,
.mini-input-area button:focus,
.mini-action-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    z-index: 1;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ethan-header {
        background: #000;
    }
    
    .message.user .message-content {
        background: #000;
    }
    
    .message.assistant .message-content {
        background: #fff;
        border: 2px solid #000;
        color: #000;
    }
    
    .quick-action-btn {
        border: 2px solid #000;
    }
    
    .mini-action-btn {
        border: 2px solid #000;
    }
}

/* ==========================================================================
   ✅ FIXED: Typing Indicator Text Color Fix
   ========================================================================== */

/* ✅ FIXED: Typing Indicator Colors - Different for Different Backgrounds */

/* Typing indicator with dark background (floating) */
#ethan-typing {
    background: rgba(55, 65, 81, 0.95) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

#ethan-typing * {
    color: white !important;
}

/* Typing indicator in conversation area (light background) */
.ethan-typing-indicator,
.typing-indicator {
    color: #374151 !important;
    background: rgba(249, 250, 251, 0.9) !important;
    border: 1px solid #e5e7eb !important;
    padding: 8px 15px;
    border-radius: 12px;
}

.ethan-typing-indicator *,
.typing-indicator * {
    color: #374151 !important;
}

/* Typing dots animation colors */
.typing-animation span,
.typing-dots span {
    background: #4f46e5 !important;
}

/* ✅ UNIVERSAL INPUT TEXT FIX - Ensure all input text is visible */
.ethan-floating-widget input,
.widget-content input,
.ethan-main-interface input,
.ethan-fullscreen-container input,
#ethan-message-input,
input[placeholder="Ask Ethan..."],
input[placeholder*="message"] {
    color: #374151 !important;
    -webkit-text-fill-color: #374151 !important;
    text-shadow: none !important;
}

/* Input focus states */
.ethan-floating-widget input:focus,
.widget-content input:focus,
.ethan-main-interface input:focus,
.ethan-fullscreen-container input:focus {
    color: #1f2937 !important;
    -webkit-text-fill-color: #1f2937 !important;
}

/* Universal placeholder visibility */
.ethan-floating-widget input::placeholder,
.widget-content input::placeholder,
.ethan-main-interface input::placeholder,
.ethan-fullscreen-container input::placeholder,
#ethan-message-input::placeholder {
    color: #9ca3af !important;
    -webkit-text-fill-color: #9ca3af !important;
    opacity: 1 !important;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .ethan-floating-widget,
    .ethan-sidebar,
    .ethan-quick-actions {
        display: none !important;
    }
}
