/**
 * AzarX Pro Avatar Widget Styles
 *
 * Modello-style pulsing animation (chatbox-pulse.css inspired)
 * Colors: #3b82f6, #8b5cf6, #a855f7
 *
 * @package AzarX_Pro
 * @since 0.3.1
 */

/* ==========================================================================
   Design Tokens
   ========================================================================== */

:root {
    --azarx-widget-size: 72px;
    --azarx-widget-offset: 24px;
    --azarx-widget-mobile-offset: 16px;

    /* Colors - Blue/Purple gradient (Modello style) */
    --azarx-color-blue: #3b82f6;
    --azarx-color-purple: #8b5cf6;
    --azarx-color-violet: #a855f7;
    --azarx-color-indigo: #6366f1;

    /* Dark backgrounds */
    --azarx-widget-bg-dark: #0a021f;
    --azarx-widget-bg-glass: rgba(31, 41, 55, 0.85);
    --azarx-widget-border: rgba(75, 85, 99, 0.5);

    /* Text */
    --azarx-widget-text: #f8f8ff;
    --azarx-widget-text-muted: #9ca3af;
}

/* ==========================================================================
   Main Widget Container
   CRITICAL: Must be perfect square with aspect-ratio: 1
   ========================================================================== */

.azarx-avatar-widget {
    position: fixed;
    z-index: 99999;

    /* Force perfect square - critical for circle */
    width: var(--azarx-widget-size);
    height: var(--azarx-widget-size);
    aspect-ratio: 1 / 1;

    /* Make it circular */
    border-radius: 50%;

    /* VISIBLE for pulse effects to show outside */
    overflow: visible;

    /* Reset button styles */
    border: none;
    padding: 0;
    margin: 0;
    background: transparent;
    cursor: pointer;
    box-sizing: border-box;
}

/* Position Variants */
.azarx-widget-bottom-right {
    bottom: var(--azarx-widget-offset);
    right: var(--azarx-widget-offset);
}

.azarx-widget-bottom-left {
    bottom: var(--azarx-widget-offset);
    left: var(--azarx-widget-offset);
}

.azarx-widget-top-right {
    top: var(--azarx-widget-offset);
    right: var(--azarx-widget-offset);
}

.azarx-widget-top-left {
    top: var(--azarx-widget-offset);
    left: var(--azarx-widget-offset);
}

/* Size Variants */
.azarx-widget-small {
    --azarx-widget-size: 58px;
}

.azarx-widget-medium {
    --azarx-widget-size: 72px;
}

.azarx-widget-large {
    --azarx-widget-size: 78px;
}

/* ==========================================================================
   Pulsing Ring - Uses ::before pseudo-element
   Positioned BEHIND the avatar image
   ========================================================================== */

.azarx-avatar-widget::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    /* Slightly larger than container for ring effect */
    width: calc(100% + 8px);
    height: calc(100% + 8px);

    /* Gradient ring */
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #a855f7 100%);

    /* Behind the image */
    z-index: 0;

    /* Pulse animation */
    animation: azarx-ring-pulse 2.5s ease-in-out infinite;
}

@keyframes azarx-ring-pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
}

/* ==========================================================================
   Glow Effect - Uses ::after pseudo-element
   Creates the outer glow/shadow
   ========================================================================== */

.azarx-avatar-widget::after { 
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    /* Larger for glow spread */
    width: calc(100% + 16px);
    height: calc(100% + 16px);

    border-radius: 50%;

    /* Glow via box-shadow */
    box-shadow:
        0 0 20px rgba(59, 130, 246, 0.5),
        0 0 40px rgba(139, 92, 246, 0.4),
        0 0 60px rgba(168, 85, 247, 0.3);

    /* Behind everything */
    z-index: -1;

    /* Glow animation */
    animation: azarx-glow-pulse 2.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes azarx-glow-pulse {
    0%, 100% {
        box-shadow:
            0 0 15px rgba(59, 130, 246, 0.4),
            0 0 30px rgba(139, 92, 246, 0.3),
            0 0 50px rgba(168, 85, 247, 0.2);
    }
    50% {
        box-shadow:
            0 0 25px rgba(59, 130, 246, 0.6),
            0 0 50px rgba(139, 92, 246, 0.5),
            0 0 80px rgba(168, 85, 247, 0.4);
    }
}

/* Hover - faster animation */
.azarx-avatar-widget:hover::before,
.azarx-avatar-widget:hover::after {
    animation-duration: 1.5s;
}

/* ==========================================================================
   Avatar Image Container
   CRITICAL: This creates the circular mask for ANY image
   ========================================================================== */

.azarx-avatar-image {
    /* Fill the parent completely */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    /* Force square aspect ratio */
    aspect-ratio: 1 / 1;

    /* Circular mask - THIS IS THE KEY */
    border-radius: 50%;
    overflow: hidden;

    /* Above the pulse ring */
    z-index: 1;
}

.azarx-avatar-image img {
    /* Fill container completely */
    width: 100%;
    height: 100%;

    /* CRITICAL: Cover maintains aspect ratio, crops excess */
    object-fit: cover;

    /* Center the crop point */
    object-position: center center;

    /* Remove any default spacing */
    display: block;

    /* Extra safety - circular clip */
    border-radius: 50%;
}

/* Hide the old pulse spans - no longer needed */
.azarx-avatar-pulse { display: none !important;
    
}

/* ==========================================================================
   Focus & Active States
   ========================================================================== */

.azarx-avatar-widget:focus {
    outline: none;
}

.azarx-avatar-widget:focus-visible {
    outline: 3px solid var(--azarx-color-blue);
    outline-offset: 6px;
}

.azarx-avatar-widget:active .azarx-avatar-image {
    transform: scale(0.95);
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .azarx-avatar-widget::before,
    .azarx-avatar-widget::after { 
        animation: none;
    }

    .azarx-avatar-widget::before {
        opacity: 0.8;
    }
}

/* ==========================================================================
   Mobile Responsiveness
   ========================================================================== */

@media (max-width: 768px) {
    .azarx-widget-bottom-right,
    .azarx-widget-bottom-left {
        bottom: var(--azarx-widget-mobile-offset);
    }

    .azarx-widget-top-right,
    .azarx-widget-top-left {
        top: var(--azarx-widget-mobile-offset);
    }

    .azarx-widget-bottom-right,
    .azarx-widget-top-right {
        right: var(--azarx-widget-mobile-offset);
    }

    .azarx-widget-bottom-left,
    .azarx-widget-top-left {
        left: var(--azarx-widget-mobile-offset);
    }
}

@media (max-width: 480px) {
    .azarx-widget-bottom-right,
    .azarx-widget-bottom-left {
        bottom: 80px;
    }

    .azarx-widget-small {
        --azarx-widget-size: 50px;
    }

    .azarx-widget-medium {
        --azarx-widget-size: 64px;
    }

    .azarx-widget-large {
        --azarx-widget-size: 72px;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .azarx-avatar-widget {
        opacity: 0.8;
        transform: scale(0.75);
    }

    .azarx-widget-bottom-right { bottom: 8px; right: 8px; }
    .azarx-widget-bottom-left { bottom: 8px; left: 8px; }
    .azarx-widget-top-right { top: 8px; right: 8px; }
    .azarx-widget-top-left { top: 8px; left: 8px; }
}

/* ==========================================================================
   High Contrast
   ========================================================================== */

@media (prefers-contrast: high) {
    .azarx-avatar-widget::before {
        opacity: 1;
    }
}

/* ==========================================================================
   Modal Styles - Ultra Modern Dark
   ========================================================================== */

body.azarx-modal-open {
    overflow: hidden;
}

.azarx-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
}

.azarx-modal-overlay[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
}

/* Backdrop - Glass blur */
.azarx-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Modal Container - Glassmorphism */
.azarx-modal-container {
    position: relative;
    z-index: 1;
    background: var(--azarx-widget-bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--azarx-widget-border);
    border-radius: 24px;
    box-shadow:
        0 25px 80px -20px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 0 100px -30px rgba(139, 92, 246, 0.5);
    max-width: 680px;
    width: 100%;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    display: flex;
    flex-direction: column;
    transform: scale(0.9) translateY(30px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

/* Gradient top border */
.azarx-modal-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        var(--azarx-color-blue) 0%,
        var(--azarx-color-purple) 50%,
        var(--azarx-color-violet) 100%);
    background-size: 200% 100%;
    animation: azarx-modal-gradient 4s ease infinite;
}

@keyframes azarx-modal-gradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.azarx-modal-overlay[aria-hidden="false"] .azarx-modal-container {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.azarx-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px;
    border-bottom: 1px solid var(--azarx-widget-border);
    flex-shrink: 0;
}

.azarx-modal-title {
    margin: 0;
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--azarx-widget-text);
    font-family: 'Poppins', sans-serif;
    letter-spacing: -0.02em;
}

/* Close Button */
.azarx-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--azarx-widget-border);
    background: transparent;
    border-radius: 12px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: var(--azarx-widget-text-muted);
    transition: all 0.25s ease;
}

.azarx-modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #ef4444;
    transform: rotate(90deg);
}

.azarx-modal-close:focus {
    outline: none;
}

.azarx-modal-close:focus-visible {
    outline: 2px solid var(--azarx-color-blue);
    outline-offset: 2px;
}

/* Modal Body */
.azarx-modal-body {
    padding: 28px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar */
.azarx-modal-body::-webkit-scrollbar {
    width: 8px;
}

.azarx-modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.azarx-modal-body::-webkit-scrollbar-thumb {
    background: var(--azarx-widget-border);
    border-radius: 4px;
}

.azarx-modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--azarx-color-purple);
}

/* Form adjustments inside modal */
.azarx-modal-body .azarx-form-wrapper {
    max-width: none;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
}

.azarx-modal-body .azarx-form-wrapper::before,
.azarx-modal-body .azarx-form-wrapper::after {
    display: none;
}

/* ==========================================================================
   Mobile Modal - Sheet style
   ========================================================================== */

@media (max-width: 640px) {
    .azarx-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .azarx-modal-container {
        max-width: none;
        max-height: 92vh;
        max-height: 92dvh;
        border-radius: 24px 24px 0 0;
        transform: translateY(100%);
    }

    .azarx-modal-overlay[aria-hidden="false"] .azarx-modal-container {
        transform: translateY(0);
    }

    /* Drag handle indicator */
    .azarx-modal-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: var(--azarx-widget-border);
        border-radius: 2px;
    }

    .azarx-modal-header {
        padding: 28px 20px 20px;
    }

    .azarx-modal-body {
        padding: 20px;
    }
}

/* ==========================================================================
   Reduced Motion for Modal
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .azarx-modal-overlay,
    .azarx-modal-container {
        transition: none;
    }

    .azarx-modal-container::before {
        animation: none;
    }

    .azarx-modal-close:hover {
        transform: none;
    }
}

/* ==========================================================================
   Google Fonts
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

/* Center position - horizontally centered, vertically at bottom */
.azarx-widget-center {
    bottom: var(--azarx-widget-offset);
    left: 50%;
    transform: translateX(-50%);
    right: auto;
}
