:root {
    --bg: #282a36;
    --current-line: #44475a;
    --fg: #f8f8f2;
    --comment: #6272a4;
    --cyan: #8be9fd;
    --green: #50fa7b;
    --orange: #ffb86c;
    --pink: #ff79c6;
    --purple: #bd93f9;
    --red: #ff5555;
    --yellow: #f1fa8c;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
}

a { color: var(--cyan); }

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: var(--current-line);
    padding: 32px;
    border-radius: 12px;
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-box h1 { margin: 0 0 8px; color: var(--purple); text-align: center; }

.login-banner {
    width: 100%;
    border-radius: 10px;
    object-fit: cover;
    max-height: 140px;
}

input, textarea, select {
    background: var(--bg);
    border: 1px solid var(--purple);
    color: var(--fg);
    padding: 10px;
    border-radius: 8px;
    font-size: 15px;
    width: 100%;
}

textarea { resize: vertical; min-height: 70px; }

button, .btn {
    background: var(--purple);
    color: var(--bg);
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 14px;
}

button.secondary, .btn.secondary {
    background: transparent;
    color: var(--purple);
    border: 1px solid var(--purple);
}

button.danger { background: var(--red); color: var(--bg); }

button:disabled { opacity: 0.5; cursor: not-allowed; }

.error { color: var(--red); }
.success { color: var(--green); }

/* Topbar / nav */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--current-line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar h1 { font-size: 18px; margin: 0; color: var(--purple); display: flex; align-items: center; gap: 8px; }
.topbar .actions { display: flex; align-items: center; gap: 8px; }
.topbar .actions a, .topbar .actions button { text-decoration: none; }

.health-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    display: inline-block;
    background: var(--comment);
    flex-shrink: 0;
}
.health-dot.green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.health-dot.yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.health-dot.red { background: var(--red); box-shadow: 0 0 6px var(--red); }

.tabs {
    display: flex;
    background: var(--current-line);
    border-bottom: 2px solid var(--purple);
}
.tabs a {
    flex: 1;
    text-align: center;
    padding: 12px 4px;
    color: var(--fg);
    text-decoration: none;
    font-weight: bold;
}
.tabs a.active { color: var(--purple); border-bottom: 3px solid var(--purple); }

.container { padding: 16px; max-width: 700px; margin: 0 auto; }

/* Instance cards */
.card {
    background: var(--current-line);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: var(--fg);
}
.card:hover { outline: 1px solid var(--purple); }
.card .meta { font-size: 13px; color: var(--comment); }

.status-badge { font-weight: bold; font-size: 13px; }
.status-open { color: var(--green); }
.status-connecting { color: var(--yellow); }
.status-close, .status-unknown { color: var(--red); }

.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 4px; font-size: 13px; color: var(--comment); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--purple);
    background: transparent;
    color: var(--fg);
    cursor: pointer;
    font-size: 13px;
}
.chip.selected { background: var(--purple); color: var(--bg); font-weight: bold; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }

.qrcode img { max-width: 260px; display: block; margin: 10px 0; border-radius: 8px; }
.pairing-code { font-size: 32px; font-weight: bold; color: var(--purple); letter-spacing: 2px; }

.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--purple);
    color: var(--bg);
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

.result-row { display: flex; gap: 8px; padding: 2px 0; font-size: 14px; }
.result-ok { color: var(--green); }
.result-fail { color: var(--red); }

.chat-list-item { display: flex; justify-content: space-between; align-items: center; }
.unread-badge {
    background: var(--pink);
    color: var(--bg);
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: bold;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 0;
    overflow-y: auto;
}
.bubble {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--current-line);
}
.bubble.me { align-self: flex-end; background: var(--purple); color: var(--bg); }
.bubble .time { font-size: 11px; color: var(--comment); margin-top: 2px; }
.bubble.me .time { color: var(--bg); opacity: .7; }

.reply-bar { display: flex; gap: 8px; position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; }
.reply-bar textarea { flex: 1; min-height: 40px; }

.workflow-row { display: flex; justify-content: space-between; align-items: center; }
.switch { position: relative; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--comment); border-radius: 26px; transition: .2s;
}
.slider:before {
    content: ""; position: absolute; height: 20px; width: 20px; left: 3px; bottom: 3px;
    background: var(--fg); border-radius: 50%; transition: .2s;
}
input:checked + .slider { background: var(--green); }
input:checked + .slider:before { transform: translateX(20px); }

.hint { font-size: 12px; color: var(--comment); margin-top: 4px; }

/* Barra de progresso indeterminada (build do apk) */
.progress-track {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--current-line);
    overflow: hidden;
    position: relative;
}
.progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 40%;
    border-radius: 4px;
    background: var(--purple);
    animation: progress-slide 1.2s ease-in-out infinite;
}
@keyframes progress-slide {
    0%   { left: -40%; }
    100% { left: 100%; }
}
.progress-track.done .progress-bar { animation: none; width: 100%; left: 0; background: var(--green); }
.progress-track.error .progress-bar { animation: none; width: 100%; left: 0; background: var(--red); }

.build-log {
    background: var(--bg);
    border: 1px solid var(--comment);
    border-radius: 8px;
    padding: 10px;
    max-height: 320px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
}

@media (max-width: 480px) {
    .container { padding: 10px; }
}
