/* Контора VK Mini App — Стили v2 (чат с аватарами) */

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

:root {
    --bg: #1a1a1a;
    --card: #252525;
    --gold: #c9a84c;
    --red: #c0392b;
    --text: #e0d6c2;
    --muted: #8a8578;
    --accent: #2a2a2a;
    --bubble-bg: #2a2a2a;
    --bubble-left: #2d2820;
}

html, body {
    font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#app { max-width: 480px; margin: 0 auto; padding: 8px; min-height: 100%; }

/* Header */
.header { text-align: center; padding: 8px 0 6px; border-bottom: 1px solid #333; margin-bottom: 8px; }
.header h1 { font-size: 20px; color: var(--gold); letter-spacing: 2px; }
.age-badge {
    display: inline-block;
    background: var(--red);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 4px;
    letter-spacing: 0;
}
.subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Screens */
.screen { display: none; }
.screen.active { display: block; }

/* Cards */
.card { background: var(--card); border-radius: 12px; padding: 14px; }
.label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: 1px; }
textarea {
    width: 100%; height: 60px; padding: 8px;
    background: var(--accent); color: var(--text);
    border: 1px solid #444; border-radius: 8px;
    font-size: 14px; resize: none; outline: none; font-family: inherit;
}
textarea:focus { border-color: var(--gold); }
.char-count { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }

/* Levels */
.levels { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.level-card { cursor: pointer; }
.level-card input { display: none; }
.level-content {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
    padding: 10px; border-radius: 8px;
    background: var(--accent); border: 2px solid transparent; transition: all 0.2s;
}
.level-card input:checked + .level-content { border-color: var(--gold); background: #2e2b20; }
.level-name { font-size: 14px; font-weight: 600; flex: 1; }
.level-price { font-size: 14px; font-weight: 700; color: var(--gold); }
.level-desc { width: 100%; font-size: 11px; color: var(--muted); }

/* Buttons */
.btn-primary, .btn-secondary {
    width: 100%; padding: 12px; border: none; border-radius: 8px;
    font-size: 14px; font-weight: 700; cursor: pointer; margin-top: 10px;
    text-transform: uppercase; letter-spacing: 1px; transition: all 0.2s;
}
.btn-primary { background: var(--gold); color: #1a1a1a; }
.btn-primary:hover { background: #d4b24e; }
.btn-primary:disabled { background: #555; color: #888; cursor: not-allowed; }
.btn-secondary { background: transparent; border: 1px solid var(--gold); color: var(--gold); }
.hint { font-size: 11px; color: var(--muted); text-align: center; margin-top: 6px; }

/* Loading */
.loading-card { text-align: center; padding: 40px 20px; }
.spinner {
    width: 40px; height: 40px; border: 3px solid #555;
    border-top-color: var(--gold); border-radius: 50%;
    animation: spin 1s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-card h2 { color: var(--gold); font-size: 18px; margin-bottom: 6px; }
#loading-question { color: var(--muted); font-size: 13px; }
.char-status { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 16px; }
.char-avatar-mini { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--gold); background: #333; }
#loading-name { font-size: 13px; color: var(--gold); }

/* Error */
.error-card { text-align: center; padding: 40px 20px; }
.error-card h2 { margin-bottom: 8px; }
#error-text { color: var(--muted); margin-bottom: 16px; }

/* ── Result Screen: Chat Style ──────────────────── */
.result-header { padding: 8px 0; }
.result-question { color: var(--gold); font-size: 13px; font-style: italic; text-align: center; padding: 8px; background: var(--card); border-radius: 8px; }

.chat-container {
    display: flex; flex-direction: column; gap: 12px;
    padding: 12px 0; max-height: 55vh; overflow-y: auto;
}

/* Chat Message */
.chat-message {
    display: flex; gap: 10px; align-items: flex-start;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.chat-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    border: 2px solid var(--gold); flex-shrink: 0;
    object-fit: cover; background: #333;
}
.chat-body { flex: 1; min-width: 0; }
.chat-name {
    font-size: 12px; font-weight: 700; color: var(--gold);
    margin-bottom: 3px; letter-spacing: 0.5px;
}
.chat-bubble {
    background: var(--bubble-left); 
    padding: 10px 14px; border-radius: 2px 12px 12px 12px;
    font-size: 13px; line-height: 1.55; color: var(--text);
    position: relative;
}
.chat-bubble::before {
    content: '';
    position: absolute; top: 0; left: -6px;
    width: 0; height: 0;
    border-top: 6px solid var(--bubble-left);
    border-left: 6px solid transparent;
}

/* Первое сообщение (Палыч) — выделенное */
.chat-message:first-child .chat-bubble {
    background: var(--accent); border: 1px solid var(--gold);
}
.chat-message:first-child .chat-bubble::before { border-top-color: var(--accent); }

.result-actions {
    display: flex; gap: 8px; padding: 8px 0;
    position: sticky; bottom: 0; background: var(--bg);
}
.result-actions .btn-primary, .result-actions .btn-secondary { margin-top: 0; }

/* Placholder avatar */
.avatar-placeholder {
    width: 42px; height: 42px; border-radius: 50%;
    border: 2px solid var(--gold); background: #333;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}

/* Disclaimer */
.disclaimer {
    font-size: 10px;
    color: #555;
    text-align: center;
    margin-top: 12px;
    line-height: 1.4;
}
.result-disclaimer {
    margin-bottom: 8px;
    margin-top: 4px;
}

/* Ad block */
.ad-block {
    margin-top: 16px; padding: 12px 14px;
    background: var(--card); border: 1px dashed var(--gold);
    border-radius: 10px;
    font-size: 12px; line-height: 1.6; color: var(--muted);
    text-align: center;
}
.ad-block strong { color: var(--gold); }
.ad-block a { color: var(--gold); text-decoration: underline; }
