/**
 * FSAI Plugin - Widget CSS
 * Floating widget with adaptive polling
 *
 * @author Luis
 * @copyright 2024 Mitiga
 */

.fsai-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 0;
    width: 380px;
    height: 500px;
    display: flex;
    flex-direction: column;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transition: all 0.3s ease;
}

/* Disable transitions during initial load to prevent flash */
.fsai-widget.no-transition,
.fsai-widget.no-transition * {
    transition: none !important;
}

.fsai-widget.collapsed {
    min-width: auto;
    padding: 0;
    opacity: 0.7;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    right: -30px; /* Half hidden off-screen */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Invisible hover area to prevent jittering */
.fsai-widget.collapsed::before {
    content: '';
    position: absolute;
    top: 0;
    left: -80px; /* Extend hover area 80px to the left (towards screen center) */
    width: 140px; /* Wide enough: 80px extension + 60px widget */
    height: 100%;
    cursor: pointer;
    z-index: -1;
}

.fsai-widget.collapsed:hover {
    opacity: 1;
    right: 3px; /* Slide in fully on hover */
    transform: scale(1.05);
}

.fsai-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px 12px 0 0;
    cursor: pointer;
}

.fsai-widget-title {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fsai-widget-icon {
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.fsai-widget-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    color: #ffffff;
    font-size: 18px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.2s;
}

.fsai-widget-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.fsai-widget-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.fsai-widget.collapsed .fsai-widget-body {
    display: none;
}

/* Collapsed state - only show icon */
.fsai-widget.collapsed .fsai-widget-header {
    margin-bottom: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    width: 100%;
    height: 100%;
    justify-content: center;
}

.fsai-widget.collapsed .fsai-widget-title {
    width: 100%;
    height: 100%;
    justify-content: center;
}

.fsai-widget.collapsed .fsai-widget-title span,
.fsai-widget.collapsed .fsai-status-indicator,
.fsai-widget.collapsed .fsai-widget-toggle {
    display: none;
}

.fsai-widget.collapsed .fsai-widget-icon {
    font-size: 28px;
    width: 40px;
    height: 40px;
    margin: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
}

/* Old stats styles removed - now using compact stats in fsai-chat.css */

.fsai-status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 2s infinite;
}

.fsai-status-indicator.active {
    background: #198754;
}

.fsai-status-indicator.idle {
    background: #6c757d;
    animation: none;
}

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

/* Mobile responsive */
@media (max-width: 768px) {
    .fsai-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

