/* Estilos base */
:root {
    --primary-color: #ff3a3a;
    --primary-dark: #cc0000;
    --secondary-color: #282828;
    --glow-color: rgba(255, 58, 58, 0.5);
    --text-color: #ffffff;
    --text-secondary: #aaaaaa;
    --bg-dark: #121212;
    --bg-card: #1e1e1e;
    --bg-message: #2a2a2a;
    --bg-user-message: #444;
    --accent-color: #ff5252;
    --magic-color-1: #ff42a1;
    --magic-color-2: #4e42ff;
    --magic-color-3: #42d6ff;
    --border-color: #333;
    --shadow-soft: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-glow: 0 0 12px 2px var(--primary-color), 0 0 24px 4px var(--glow-color);
    --user-avatar-gradient-1: #4e42ff;
    --user-avatar-gradient-2: #42d6ff;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-color);
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
}

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

.header {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: linear-gradient(135deg, var(--bg-card), var(--bg-dark));
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
}

h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-color);
    text-shadow: 0 0 10px var(--glow-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 5px;
}

h1 i {
    color: var(--primary-color);
    margin-right: 10px;
    filter: drop-shadow(0 0 5px var(--glow-color));
}

.sparkle {
    color: var(--magic-color-1);
    margin-left: 5px;
    animation: twinkle 2s infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.7; }
    100% { opacity: 1; text-shadow: 0 0 10px var(--magic-color-1), 0 0 20px var(--magic-color-1); }
}

.subtitle {
    font-size: 14px;
    color: #aaaaaa;
    margin-bottom: 10px;
}

/* Contenedor del chat */
.chat-container {
    background: var(--bg-card);
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 600px;
}

/* Historial de chat */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: var(--bg-card);
    scroll-behavior: smooth;
}

/* Animaciones para los mensajes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    animation: fadeInUp 0.3s ease-out;
    display: flex;
    gap: 10px;
    max-width: 85%;
}

.message.bot {
    align-self: flex-start;
    animation: fadeInUp 0.4s ease-out, float 5s ease-in-out infinite alternate;
    transform-origin: left center;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message.user .avatar {
    background: linear-gradient(135deg, var(--user-avatar-gradient-1), var(--user-avatar-gradient-2));
    color: #fff;
    box-shadow: 0 0 10px rgba(66, 214, 255, 0.6);
    position: relative;
    overflow: hidden;
    animation: avatarPulse 2s infinite alternate;
}

.message.user .avatar i {
    font-size: 20px;
    position: relative;
    z-index: 2;
    animation: bounce 2s ease infinite;
}

.message.user .avatar::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    opacity: 0;
    animation: avatarGlow 3s infinite;
}

@keyframes avatarPulse {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.05);
    }
}

@keyframes avatarGlow {
    0% {
        opacity: 0;
        transform: rotate(0deg);
    }
    50% {
        opacity: 0.8;
    }
    100% {
        opacity: 0;
        transform: rotate(360deg);
    }
}

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

.message.bot .avatar {
    background: linear-gradient(135deg, var(--primary-color), #b30000);
    color: white;
}

.bubble {
    padding: 12px 16px;
    border-radius: 18px;
    background-color: #333;
    color: white;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    box-shadow: var(--shadow-soft);
    word-break: break-word;
}

.message.user .bubble {
    background-color: var(--bg-user-message);
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-soft);
}

.message.bot .bubble {
    background-color: var(--bg-message);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-soft);
    border-left: 3px solid var(--primary-color);
}

/* Estilos para código y markdown dentro de las burbujas */
.bubble pre {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 8px 0;
    border-left: 3px solid var(--accent-color);
}

.bubble code {
    font-family: 'Consolas', 'Monaco', monospace;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.9em;
}

.bubble pre code {
    background-color: transparent;
    padding: 0;
}

.bubble p {
    margin: 8px 0;
}

.bubble p:first-child {
    margin-top: 0;
}

.bubble p:last-child {
    margin-bottom: 0;
}

.bubble ul, .bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.bubble a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px dotted;
}

.bubble a:hover {
    border-bottom: 1px solid;
    opacity: 0.8;
}

.bubble blockquote {
    border-left: 3px solid var(--accent-color);
    margin: 8px 0;
    padding-left: 10px;
    color: var(--text-secondary);
}

/* Área de input mejorada */
.chat-input-area {
    display: flex;
    padding: 15px;
    background-color: rgba(26, 26, 26, 0.9);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    gap: 12px;
    align-items: flex-end;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

#chatInput {
    flex: 1;
    padding: 14px 20px;
    border-radius: 25px;
    border: 2px solid var(--border-color);
    background-color: rgba(51, 51, 51, 0.8);
    color: white;
    font-size: 15px;
    resize: none;
    outline: none;
    transition: all 0.3s ease;
    min-height: 44px;
    max-height: 100px;
    box-sizing: border-box;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}

#chatInput:focus {
    border-color: var(--primary-color);
    background-color: rgba(51, 51, 51, 1);
    box-shadow: 0 0 10px var(--glow-color);
}

/* Mejorar la experiencia móvil */
@media (max-width: 600px) {
    .container {
        margin: 0;
        padding: 10px;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    .chat-container {
        flex: 1;
        height: auto;
        border-radius: 8px;
    }
    
    .header {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .subtitle {
        font-size: 12px;
    }
    
    .chat-history {
        padding: 15px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .bubble {
        padding: 10px 14px;
        font-size: 14px;
    }
}

.avatar.github-bot {
    background: linear-gradient(135deg, #2b3137, #24292e);
    color: #fff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    border: 2px solid #f6f8fa;
    animation: githubPulse 3s infinite alternate;
}

.avatar.github-bot i {
    font-size: 22px;
    position: relative;
    z-index: 2;
    animation: scaleGithub 2s ease infinite;
    color: #f6f8fa;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

@keyframes githubPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
    }
    100% {
        transform: scale(1.05);
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
    }
}

@keyframes scaleGithub {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.avatar.github-bot::before {
    content: '';
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(246, 248, 250, 0.2) 0%, transparent 70%);
    opacity: 0;
    animation: githubShine 4s infinite;
    transform-origin: center center;
}

@keyframes githubShine {
    0% {
        opacity: 0;
        transform: rotate(0deg);
    }
    30% {
        opacity: 0.8;
    }
    70% {
        opacity: 0.5;
    }
    100% {
        opacity: 0;
        transform: rotate(360deg);
    }
}

.avatar.ollama-bot {
    background: linear-gradient(135deg, #ff9a00, #ff4e00);
    color: #fff;
    box-shadow: 0 0 10px rgba(255, 154, 0, 0.6);
    position: relative;
    overflow: hidden;
    border: 2px solid #fff3e6;
    animation: ollamaPulse 3s infinite alternate;
}

.avatar.ollama-bot span {
    position: relative;
    z-index: 2;
    animation: bounce 2s ease infinite;
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.7));
}

@keyframes ollamaPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 5px rgba(255, 154, 0, 0.4);
    }
    100% {
        transform: scale(1.05);
        box-shadow: 0 0 15px rgba(255, 154, 0, 0.7);
    }
}

.avatar.ollama-bot::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    opacity: 0;
    animation: ollamaGlow 4s infinite;
}

@keyframes ollamaGlow {
    0% {
        opacity: 0;
        transform: rotate(0deg);
    }
    25% {
        opacity: 0.8;
    }
    75% {
        opacity: 0.4;
    }
    100% {
        opacity: 0;
        transform: rotate(360deg);
    }
}

/* Animación de carga (tres puntos) */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
}

.typing-indicator span {
  height: 8px;
  width: 8px;
  float: left;
  margin: 0 2px;
  background-color: #9E9EA1;
  display: block;
  border-radius: 50%;
  opacity: 0.4;
}

.typing-indicator span:nth-of-type(1) {
  animation: 1s bouncing infinite;
}

.typing-indicator span:nth-of-type(2) {
  animation: 1s bouncing infinite .33s;
}

.typing-indicator span:nth-of-type(3) {
  animation: 1s bouncing infinite .66s;
}

@keyframes bouncing {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes float {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-3px);
    }
}

/* Botón de envío mejorado */
.magic-btn {
    padding: 12px 20px;
    border-radius: 30px;
    border: none;
    background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
    color: white;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 100px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(255, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.magic-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transform: rotate(45deg);
    transition: all 0.5s;
    opacity: 0;
}

.magic-btn:hover::before {
    animation: shine 1.5s ease-in-out;
}

@keyframes shine {
    0% {
        left: -50%;
        opacity: 0;
    }
    50% {
        opacity: 0.7;
    }
    100% {
        left: 150%;
        opacity: 0;
    }
}

.magic-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 0, 0, 0.3);
}

.magic-btn i {
    font-size: 16px;
}

/* Estilos para los botones de modo */
#modeSelector {
    background-color: #222;
    padding: 3px;
    border-radius: 20px;
    display: flex;
    margin-right: 5px;
}

.mode-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #2a2a2a;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mode-btn.selected {
    background: linear-gradient(135deg, var(--magic-color-2), var(--magic-color-3));
    color: white;
    box-shadow: 0 0 10px rgba(66, 214, 255, 0.5);
}

.mode-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 8px rgba(66, 214, 255, 0.4);
}

.mode-btn.selected:hover {
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(66, 214, 255, 0.6);
}

/* Animación para los botones del selector de modo */
.mode-btn i, .mode-btn span {
    transition: transform 0.3s ease;
}

.mode-btn:hover i, .mode-btn:hover span {
    transform: scale(1.2);
}

.mode-btn.selected i, .mode-btn.selected span {
    animation: pulse 2s infinite alternate;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.15);
    }
}

.avatar-shine {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    opacity: 0;
    animation: shineEffect 3s infinite;
    transform: translateX(-100%);
    pointer-events: none;
}

@keyframes shineEffect {
    0% {
        transform: translateX(-100%);
        opacity: 0;
    }
    20% {
        opacity: 0.8;
    }
    40% {
        transform: translateX(100%);
        opacity: 0;
    }
    100% {
        transform: translateX(100%);
        opacity: 0;
    }
}
