/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f0f14;
    --surface: #1a1a24;
    --surface2: #222233;
    --border: #2a2a3c;
    --text: #e0e0e8;
    --text-dim: #8888a0;
    --accent: #6c5ce7;
    --accent2: #a29bfe;
    --accent3: #48dbfb;
    --success: #00cec9;
    --warning: #fdcb6e;
    --danger: #ff7675;
    --user-bubble: #2d2b4a;
    --ai-bubble: #1e1e2e;
    --radius: 12px;
    --radius-sm: 8px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ===== Landing Page ===== */
.landing {
    max-width: 640px;
    margin: 60px auto 0;
    padding: 0 20px;
}

.landing-hero {
    text-align: center;
    margin-bottom: 40px;
}

.landing-hero h1 {
    font-size: 2.5rem;
    color: var(--accent2);
    margin-bottom: 8px;
}

.landing-hero .subtitle {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 8px;
}

.landing-hero .desc {
    font-size: 0.9rem;
    color: var(--text-dim);
    max-width: 480px;
    margin: 0 auto;
}

.setup-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
}

.scenario-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.scenario-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    cursor: pointer;
    transition: all 0.2s;
}

.scenario-card:hover {
    border-color: var(--accent);
    background: var(--surface2);
}

.scenario-card input { display: none; }
.scenario-card input:checked + .sc-emoji + .sc-name {
    color: var(--accent2);
}
.scenario-card:has(input:checked) {
    border-color: var(--accent);
    background: var(--surface2);
}

.sc-emoji { font-size: 1.5rem; }
.sc-name { font-size: 0.8rem; color: var(--text-dim); }

.btn-start {
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-start:hover { background: var(--accent2); }
.btn-start:active { transform: scale(0.98); }
.btn-start:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Chat Interface ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.back-btn {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s;
    white-space: nowrap;
}

.back-btn:hover { color: var(--accent2); }

.chat-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-scenario {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent2);
}

.chat-puesto {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.btn-end {
    padding: 8px 16px;
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--danger);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-end:hover { background: var(--danger); color: #fff; }
.btn-end:disabled { opacity: 0.4; }

/* ===== Messages ===== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.msg {
    max-width: 80%;
    animation: fadeIn 0.25s ease;
}

.msg.user { align-self: flex-end; }
.msg.ai { align-self: flex-start; }

.msg-content {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.msg.user .msg-content {
    background: var(--user-bubble);
    border: 1px solid var(--accent);
    color: var(--text);
}

.msg.ai .msg-content {
    background: var(--ai-bubble);
    border: 1px solid var(--border);
    color: var(--text);
}

.msg-error .msg-content {
    background: var(--danger);
    color: #fff;
    border: none;
    max-width: 100%;
}

/* ===== Thinking dots ===== */
.thinking .msg-content {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
}

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

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

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* ===== Input Area ===== */
.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-input-area textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
}

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

#btn-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

#btn-send:hover { background: var(--accent2); }
#btn-send:disabled { opacity: 0.4; }

/* ===== Evaluation Modal ===== */
.evaluation-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.eval-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
}

.eval-content {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.eval-content h2 {
    font-size: 1.4rem;
}

.eval-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text);
}

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

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .landing { margin-top: 30px; padding: 0 12px; }
    .landing-hero h1 { font-size: 1.8rem; }
    .setup-form { padding: 20px; }
    .scenario-grid { grid-template-columns: 1fr; }
    .msg { max-width: 90%; }
}
