/* MithunConnect — Web Viewer styles (self-contained, no framework) */
:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #e6e9ef;
  --text-dim: #9aa3b2;
  --accent: #4f8cff;
  --accent-hover: #3d76e0;
  --green: #35c66b;
  --red: #e5484d;
  --amber: #e0a63a;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.muted { color: var(--text-dim); }

.container { max-width: 960px; margin: 0 auto; padding: 24px 20px; }

/* ---- Auth card ---- */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%; max-width: 400px;
}
.card h1 { font-size: 22px; margin-bottom: 4px; }
.card .sub { color: var(--text-dim); font-size: 14px; margin-bottom: 22px; }

label { display: block; font-size: 13px; color: var(--text-dim); margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=number] {
  width: 100%; padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text); font-size: 15px;
}
input:focus { outline: none; border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 12px; margin-top: 18px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--red); }
.btn.small { width: auto; padding: 7px 14px; margin: 0; font-size: 13px; }

.switch-line { text-align: center; margin-top: 16px; font-size: 14px; color: var(--text-dim); }
.switch-line a { color: var(--accent); cursor: pointer; text-decoration: none; }

.alert { padding: 10px 13px; border-radius: 8px; font-size: 14px; margin-top: 14px; display: none; }
.alert.show { display: block; }
.alert.error { background: rgba(229,72,77,.12); color: #ff9a9d; border: 1px solid rgba(229,72,77,.3); }
.alert.ok { background: rgba(53,198,107,.12); color: #7ee6a3; border: 1px solid rgba(53,198,107,.3); }

/* ---- Device list ---- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 24px 0 14px; }
.section-head h2 { font-size: 17px; }

.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.device {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.device .name { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.device .did { font-family: ui-monospace, monospace; color: var(--text-dim); font-size: 13px; letter-spacing: 1px; }
.device .row { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.status .pip { width: 8px; height: 8px; border-radius: 50%; }
.status.online .pip { background: var(--green); } .status.online { color: var(--green); }
.status.offline .pip { background: var(--text-dim); } .status.offline { color: var(--text-dim); }

.empty { text-align: center; color: var(--text-dim); padding: 40px; border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---- Modal ---- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-bg.show { display: flex; }

/* ---- Viewer ---- */
.viewer-shell { display: flex; flex-direction: column; height: 100vh; background: #000; }
.viewer-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.viewer-toolbar .spacer { flex: 1; }
.viewer-toolbar select {
  padding: 7px 10px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px; font-size: 13px;
}
.conn-badge { font-size: 13px; padding: 4px 10px; border-radius: 20px; background: var(--surface-2); }
.conn-badge.live { background: rgba(53,198,107,.15); color: var(--green); }
.conn-badge.wait { background: rgba(224,166,58,.15); color: var(--amber); }
.conn-badge.dead { background: rgba(229,72,77,.15); color: var(--red); }

.stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
#remoteVideo { max-width: 100%; max-height: 100%; background: #000; display: block; }
.stage.fit #remoteVideo { width: 100%; height: 100%; object-fit: contain; }
.stage.stretch #remoteVideo { width: 100%; height: 100%; object-fit: fill; }

.overlay-msg {
  position: absolute; color: var(--text-dim); font-size: 15px; text-align: center;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hint { font-size: 12px; color: var(--text-dim); }

/* viewer toolbar extras (clipboard/file) */
.clip-toggle { display: inline-flex; align-items: center; gap: 4px; font-size: 15px;
  color: var(--text); cursor: pointer; padding: 6px 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 7px; }
.file-btn { display: inline-flex; align-items: center; gap: 5px; font-size: 13px;
  color: var(--text); cursor: pointer; padding: 7px 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 7px; }
.file-btn:hover { border-color: var(--accent); }
