* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0f0f13;
    --surface: #1a1a24;
    --surface2: #22222f;
    --primary: #6c5ce7;
    --primary-hover: #7f71ed;
    --text: #e8e8ed;
    --text-dim: #8888a0;
    --user-bg: #6c5ce7;
    --bot-bg: #22222f;
    --danger: #e74c3c;
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100dvh;
    overflow: hidden;
}

.screen { display: none; }
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ====== LOGIN ====== */
#login-screen {
    height: 100dvh;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
}

.login-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 2.5rem;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.logo {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.logo h1 {
    font-size: 1.8rem;
    margin-bottom: 0.3rem;
}

.logo p {
    color: var(--text-dim);
    font-size: 0.9rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.input-group input {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--surface2);
    border: 2px solid transparent;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--primary);
}

.error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

#btn-entrar {
    width: 100%;
    padding: 0.85rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#btn-entrar:hover {
    background: var(--primary-hover);
}

#btn-entrar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ====== CHAT ====== */
#chat-screen {
    flex-direction: column;
    height: 100dvh;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.2rem;
    background: var(--surface);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.header-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.chat-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.btn-salir {
    padding: 0.4rem 1rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-dim);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-salir:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ====== MENSAJES ====== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.message {
    max-width: 80%;
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    line-height: 1.5;
    font-size: 0.95rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    animation: fadeIn 0.2s ease;
}

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

.message.user {
    background: var(--user-bg);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    background: var(--bot-bg);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.assistant .bold {
    font-weight: 600;
}

.msg-time {
    display: block;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.35);
    margin-top: 0.4rem;
    text-align: right;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 1rem;
    align-self: flex-start;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-dim);
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}

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

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ====== INPUT AREA ====== */
.chat-input-area {
    padding: 0.8rem 1.2rem 1rem;
    background: var(--surface);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    background: var(--surface2);
    border-radius: var(--radius);
    padding: 0.5rem 0.6rem 0.5rem 1rem;
}

.input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.4;
    padding: 0.3rem 0;
}

#btn-enviar {
    width: 38px;
    height: 38px;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

#btn-enviar:hover {
    background: var(--primary-hover);
}

#btn-enviar:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ====== RESPONSIVO ====== */
@media (max-width: 600px) {
    .login-card { padding: 1.8rem; }
    .message { max-width: 90%; }
    .chat-header h2 { font-size: 0.9rem; }
}
