:root {
    --primary: #9d8df1;
    --primary-light: #b8aff5;
    --accent: #f0e6ff;
    --bg-aura: #f9f7ff;
    --text-dark: #4a4a4a;
    --text-light: #ffffff;
    --shadow: 0 8px 30px rgba(157, 141, 241, 0.15);
    --glass: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background: linear-gradient(135deg, #fdfcfb 0%, #e2d1f9 100%);
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-dark);
    overflow: hidden;
}

#app {
    width: 100%;
    max-width: 480px;
    height: 100dvh; /* Cambiado de 90vh a 100dvh para aprovechar todo el espacio */
    background: var(--glass);
    backdrop-filter: blur(15px);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

@media (min-width: 500px) {
    #app {
        height: 95vh;
        border-radius: 32px;
        border: 1px solid var(--glass-border);
    }
}

header {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.7);
    border-bottom: 1px solid rgba(157, 141, 241, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    min-height: 80px;
    flex-shrink: 0;
}

.avatar {
    width: 60px !important;
    height: 60px !important;
    min-width: 60px;
    min-height: 60px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    box-shadow: 0 0 15px rgba(157, 141, 241, 0.3);
    object-fit: cover; /* MUY IMPORTANTE: Evita que la imagen se estire */
}

.status-info h2 {
    font-size: 1.1rem;
    color: var(--primary);
    font-weight: 700;
}

.status-info p {
    font-size: 0.75rem;
    color: #888;
}

/* Actions Bar */
#actions-bar {
    padding: 8px 15px;
    display: flex;
    gap: 10px;
    justify-content: flex-start;
    background: rgba(255, 255, 255, 0.3);
    overflow-x: auto;
    flex-shrink: 0;
}

.action-chip {
    padding: 6px 12px;
    border-radius: 20px;
    background: white;
    border: 1px solid rgba(157, 141, 241, 0.2);
    font-size: 0.8rem;
    color: var(--primary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s;
}

#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: rgba(239, 230, 255, 0.2);
}

#chat-container::-webkit-scrollbar { width: 4px; }
#chat-container::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 10px; }

.message {
    max-width: 85%;
    padding: 12px 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: fadeIn 0.3s ease-out;
}

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

.message.aura {
    align-self: flex-start;
    background: var(--accent);
    color: var(--text-dark);
    border-radius: 18px 18px 18px 2px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: var(--text-light);
    border-radius: 18px 18px 2px 18px;
    box-shadow: 0 4px 12px rgba(157, 141, 241, 0.2);
}

/* Input Area Optimizado para Tablet */
#input-area {
    padding: 15px 20px;
    padding-bottom: env(safe-area-inset-bottom, 15px);
    background: white;
    border-top: 1px solid rgba(157, 141, 241, 0.05);
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
}

.preview-bar {
    display: flex;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    overflow-x: auto;
    border-top: 1px solid #f0f0f0;
}

.preview-bar:empty {
    display: none;
}

.preview-item {
    position: relative;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.preview-item .remove-img {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #ff4d4d;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid white;
}

#message-input {
    flex: 1;
    padding: 14px 20px; /* Aumentado para mejor target táctil */
    border-radius: 28px;
    border: 1px solid rgba(157, 141, 241, 0.2);
    outline: none;
    background: #fdfbff;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

#message-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(157, 141, 241, 0.1);
}

.icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: #f0ecff;
    color: var(--primary);
    font-size: 1.2rem;
}

.icon-btn.send {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(157, 141, 241, 0.3);
}

.typing-animation {
    display: flex;
    gap: 4px;
    padding: 15px 20px !important;
}

.typing-animation span {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1.3s infinite;
}

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

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

/* El print-template no debe ocupar NADA en la pantalla normal */
#print-template {
    visibility: hidden;
    pointer-events: none;
}
