/**
 * Ricky Chat Styles
 * Child-friendly, colorful design for RORK TV
 */

/* Main Widget Container */
#ricky-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Comic Sans MS', sans-serif;
}

/* Chat Toggle Button */
.ricky-chat-toggle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6B6B 0%, #4ECDC4 50%, #45B7D1 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    position: relative;
    border: 3px solid #fff;
    animation: gentle-bounce 2s infinite ease-in-out;
}

@keyframes gentle-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.ricky-chat-toggle:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    animation: none;
}

/* Ricky Avatar */
.ricky-avatar {
    width: 45px;
    height: 45px;
}

.ricky-face {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 50%;
    position: relative;
    border: 3px solid #FFA500;
    box-shadow: 0 2px 10px rgba(255, 165, 0, 0.3);
    animation: ricky-float 3s ease-in-out infinite;
}

.ricky-face.small {
    width: 35px;
    height: 35px;
    border-width: 2px;
}

.ricky-face.tiny {
    width: 25px;
    height: 25px;
    border-width: 2px;
}

/* Floating animation for Ricky */
@keyframes ricky-float {
    0%, 100% { 
        transform: translateY(0) scale(1);
        box-shadow: 0 2px 10px rgba(255, 165, 0, 0.3);
    }
    50% { 
        transform: translateY(-3px) scale(1.05);
        box-shadow: 0 6px 20px rgba(255, 165, 0, 0.4);
    }
}

/* Pulse animation for interaction */
.ricky-face.pulse {
    animation: ricky-pulse 0.6s ease-in-out;
}

@keyframes ricky-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Excited animation */
.ricky-face.excited {
    animation: ricky-excited 1s ease-in-out infinite;
}

@keyframes ricky-excited {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-5deg) scale(1.1); }
    75% { transform: rotate(5deg) scale(1.1); }
}

/* Remove old eye and mouth styles as we're using the image now */
.ricky-eyes, .eye, .ricky-mouth {
    display: none;
}

/* Speech Bubble */
.ricky-speech-bubble {
    position: absolute;
    bottom: 75px;
    right: -10px;
    background: linear-gradient(135deg, #FFE4E1, #E0F6FF);
    padding: 8px 12px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    font-size: 12px;
    color: #333;
    font-weight: bold;
    white-space: nowrap;
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s ease;
    pointer-events: none;
    border: 2px solid #FFB6C1;
    animation: bubble-entrance 2s ease-out, bubble-pulse 4s ease-in-out 2s infinite;
    z-index: 1001; /* Ensure bubble appears above other elements */
}

.ricky-speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 7px solid #FFE4E1;
}

/* Bubble is now always visible, but add extra glow on hover */
.ricky-chat-toggle:hover .ricky-speech-bubble {
    box-shadow: 0 6px 20px rgba(255, 182, 193, 0.4);
    transform: translateY(-2px) scale(1.02);
}

/* Chat Window */
.ricky-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    max-height: 500px;
    background: linear-gradient(135deg, #fff 0%, #f8f9ff 100%);
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 3px solid #E6E6FA;
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    transition: all 0.3s ease;
}

.ricky-chat-window.open {
    display: flex;
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Chat Header */
.ricky-chat-header {
    background: linear-gradient(135deg, #FF6B6B 0%, #4ECDC4 50%, #45B7D1 100%);
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    border-radius: 17px 17px 0 0;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.ricky-header-avatar {
    flex-shrink: 0;
}

.ricky-header-info {
    flex: 1;
}

.ricky-header-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
}

.ricky-status {
    font-size: 12px;
    opacity: 0.9;
}

.ricky-header-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.ricky-new-chat-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 35px;
    height: 30px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-weight: bold;
}

.ricky-new-chat-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

.ricky-chat-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ricky-chat-close:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

/* Messages Area */
.ricky-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: linear-gradient(135deg, #fff 0%, #f8f9ff 100%);
    min-height: 0; /* Important for flexbox scrolling */
    max-height: 320px; /* Ensure it doesn't exceed available space */
}

/* Message Styles */
.ricky-message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: message-appear 0.3s ease;
}

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

.user-message {
    justify-content: flex-end;
}

.ricky-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.ricky-message .ricky-message-content {
    background: linear-gradient(135deg, #E1F5FE, #F3E5F5);
    color: #333;
    border: 2px solid #B39DDB;
    border-radius: 18px 18px 18px 4px;
}

.user-message .ricky-message-content {
    background: linear-gradient(135deg, #4ECDC4, #45B7D1);
    color: white;
    border: 2px solid #40E0D0;
    border-radius: 18px 18px 4px 18px;
}

.message-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
}

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

/* Avatar in messages */
.ricky-avatar-small {
    flex-shrink: 0;
    margin-top: 5px;
}

/* Typing Indicator */
.ricky-typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(255,255,255,0.8);
    border-top: 1px solid #E0E0E0;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666;
}

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

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

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

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

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Input Area */
.ricky-chat-input-area {
    background: linear-gradient(135deg, #fff 0%, #f8f9ff 100%);
    border-top: 2px solid #E6E6FA;
    padding: 15px;
    flex-shrink: 0; /* Prevent input area from shrinking */
}

/* Make sure the input area is visible */
.ricky-chat-window.open .ricky-chat-input-area {
    display: block;
}

.ricky-chat-form {
    margin-bottom: 10px;
}

.input-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.ricky-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #E0E0E0;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    background: white;
}

.ricky-chat-input:focus {
    border-color: #4ECDC4;
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.1);
}

.ricky-send-button {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4ECDC4, #45B7D1);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px rgba(78, 205, 196, 0.3);
}

.ricky-send-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
}

.ricky-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Quick Questions */
.ricky-quick-questions {
    margin-top: 10px;
    transition: all 0.3s ease;
    max-height: 200px;
    overflow: visible;
    background: rgba(255, 255, 255, 0.5);
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(230, 230, 250, 0.8);
}

.ricky-quick-questions.hidden {
    opacity: 0;
    max-height: 0;
    margin-top: 0;
    padding: 0;
    overflow: hidden;
}

.quick-question-label {
    font-size: 12px;
    color: #333;
    margin-bottom: 8px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

.quick-questions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: auto;
    justify-content: flex-start;
    align-items: flex-start;
}

/* Ensure quick questions area is visible in open chat (only when not hidden) */
.ricky-chat-window.open .ricky-quick-questions:not(.hidden) {
    display: block;
    opacity: 1;
}

.quick-question-btn {
    background: linear-gradient(135deg, #4ECDC4, #45B7D1);
    border: 2px solid #40E0D0;
    padding: 8px 12px;
    border-radius: 15px;
    font-size: 11px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    box-shadow: 0 2px 5px rgba(78, 205, 196, 0.3);
    flex: 0 1 auto;
    white-space: nowrap;
    min-width: 0;
}

.quick-question-btn:hover {
    background: linear-gradient(135deg, #FF6B6B, #FFA500);
    border-color: #FF69B4;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

/* Scrollbar Styling */
.ricky-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ricky-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.ricky-chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #4ECDC4, #45B7D1);
    border-radius: 3px;
}

.ricky-chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #45B7D1, #4ECDC4);
}

/* Mobile Responsive */
@media (max-width: 400px) {
    #ricky-chat-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .ricky-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        right: -10px;
        bottom: 70px;
    }
    
    .ricky-chat-toggle {
        width: 60px;
        height: 60px;
    }
    
    .ricky-avatar {
        width: 35px;
        height: 35px;
    }
}

/* Animated emoji circle before start */
.ricky-emoji-circle {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 25px;
    height: 25px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    animation: emoji-bounce 2s ease-in-out infinite;
    box-shadow: 0 2px 10px rgba(255, 215, 0, 0.4);
    border: 2px solid white;
}

@keyframes emoji-bounce {
    0%, 100% { 
        transform: translateY(0) rotate(0deg) scale(1);
    }
    25% { 
        transform: translateY(-5px) rotate(5deg) scale(1.1);
    }
    50% { 
        transform: translateY(-10px) rotate(0deg) scale(1.2);
    }
    75% { 
        transform: translateY(-5px) rotate(-5deg) scale(1.1);
    }
}

/* Speech bubble entrance animation */
@keyframes bubble-entrance {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }
    60% {
        transform: translateY(-5px) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Speech bubble gentle pulse animation */
@keyframes bubble-pulse {
    0%, 100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    }
    50% {
        transform: translateY(-2px) scale(1.02);
        box-shadow: 0 6px 20px rgba(255, 182, 193, 0.3);
    }
}

/* Fun animations */
@keyframes rainbow-border {
    0% { border-color: #FF6B6B; }
    25% { border-color: #4ECDC4; }
    50% { border-color: #45B7D1; }
    75% { border-color: #96CEB4; }
    100% { border-color: #FF6B6B; }
}

.ricky-chat-window.rainbow-mode {
    animation: rainbow-border 3s infinite;
}

/* Welcome message special styling */
.welcome-message .ricky-message-content {
    background: linear-gradient(135deg, #FFE4E1, #E0F6FF, #F0FFF0);
    border: 3px solid #FFB6C1;
    font-weight: bold;
    position: relative;
    overflow: hidden;
}

.welcome-message .ricky-message-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: welcome-shine 2s infinite;
}

@keyframes welcome-shine {
    0% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
    }
    100% {
        transform: translateX(100%) translateY(100%) rotate(45deg);
    }
}