/* ── FONTES ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Special+Elite&family=Courier+Prime:ital,wght@0,400;0,700;1,400&display=swap');

/* ── VARIÁVEIS ──────────────────────────────────────────────────────── */
:root {
    --paper:      #f0e8d0;
    --paper-dark: #e0d0a8;
    --paper-aged: #d4c08a;
    --ink:        #1a1208;
    --ink-faded:  #4a3820;
    --ink-rust:   #6b2a0a;
    --machine:    #2a2018;
    --machine-mid:#3a3020;
    --chrome:     #8a7a60;
    --red-key:    #8b1a00;
    --shadow:     rgba(10, 5, 0, 0.55);
    --font-type:  'Special Elite', cursive;
    --font-body:  'Courier Prime', 'Courier New', monospace;
}

/* ── RESET & BASE ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: #1a1208;
    font-family: var(--font-body);
    display: flex;
    justify-content: center;
    align-items: stretch;        /* era flex-start */
    height: 100vh;               /* ocupa exatamente a viewport */
    overflow: hidden;            /* sem scroll na página */
    padding: 0;                  /* era 2rem 1rem 3rem */
    color: var(--ink);
    position: relative;
}

/* Overlay escuro sobre fundo.png */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(10, 6, 2, 0.55);
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 700px;
    background-color: transparent;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 0;
    border: 3px solid #4a3a28;
    box-shadow:
        0 0 0 1px #1a1008,
        0 12px 60px rgba(0,0,0,0.8),
        inset 0 1px 0 rgba(255,255,255,0.05);
    overflow: hidden;
    /* ── layout flex vertical ── */
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
}

/* ── CABEÇALHO ──────────────────────────────────────────────────────── */
.header-card {
    flex-shrink: 0;
    background: transparent;
    padding: 0;
    border-bottom: 3px solid #1a1008;
    overflow: hidden;
    line-height: 0;
}

.header-card img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    object-position: center top;
    max-height: 130px;
}



/* ── ÁREA DE CHAT — O PAPEL ─────────────────────────────────────────── */
.chat-area {
    flex: 1 1 auto;
    min-height: 0;
    background: transparent;
    overflow-y: auto;
    padding: 1.4rem 1.8rem 1.4rem 3.5rem;
    scroll-behavior: smooth;
    border-bottom: 2px solid #3a2a10;
    position: relative;
    border-left: 14px solid #2a2018;
    border-right: 14px solid #2a2018;
    box-shadow:
        inset 6px 0 10px rgba(0,0,0,0.5),
        inset -6px 0 10px rgba(0,0,0,0.5);
}

/* Scrollbar estilo máquina */
.chat-area::-webkit-scrollbar { width: 6px; }
.chat-area::-webkit-scrollbar-track { background: var(--paper-dark); }
.chat-area::-webkit-scrollbar-thumb { background: var(--chrome); border-radius: 0; }

/* Buracos do papel — margem esquerda */
.chat-area::before {
    content: '○\A○\A○\A○\A○\A○\A○\A○\A○\A○\A○';
    white-space: pre;
    position: absolute;
    left: 14px;
    top: 1.8rem;
    font-size: 10px;
    line-height: 28px;
    color: rgba(100,70,30,0.35);
    pointer-events: none;
}

.welcome-msg {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 0.9rem;
    color: var(--ink-faded);
    padding: 0.5rem 0;
    line-height: 1.8;
}

/* ── BLOCOS DE MENSAGEM ─────────────────────────────────────────────── */
.msg-block {
    margin-bottom: 1.4rem;
    animation: typeIn 0.15s ease-out;
}

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

.msg-user {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--ink);
    line-height: 1.65;
    border-left: 2px solid var(--ink-rust);
    padding-left: 0.8rem;
    margin-bottom: 0.9rem;
}

.msg-bot {
    font-family: var(--font-body);
    font-size: 0.92rem;
    color: var(--ink);
    line-height: 1.75;
    background: rgba(180,150,80,0.10);
    border-left: 2px solid var(--paper-aged);
    padding: 0.7rem 0.8rem;
    position: relative;
}

.msg-bot::before {
    content: attr(data-label);
    display: block;
    font-size: 0.68rem;
    font-family: var(--font-type);
    color: var(--chrome);
    letter-spacing: 0.15em;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
}

.msg-bot .signature {
    display: block;
    font-style: italic;
    color: var(--ink-rust);
    margin-top: 0.5rem;
    font-size: 0.88rem;
}

/* Botões de ação — discretos, inline */
.msg-actions {
    display: flex;
    gap: 1.4rem;
    margin-top: 0.5rem;
    padding-top: 0.4rem;
    border-top: 1px dashed rgba(100,70,30,0.25);
}

.msg-actions button {
    font-family: var(--font-body);
    font-size: 0.72rem;
    color: var(--chrome);
    background: none;
    border: none;
    cursor: pointer;
    letter-spacing: 0.08em;
    text-transform: lowercase;
    padding: 0;
    transition: color 0.15s;
}
.msg-actions button:hover { color: var(--ink-rust); }

/* Mensagem aguardando */
.aguardando {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 0.85rem;
    color: var(--ink-faded);
    opacity: 0.7;
    padding: 0.3rem 0;
    animation: blink 1.2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 0.7; }
    50%       { opacity: 0.3; }
}

/* ── ÁREA DE INPUT — A MÁQUINA DE ESCREVER ──────────────────────────── */
.input-area {
    flex-shrink: 0;              /* não encolhe — sempre visível */
    position: relative;
    background: transparent;
    padding: 0;
}

.input-row {
    display: flex;
    align-items: flex-end;
    width: 100%;
}

/* Bloco da máquina de escrever */
.machine-block {
    position: relative;
    flex: 1 1 auto;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: top center;
    min-height: 160px;
    height: 160px;
    overflow: visible;
}

/* Textarea posicionada sobre o papel/rolo da máquina */
.typewriter-wrap {
    position: absolute;
    top:    96px;
    left:   22%;
    right:  12%;
    height: auto;
    background: transparent;
    overflow: visible;   /* deixa o textarea crescer sem cortar */
    z-index: 10;
}

.paper-roll {
    width: 100%;
    height: 100%;
}

textarea#pergunta {
    display: block;
    width: 81%;
    height: 30px;
    min-height: 30px;
    max-height: none;
    background: var(--paper);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 2px;
    outline: none;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--ink);
    line-height: 24px;
    padding: 0.15rem 0.6rem;
    resize: none;
    overflow-y: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

textarea#pergunta::placeholder {
    color: var(--ink-faded);
    font-style: italic;
}

/* ── BOTÃO SEND — embutido na imagem da máquina ─────────────────────── */
.send-block {
    display: none;
}

#btn-enviar {
    display: none;
}

/* Área clicável sobre o botão Enviar da imagem */
.btn-enviar-imagem {
    position: absolute;
    right: 2%;
    top: 20%;
    width: 12%;
    height: 70%;
    cursor: pointer;
    z-index: 20;
    background: transparent;
    border: none;
}

.btn-enviar-imagem:active {
    opacity: 0.7;
    transform: scale(0.97);
}

/* Select de obras */
.obra-tag {
    font-family: var(--font-body);
    font-size: 0.70rem;
    color: var(--ink-rust);
    letter-spacing: 0.08em;
    font-style: italic;
    margin-top: 0.3rem;
    opacity: 1;
}

.obra-wrap {
    margin-top: 0;
    padding: 0 0 1rem 0;   /* era: 0 1.8rem 1rem — zerando as laterais */
}

.obra-wrap select {
    width: 100%;
    background: var(--machine-mid);
    color: var(--chrome);
    border: 1px solid #4a3a28;
    border-radius: 2px;
    font-family: var(--font-body);
    font-size: 0.78rem;
    padding: 0.4rem 0.8rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    letter-spacing: 0.05em;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238a7a60' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
}
.obra-wrap select:focus { border-color: var(--chrome); }

/* ── FOOTER ─────────────────────────────────────────────────────────── */
.footer {
    flex-shrink: 0;
    background: transparent;
    padding: 0.8rem 1.6rem;
    border-top: 1px solid #0a0800;
    text-align: center;
}

.footer p {
    font-family: var(--font-body);
    font-size: 0.68rem;
    color: #4a3a28;
    letter-spacing: 0.06em;
    line-height: 1.8;
}

.footer a {
    color: var(--chrome);
    text-decoration: none;
}
.footer a:hover { color: var(--paper-aged); }

/* ── RESPONSIVO ──────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .container {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .header-card { padding: 1rem 1.2rem; }
    .header-info h1 { font-size: 1.25rem; }

    .chat-area {
        padding-left: 2.8rem;
    }

    .machine-block {
        height: 120px;
    }

    .send-block {
        flex: 0 0 68px;
    }

    #btn-enviar {
        width: 60px;
        height: 60px;
    }
}
