/**
 * All of the CSS for the public-facing functionality should be
 * included in this file.
 */

/* Reset and Base Styles */
.wp-explainer-bubble,
.wp-explainer-popup {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.5;
}

.wp-explainer-bubble *,
.wp-explainer-popup * {
    box-sizing: border-box;
}

/* Floating Bubble */
.wp-explainer-bubble {
    position: fixed;
    z-index: 999998;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.wp-explainer-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
}

.wp-explainer-bubble.bottom-right {
    bottom: 24px;
    right: 24px;
}

.wp-explainer-bubble.bottom-left {
    bottom: 24px;
    left: 24px;
}

.wp-explainer-bubble.visible {
    display: flex;
    animation: bubbleSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes bubbleSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.wp-explainer-bubble .bubble-icon {
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-explainer-bubble .bubble-icon svg {
    width: 28px;
    height: 28px;
}

/* Bubble Tooltip */
.wp-explainer-bubble .bubble-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.wp-explainer-bubble .bubble-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

.wp-explainer-bubble:hover .bubble-tooltip {
    opacity: 1;
}

/* Main Popup - Tooltip Style */
.wp-explainer-popup {
    position: absolute;
    z-index: 999999;
    display: none;
    max-width: 400px;
    min-width: 300px;
    transition: all 0.3s ease;
}

.wp-explainer-popup.visible {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    animation: tooltipFadeIn 0.25s ease-out;
}

.wp-explainer-popup.loading-mode {
    max-width: 200px;
    min-width: 180px;
}

.wp-explainer-popup.loading-mode .popup-content {
    transform: scale(0.9);
}

.wp-explainer-popup.expanded {
    max-width: 400px;
    min-width: 300px;
}

.wp-explainer-popup.expanded .popup-content {
    transform: scale(1);
    animation: expandTooltip 0.3s ease-out;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(0.9);
    }
}

@keyframes expandTooltip {
    from {
        transform: scale(0.9);
    }
    to {
        transform: scale(1);
    }
}

/* Popup Content */
.wp-explainer-popup .popup-content {
    background: #1c232d;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    position: relative;
    transition: transform 0.3s ease;
}

/* Compact Loading State */
.wp-explainer-popup.loading-mode .explanation-content {
    display: none;
}

.wp-explainer-popup.loading-mode .loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    gap: 10px;
}

.wp-explainer-popup.loading-mode .loading-state span {
    font-size: 16px;
    font-weight: 500;
    color: #e5e7eb;
}

/* Popup Body */
.wp-explainer-popup .popup-body {
    padding: 16px;
    position: relative;
    transition: all 0.3s ease;
}

/* Loading State */
.wp-explainer-popup .loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #e5e7eb;
    font-size: 15px;
    padding: 12px 0;
    transition: all 0.3s ease;
}

.wp-explainer-popup .loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Explanation Content */
.wp-explainer-popup .explanation-content {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wp-explainer-popup .explanation-content.visible {
    display: block;
    opacity: 1;
    animation: contentSlideIn 0.3s ease-out;
}

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

.wp-explainer-popup .explanation-text {
    color: #e5e7eb;
    font-size: 16px;
    line-height: 1.5;
    margin: 0 0 16px;
    word-wrap: break-word;
}

.wp-explainer-popup .explanation-text p {
    margin: 0 0 8px;
}

.wp-explainer-popup .explanation-text p:last-child {
    margin-bottom: 0;
}

/* Action Buttons */
.wp-explainer-popup .explanation-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.wp-explainer-popup .action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 6px 12px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.wp-explainer-popup .action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.wp-explainer-popup .action-btn:active {
    transform: translateY(0);
}

/* Like/Dislike Buttons */
.wp-explainer-popup .like-btn,
.wp-explainer-popup .dislike-btn {
    width: 32px;
    height: 32px;
    padding: 6px;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.wp-explainer-popup .like-btn i,
.wp-explainer-popup .dislike-btn i {
    font-size: 14px;
}

.wp-explainer-popup .like-btn:hover,
.wp-explainer-popup .dislike-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.wp-explainer-popup .like-btn.active {
    background: rgba(34, 197, 94, 0.3);
    color: #ffffff;
}

.wp-explainer-popup .dislike-btn.active {
    background: rgba(239, 68, 68, 0.3);
    color: #ffffff;
}

/* Simplify Button */
.wp-explainer-popup .simplify-btn {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.wp-explainer-popup .simplify-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Explanation Branding */
.wp-explainer-popup .explanation-branding {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.wp-explainer-popup .branding-text {
    color: #ffffff;
    font-size: 12px;
    font-weight: 400;
    opacity: 0.8;
}

/* Text Selection Highlighting */
::selection {
    background: rgba(102, 126, 234, 0.2);
}

::-moz-selection {
    background: rgba(102, 126, 234, 0.2);
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .wp-explainer-popup {
        max-width: 320px;
        min-width: 280px;
    }
    
    .wp-explainer-popup .popup-body {
        padding: 12px;
    }
    
    .wp-explainer-popup .explanation-text {
        font-size: 13px;
    }
    
    .wp-explainer-popup .explanation-actions {
        gap: 6px;
    }
    
    .wp-explainer-popup .action-btn {
        font-size: 11px;
        padding: 5px 10px;
    }
}

@media screen and (max-width: 480px) {
    .wp-explainer-popup {
        max-width: 280px;
        min-width: 260px;
    }
    
    .wp-explainer-popup .explanation-actions {
        display: none !important;
    }

    .wp-explainer-popup .simplify-btn {
        width: 100%;
        padding: 12px;
        font-size: 16px;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .wp-explainer-popup .popup-content {
        border-width: 2px;
        border-color: #000000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .wp-explainer-popup,
    .wp-explainer-popup .explanation-content,
    .wp-explainer-popup .action-btn {
        animation: none;
        transition: none;
    }
    
    .wp-explainer-popup .loading-spinner {
        animation: none;
        border: 2px solid #3b82f6;
        border-top-color: transparent;
    }
}

/* Dark Mode Compatibility */
@media (prefers-color-scheme: dark) {
    .wp-explainer-popup .popup-content {
        background: #1f2937;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .wp-explainer-popup .explanation-text {
        color: #e5e7eb;
    }
}

/* Toggle Switch Styles */
.wp-explainer-toggle {
    position: fixed;
    z-index: 999997;
    background: rgba(28, 35, 45, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    padding: 8px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: none;
}

/* Position classes for toggle */
.wp-explainer-toggle.bottom-left {
    bottom: 20px;
    left: 20px;
}

.wp-explainer-toggle.bottom-right {
    bottom: 20px;
    right: 20px;
}

.wp-explainer-toggle.bottom-middle {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.wp-explainer-toggle.top-left {
    top: 20px;
    left: 20px;
}

.wp-explainer-toggle.top-right {
    top: 20px;
    right: 20px;
}

.wp-explainer-toggle.visible {
    display: block;
    animation: toggleSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Special animation for bottom-middle */
.wp-explainer-toggle.bottom-middle.visible {
    animation: toggleSlideInCenter 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes toggleSlideInCenter {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.wp-explainer-toggle .toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wp-explainer-toggle .toggle-label {
    color: #e5e7eb;
    font-size: 14px;
    font-weight: 500;
    user-select: none;
}

.wp-explainer-toggle .toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.wp-explainer-toggle .toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.wp-explainer-toggle .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #374151;
    border-radius: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.wp-explainer-toggle .toggle-slider:hover {
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.wp-explainer-toggle .toggle-knob {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 2px;
    background: #ffffff;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: block;
}

.wp-explainer-toggle .toggle-input:checked + .toggle-slider {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: rgba(102, 126, 234, 0.3);
}

.wp-explainer-toggle .toggle-input:checked + .toggle-slider .toggle-knob {
    transform: translateX(20px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.wp-explainer-toggle .toggle-input:focus + .toggle-slider {
    outline: 2px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

/* Toggle disabled state */
.wp-explainer-toggle.disabled .toggle-label {
    color: #9ca3af;
}

.wp-explainer-toggle.disabled .toggle-slider {
    background: #1f2937;
    cursor: not-allowed;
}

.wp-explainer-toggle.disabled .toggle-knob {
    background: #6b7280;
}

/* Responsive adjustments for toggle */
@media screen and (max-width: 768px) {
    .wp-explainer-toggle {
        padding: 6px 12px;
    }
    
    .wp-explainer-toggle.bottom-left,
    .wp-explainer-toggle.bottom-right,
    .wp-explainer-toggle.bottom-middle {
        bottom: 15px;
    }
    
    .wp-explainer-toggle.top-left,
    .wp-explainer-toggle.top-right {
        top: 15px;
    }
    
    .wp-explainer-toggle .toggle-container {
        gap: 8px;
    }
    
    .wp-explainer-toggle .toggle-label {
        font-size: 13px;
    }
    
    .wp-explainer-toggle .toggle-switch {
        width: 40px;
        height: 22px;
    }
    
    .wp-explainer-toggle .toggle-knob {
        height: 16px;
        width: 16px;
        left: 3px;
        bottom: 2px;
    }
    
    .wp-explainer-toggle .toggle-input:checked + .toggle-slider .toggle-knob {
        transform: translateX(18px);
    }
} 