/* =============================================
   CHATTING CORNER RING ANIMATION SYSTEM
   Version: 2.0 | Detailed Implementation
   ============================================= */

/* Base Container Structure */
.ring-container {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    margin-right: 16px;
    perspective: 1000px;
    transform-style: preserve-3d;
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Ring Base Styles */
.ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    transform-style: preserve-3d;
    backface-visibility: hidden;
}

/* Outer Ring - Primary Animation */
.outer-ring {
    border: 3px solid transparent;
    border-top: 3px solid rgba(135, 203, 249, 0.95);
    border-right: 3px solid rgba(66, 133, 244, 0.9);
    border-bottom: 3px solid rgba(66, 133, 244, 0.7);
    border-left: 3px solid rgba(135, 203, 249, 0.8);
    animation: 
        spin 2.2s cubic-bezier(0.65, 0, 0.35, 1) infinite,
        pulse-glow 3s ease-in-out infinite alternate,
        depth-breathe 4s ease-in-out infinite;
    box-shadow: 
        0 0 20px rgba(66, 133, 244, 0.3),
        inset 0 0 15px rgba(135, 203, 249, 0.2);
    filter: drop-shadow(0 0 5px rgba(66, 133, 244, 0.4));
}

/* Inner Ring - Secondary Animation */
.inner-ring {
    width: 70%;
    height: 70%;
    top: 15%;
    left: 15%;
    border: 2.5px solid transparent;
    border-top: 2.5px solid rgba(133, 124, 255, 0.85);
    border-right: 2.5px solid rgba(66, 133, 244, 0.8);
    border-bottom: 2.5px solid rgba(133, 124, 255, 0.7);
    border-left: 2.5px solid rgba(66, 133, 244, 0.75);
    animation: 
        spin 1.8s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite reverse,
        inner-pulse 2.5s ease-in-out infinite alternate,
        depth-float 3.5s ease-in-out infinite;
    box-shadow: 
        0 0 15px rgba(133, 124, 255, 0.25),
        inset 0 0 10px rgba(66, 133, 244, 0.15);
    filter: drop-shadow(0 0 3px rgba(133, 124, 255, 0.3));
}

/* Liquid Fill Effect */
.ring-fill {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(
        135deg, 
        #87CBF9 0%, 
        #4285F4 40%, 
        #857CFF 70%, 
        #4285F4 100%
    );
    opacity: 0;
    transform: scale(0.95);
    transition: all 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 
        0 0 30px rgba(66, 133, 244, 0.5),
        inset 0 0 20px rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

/* Liquid Wave Animation (visible during fill) */
.ring-fill::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 70%
    );
    animation: liquid-wave 3s linear infinite;
    opacity: 0;
    transition: opacity 0.8s ease;
}

/* Center Text with Gradient Transparency */
.center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
    font-size: 9px;
    font-family: 'Segoe UI', 'Roboto', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255, 255, 255, 0.95);
    opacity: 0.9;
    width: 100%;
    text-align: center;
    line-height: 1.3;
    z-index: 10;
    text-shadow: 
        0 0 10px rgba(66, 133, 244, 0.6),
        0 0 20px rgba(135, 203, 249, 0.4),
        0 0 30px rgba(133, 124, 255, 0.3);
    background: linear-gradient(
        135deg,
        rgba(135, 203, 249, 0.9),
        rgba(66, 133, 244, 0.85),
        rgba(133, 124, 255, 0.9)
    );
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    padding: 2px;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============ ANIMATION KEYFRAMES ============ */

/* Primary Spinning Animation */
@keyframes spin {
    0% { 
        transform: rotate(0deg) scale(1) translateZ(0);
    }
    50% {
        transform: rotate(180deg) scale(1.02) translateZ(5px);
    }
    100% { 
        transform: rotate(360deg) scale(1) translateZ(0);
    }
}

/* Pulsing Glow Effect */
@keyframes pulse-glow {
    0% {
        box-shadow: 
            0 0 20px rgba(66, 133, 244, 0.3),
            inset 0 0 15px rgba(135, 203, 249, 0.2);
        filter: drop-shadow(0 0 5px rgba(66, 133, 244, 0.4));
    }
    100% {
        box-shadow: 
            0 0 30px rgba(66, 133, 244, 0.5),
            inset 0 0 25px rgba(135, 203, 249, 0.3);
        filter: drop-shadow(0 0 8px rgba(66, 133, 244, 0.6));
    }
}

/* Inner Ring Pulse */
@keyframes inner-pulse {
    0% {
        box-shadow: 
            0 0 15px rgba(133, 124, 255, 0.25),
            inset 0 0 10px rgba(66, 133, 244, 0.15);
        filter: drop-shadow(0 0 3px rgba(133, 124, 255, 0.3));
    }
    100% {
        box-shadow: 
            0 0 25px rgba(133, 124, 255, 0.35),
            inset 0 0 15px rgba(66, 133, 244, 0.25);
        filter: drop-shadow(0 0 5px rgba(133, 124, 255, 0.4));
    }
}

/* 3D Depth Breathing Effect */
@keyframes depth-breathe {
    0%, 100% {
        transform: rotate(0deg) translateZ(0) scale(1);
    }
    50% {
        transform: rotate(5deg) translateZ(3px) scale(1.03);
    }
}

/* Inner Ring Floating Effect */
@keyframes depth-float {
    0%, 100% {
        transform: rotate(0deg) translateZ(2px) scale(1);
    }
    50% {
        transform: rotate(-3deg) translateZ(5px) scale(1.02);
    }
}

/* Liquid Wave Animation */
@keyframes liquid-wave {
    0% {
        transform: rotate(0deg) translateX(-25%);
    }
    100% {
        transform: rotate(360deg) translateX(-25%);
    }
}

/* Fill Transition Animation */
@keyframes fill-expand {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Text Focus Animation */
@keyframes text-focus {
    0% {
        opacity: 0.7;
        transform: translate(-50%, -50%) scale(0.95);
        text-shadow: 0 0 5px rgba(66, 133, 244, 0.4);
    }
    100% {
        opacity: 0.95;
        transform: translate(-50%, -50%) scale(1.05);
        text-shadow: 
            0 0 15px rgba(66, 133, 244, 0.8),
            0 0 25px rgba(135, 203, 249, 0.6);
    }
}

/* ============ STATE CLASSES ============ */

/* Loading State - Active Spinning */
.ring-loading .outer-ring,
.ring-loading .inner-ring {
    opacity: 1;
    visibility: visible;
    animation-play-state: running;
}

.ring-loading .ring-fill {
    opacity: 0;
    transform: scale(0.9);
}

.ring-loading .ring-fill::before {
    opacity: 0;
}

.ring-loading .center-text {
    animation: text-focus 2s ease-in-out infinite alternate;
    opacity: 0.85;
}

/* Completed State - Filled Circle */
.ring-completed .outer-ring,
.ring-completed .inner-ring {
    opacity: 0;
    visibility: hidden;
    animation-play-state: paused;
    transform: scale(1.1);
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ring-completed .ring-fill {
    opacity: 1;
    transform: scale(1);
    animation: fill-expand 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.ring-completed .ring-fill::before {
    opacity: 0.6;
}

.ring-completed .center-text {
    animation: none;
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(1.1);
    text-shadow: 
        0 0 20px rgba(66, 133, 244, 0.8),
        0 0 35px rgba(135, 203, 249, 0.6),
        0 0 45px rgba(133, 124, 255, 0.4);
}

/* Error State */
.ring-error .ring-fill {
    background: linear-gradient(
        135deg, 
        #ff6b6b 0%, 
        #ee5a52 40%, 
        #ff4757 70%, 
        #ee5a52 100%
    );
    box-shadow: 
        0 0 30px rgba(255, 107, 107, 0.5),
        inset 0 0 20px rgba(255, 255, 255, 0.3);
}

.ring-error .center-text {
    background: linear-gradient(
        135deg,
        #ff6b6b,
        #ee5a52,
        #ff4757
    );
    -webkit-background-clip: text;
    background-clip: text;
}

/* Hover Effects */
.ring-container:hover .center-text {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
    text-shadow: 
        0 0 25px rgba(66, 133, 244, 1),
        0 0 40px rgba(135, 203, 249, 0.8),
        0 0 55px rgba(133, 124, 255, 0.6);
}

.ring-container:hover .ring-fill {
    transform: scale(1.05);
    box-shadow: 
        0 0 40px rgba(66, 133, 244, 0.7),
        inset 0 0 25px rgba(255, 255, 255, 0.4);
}

/* Dark/Light Mode Support */
.dark-mode .center-text {
    opacity: 0.95;
}

.light-mode .center-text {
    opacity: 0.85;
    text-shadow: 
        0 0 8px rgba(66, 133, 244, 0.5),
        0 0 15px rgba(135, 203, 249, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .ring-container {
        width: 40px;
        height: 40px;
        margin-right: 12px;
    }
    
    .center-text {
        font-size: 7px;
        letter-spacing: 0.8px;
    }
    
    .outer-ring {
        border-width: 2.5px;
    }
    
    .inner-ring {
        border-width: 2px;
    }
}

@media (max-width: 480px) {
    .ring-container {
        width: 36px;
        height: 36px;
        margin-right: 10px;
    }
    
    .center-text {
        font-size: 6px;
        letter-spacing: 0.6px;
    }
}

/* High DPI Screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .ring-container {
        transform: translateZ(0);
        backface-visibility: hidden;
    }
    
    .ring {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .ring,
    .ring-fill::before,
    .center-text {
        animation: none !important;
        transition: opacity 0.3s ease !important;
    }
    
    .ring-loading .outer-ring,
    .ring-loading .inner-ring {
        animation: spin 4s linear infinite !important;
    }
}

/* Print Styles */
@media print {
    .ring-container {
        display: none !important;
    }
}
