/* ========================================
   Mundo Móvil – Chatbot Styles
   Mobile-first, tema rojo/negro/blanco
   ======================================== */

:root {
    --red: #D42B2B;
    --red-dark: #B71C1C;
    --black: #1a1a1a;
    --white: #ffffff;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --whatsapp: #25D366;
    --whatsapp-dark: #1da851;
    --radius: 18px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--gray-100);
    color: var(--black);
    overflow: hidden;
}

/* ── Layout (ancho completo con margen pequeño) ── */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    margin: 0 6px;
    background: var(--white);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* ── Header (blanco para que el logo se vea bien) ── */
.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--white);
    border-bottom: 2px solid var(--red);
    flex-shrink: 0;
}

.chat-header .logo {
    height: 40px;
    width: auto;
    flex-shrink: 0;
}

.chat-header .info h1 {
    font-size: 16px;
    font-weight: 700;
    color: var(--black);
    line-height: 1.2;
}

.chat-header .info p {
    font-size: 12px;
    color: var(--red);
    font-weight: 500;
}

/* ── Hidden utility ── */
.hidden {
    display: none !important;
}

/* ── Welcome screen ── */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    text-align: center;
    background: var(--white);
}

.welcome-screen .welcome-logo {
    width: 200px;
    height: auto;
    margin-bottom: 24px;
}

.welcome-screen h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--black);
    margin-bottom: 8px;
}

.welcome-screen p {
    font-size: 14px;
    color: var(--gray-600);
    margin-bottom: 32px;
}

.btn-start {
    padding: 14px 40px;
    background: var(--red);
    color: var(--white);
    border: none;
    border-radius: 28px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-start:hover {
    background: var(--red-dark);
}

.btn-start:active {
    transform: scale(0.97);
}

/* ── Messages area ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--gray-100);
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 2px;
}

/* ── Message bubbles ── */
.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius);
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
    animation: fadeIn 0.2s ease;
}

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

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

.message.bot {
    align-self: flex-start;
    background: var(--white);
    color: var(--black);
    border: 1px solid var(--gray-200);
    border-bottom-left-radius: 4px;
}

/* Markdown dentro de burbujas */
.message strong, .message b {
    font-weight: 600;
}

.message ul, .message ol {
    padding-left: 18px;
    margin: 4px 0;
}

.message li {
    margin-bottom: 2px;
}

.message p {
    margin-bottom: 6px;
}

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

/* ── Typing indicator ── */
.typing-indicator {
    align-self: flex-start;
    display: none;
    padding: 12px 18px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    border-bottom-left-radius: 4px;
}

.typing-indicator.visible {
    display: flex;
    gap: 4px;
    align-items: center;
}

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

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

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30%           { transform: translateY(-6px); opacity: 1; }
}

/* ── WhatsApp Button ── */
.whatsapp-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 12px 20px;
    background: var(--whatsapp);
    color: var(--white);
    border: none;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.whatsapp-btn:hover {
    background: var(--whatsapp-dark);
}

.whatsapp-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* ── File attached badge ── */
.file-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(212, 43, 43, 0.15);
    color: var(--red-dark);
    border-radius: 12px;
    font-size: 13px;
    margin-top: 4px;
}

/* ── Input area ── */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: var(--white);
    border-top: 1px solid var(--gray-300);
    flex-shrink: 0;
}

.chat-input-area textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--gray-300);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: var(--font);
    line-height: 1.4;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area textarea:focus {
    border-color: var(--red);
}

.chat-input-area textarea::placeholder {
    color: var(--gray-500);
}

/* ── Buttons (attach & send) ── */
.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.btn-attach {
    background: transparent;
    color: var(--gray-600);
}

.btn-attach:hover {
    background: var(--gray-100);
    color: var(--red);
}

.btn-send {
    background: var(--red);
    color: var(--white);
}

.btn-send:hover {
    background: var(--red-dark);
}

.btn-send:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.btn-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Hidden file input */
#fileInput {
    display: none;
}

/* ── Upload progress ── */
.upload-preview {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-300);
    font-size: 13px;
    color: var(--gray-600);
}

.upload-preview.visible {
    display: flex;
}

.upload-preview .filename {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-preview .remove-file {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 2px 6px;
}

/* ── Error toast ── */
.error-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--red);
    color: var(--white);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    max-width: 90%;
    text-align: center;
}

/* ── Desktop ── */
@media (min-width: 501px) {
    .chat-container {
        margin: 0 12px;
    }
}
