:root {
    --bg: #0a0a0f;
    --surface: #14141f;
    --surface2: #1e1e2e;
    --border: #2a2a3e;
    --text: #e4e4e7;
    --text2: #a1a1aa;
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --green: #4ade80;
    --red: #ef4444;
    --radius: 16px;
    --radius-sm: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#app { height: 100vh; display: flex; flex-direction: column; }

.hidden { display: none !important; }

/* Form Screen */
#form-screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
}

#form-screen h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.25rem;
}

#form-screen .subtitle {
    color: var(--text2);
    margin-bottom: 1.5rem;
    text-align: center;
}

.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 480px;
    width: 100%;
}

.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text2);
}

.form-group input[type="text"],
.form-group textarea,
.form-group select {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.7rem 1rem;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.3s;
    font-family: inherit;
}

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

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.gender-options {
    display: flex;
    gap: 0.75rem;
}

.gender-options label {
    flex: 1;
    padding: 0.6rem;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    color: var(--text2);
}

.gender-options input[type="radio"] { display: none; }

.gender-options input[type="radio"]:checked + label {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem !important;
    color: var(--text2) !important;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    accent-color: var(--primary);
}

.btn-primary {
    width: 100%;
    padding: 0.8rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

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

.btn-secondary {
    padding: 0.7rem 1.5rem;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger {
    padding: 0.7rem 1.5rem;
    background: transparent;
    color: var(--red);
    border: 1px solid var(--red);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

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

/* Panel Screen */
#panel-screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

#panel-screen h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1.5rem;
}

.panel-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.panel-avatar {
    font-size: 4rem;
    margin-bottom: 0.75rem;
}

.panel-name {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.panel-type {
    font-size: 0.85rem;
    color: var(--text2);
    margin-bottom: 1rem;
}

.panel-personality {
    font-size: 0.8rem;
    color: var(--text2);
    line-height: 1.5;
    text-align: left;
    padding: 0.75rem;
    background: var(--surface2);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    max-height: 120px;
    overflow-y: auto;
}

.panel-stats {
    font-size: 0.8rem;
    color: var(--text2);
    margin-bottom: 1.25rem;
}

.panel-actions {
    display: flex;
    gap: 0.75rem;
    flex-direction: column;
}

/* Back Button */
.back-btn {
    background: none;
    border: none;
    color: var(--text2);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    transition: color 0.3s;
}

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

/* Config Screen */
#config-screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.config-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.config-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.config-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.config-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 500px;
    margin: 0 auto;
}

.cfg-type-desc {
    font-size: 0.75rem;
    color: var(--text2);
    margin-top: 0.3rem;
}

/* Call Screen */
#call-screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.call-header {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    gap: 0.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
}

.mood-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border: 2px solid var(--border);
    transition: border-color 0.5s ease;
    flex-shrink: 0;
}

.mood-avatar.mood-animado { border-color: #fb923c; }
.mood-avatar.mood-feliz { border-color: #4ade80; }
.mood-avatar.mood-calmo { border-color: #60a5fa; }
.mood-avatar.mood-brincalhao { border-color: #fbbf24; }
.mood-avatar.mood-curioso { border-color: #a78bfa; }
.mood-avatar.mood-romantico { border-color: #f472b6; }
.mood-avatar.mood-serio { border-color: #94a3b8; }
.mood-avatar.mood-confuso { border-color: #f87171; }

.mood-avatar.pulse {
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 5px currentColor; }
    50% { box-shadow: 0 0 15px currentColor; }
}

.header-info {
    line-height: 1.3;
    min-width: 0;
}

.companion-name { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.companion-type { font-size: 0.7rem; color: var(--text2); }

.header-right { text-align: right; flex-shrink: 0; }
.call-timer { font-size: 0.85rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--green); }
.mood-label { font-size: 0.65rem; color: var(--text2); text-transform: capitalize; }

#temperament-bar {
    display: flex;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.trait { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.trait-label { font-size: 0.5rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.3px; }
.trait-track { width: 100%; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.trait-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--primary), #ec4899); transition: width 0.8s ease; }

#message-area {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.message {
    max-width: 85%;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius);
    animation: fadeIn 0.3s ease;
}

.message.assistant { align-self: flex-start; background: var(--surface2); border-bottom-left-radius: 4px; }
.message.user { align-self: flex-end; background: var(--primary); border-bottom-right-radius: 4px; }
.message .text { font-size: 0.85rem; line-height: 1.5; }
.message .audio-player { margin-top: 0.35rem; }
.message .audio-player audio { width: 100%; height: 30px; border-radius: var(--radius-sm); }

.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0.6rem 0.85rem;
    background: var(--surface2);
    border-radius: var(--radius);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.typing-indicator span { width: 7px; height: 7px; border-radius: 50%; background: var(--text2); animation: bounce 1.4s ease-in-out infinite; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

#input-area {
    display: flex;
    gap: 0.6rem;
    padding: 0.65rem 0.75rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

#input-area input {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 0.6rem 1rem;
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
}

#input-area input:focus { border-color: var(--primary); }
#input-area input::placeholder { color: var(--text2); }

.send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.send-btn:hover { background: var(--primary-hover); transform: scale(1.05); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text2); }
