/* ChatBot Latino - Estilos Galácticos Suaves */

:root {
    /* Colores principales galácticos */
    --primary-blue: #4F46E5;
    --secondary-blue: #06B6D4;
    --deep-space: #0F172A;
    --nebula-purple: #7C3AED;
    --cosmic-cyan: #22D3EE;
    --starlight: #F8FAFC;
    --galaxy-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --space-gradient: linear-gradient(45deg, #0F172A 0%, #1E293B 50%, #334155 100%);
    
    /* Colores funcionales */
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --text-primary: #F8FAFC;
    --text-secondary: #CBD5E1;
    --text-muted: #94A3B8;
    
    /* Espaciado */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Bordes y sombras */
    --border-radius: 0.75rem;
    --border-radius-lg: 1rem;
    --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.3);
    --shadow-cosmic: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-nebula: 0 4px 16px rgba(124, 58, 237, 0.2);
}

/* Reset y base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--space-gradient);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

/* Fondo estrellado animado */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 160px 30px, rgba(255,255,255,0.2), transparent);
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: twinkle 20s linear infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Contenedor principal */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    backdrop-filter: blur(10px);
}

/* Header */
.chat-header {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(79, 70, 229, 0.2);
    padding: var(--spacing-md);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-cosmic);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo {
    width: 50px;
    height: 50px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-glow);
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.1) rotate(5deg);
}

.brand-info h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--galaxy-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.875rem;
    color: var(--success);
}

.status-indicator i {
    animation: pulse 2s infinite;
}

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

.header-controls {
    display: flex;
    gap: var(--spacing-sm);
}

.control-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--border-radius);
    background: rgba(79, 70, 229, 0.2);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: var(--primary-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 100px);
    position: relative;
}

.chat-messages {
    flex: 1;
    padding: var(--spacing-lg);
    overflow-y: auto;
    scroll-behavior: smooth;
    position: relative;
}

/* Loading Animation */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    text-align: center;
}

.galaxy-loader {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: var(--spacing-lg);
}

.planet {
    width: 40px;
    height: 40px;
    background: var(--galaxy-gradient);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 
        0 0 20px rgba(79, 70, 229, 0.5),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
    animation: planetRotate 4s linear infinite;
}

.orbit {
    width: 80px;
    height: 80px;
    border: 2px solid rgba(79, 70, 229, 0.3);
    border-radius: 50%;
    position: absolute;
    animation: orbitRotate 3s linear infinite;
}

.satellite {
    width: 8px;
    height: 8px;
    background: var(--cosmic-cyan);
    border-radius: 50%;
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 10px var(--cosmic-cyan);
}

@keyframes planetRotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes orbitRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Messages */
.message {
    margin-bottom: var(--spacing-lg);
    display: flex;
    animation: messageSlideIn 0.5s ease-out;
}

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

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

.message.bot {
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: var(--spacing-md);
    border-radius: var(--border-radius-lg);
    position: relative;
    word-wrap: break-word;
}

.message.user .message-content {
    background: var(--galaxy-gradient);
    color: white;
    border-bottom-right-radius: var(--spacing-xs);
}

.message.bot .message-content {
    background: rgba(30, 41, 59, 0.8);
    color: var(--text-primary);
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-bottom-left-radius: var(--spacing-xs);
    box-shadow: var(--shadow-nebula);
}

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    margin: 0 var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--galaxy-gradient);
    order: 2;
}

.message.bot .message-avatar {
    background: rgba(79, 70, 229, 0.3);
    border: 2px solid var(--primary-blue);
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--spacing-xs);
    text-align: center;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-md);
    color: var(--text-secondary);
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--secondary-blue);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Input Area */
.input-area {
    padding: var(--spacing-lg);
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(79, 70, 229, 0.2);
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    background: rgba(30, 41, 59, 0.8);
    border: 2px solid rgba(79, 70, 229, 0.3);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-sm);
    transition: border-color 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary-blue);
    box-shadow: var(--shadow-glow);
}

#messageInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    padding: var(--spacing-sm);
    outline: none;
    font-family: inherit;
}

#messageInput::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 45px;
    height: 45px;
    border: none;
    border-radius: var(--border-radius);
    background: var(--galaxy-gradient);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--spacing-sm);
}

.character-count {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.quick-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.quick-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-radius: var(--border-radius);
    background: rgba(79, 70, 229, 0.1);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.quick-btn:hover {
    background: rgba(79, 70, 229, 0.3);
    color: var(--text-primary);
    transform: translateY(-1px);
}

/* Session Panel */
.session-panel {
    position: fixed;
    top: 0;
    right: -350px;
    width: 350px;
    height: 100vh;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(79, 70, 229, 0.3);
    transition: right 0.3s ease;
    z-index: 200;
    display: flex;
    flex-direction: column;
}

.session-panel.open {
    right: 0;
    box-shadow: var(--shadow-cosmic);
}

.panel-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid rgba(79, 70, 229, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--text-primary);
}

.close-panel-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
}

.close-panel-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
}

.session-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.session-item {
    padding: var(--spacing-md);
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(79, 70, 229, 0.2);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
}

.session-item:hover {
    background: rgba(79, 70, 229, 0.2);
    border-color: var(--primary-blue);
    transform: translateY(-1px);
}

.session-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.session-preview {
    font-size: 0.875rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Floating Button */
.floating-btn {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: var(--galaxy-gradient);
    color: white;
    cursor: pointer;
    box-shadow: var(--shadow-cosmic);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    z-index: 150;
}

.floating-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(79, 70, 229, 0.4);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.toast {
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    color: white;
    min-width: 300px;
    box-shadow: var(--shadow-cosmic);
    animation: toastSlideIn 0.3s ease-out;
    position: relative;
    overflow: hidden;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--secondary-blue); }

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Voice Controls */
.voice-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.voice-btn {
    width: 35px;
    height: 35px;
    border: none;
    border-radius: 50%;
    background: rgba(34, 211, 238, 0.2);
    color: var(--cosmic-cyan);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-btn:hover {
    background: var(--cosmic-cyan);
    color: white;
    transform: scale(1.05);
}

.voice-btn.active {
    background: var(--cosmic-cyan);
    color: white;
    animation: voicePulse 1s infinite;
}

@keyframes voicePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.7); }
    50% { box-shadow: 0 0 0 10px rgba(34, 211, 238, 0); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        min-height: 100vh;
    }
    
    .header-content {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
    
    .logo {
        width: 40px;
        height: 40px;
    }
    
    .brand-info h1 {
        font-size: 1.25rem;
    }
    
    .chat-messages {
        padding: var(--spacing-md);
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .input-area {
        padding: var(--spacing-md);
    }
    
    .quick-actions {
        flex-wrap: wrap;
    }
    
    .session-panel {
        width: 100%;
        right: -100%;
    }
    
    .floating-btn {
        bottom: 80px;
        right: 15px;
        width: 50px;
        height: 50px;
    }
    
    .toast-container {
        right: 10px;
        left: 10px;
    }
    
    .toast {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .brand-info h1 {
        font-size: 1rem;
    }
    
    .header-controls {
        gap: var(--spacing-xs);
    }
    
    .control-btn {
        width: 35px;
        height: 35px;
    }
    
    .message-content {
        max-width: 90%;
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .loading-container {
        height: 50vh;
    }
    
    .galaxy-loader {
        width: 60px;
        height: 60px;
    }
    
    .planet {
        width: 30px;
        height: 30px;
    }
    
    .orbit {
        width: 60px;
        height: 60px;
    }
}

/* Animaciones adicionales */
@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

.gradient-text {
    background: var(--galaxy-gradient);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease infinite;
}

/* Estados de carga */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading .send-btn {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Efectos hover mejorados */
.message-content:hover {
    transform: translateY(-1px);
    transition: transform 0.2s ease;
}

.control-btn:active {
    transform: translateY(0) scale(0.95);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

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

.chat-messages::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.3);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(79, 70, 229, 0.5);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(79, 70, 229, 0.7);
}

/* Mejoras de accesibilidad */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Estados de focus mejorados */
button:focus,
input:focus {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* Transiciones suaves para todos los elementos interactivos */
button, input, .message-content, .session-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
