/* plypad.css — PlyPad VPS UI Design System
   Based on Sora + IBM Plex Mono redesign.
   Replaces Tailwind utility classes with semantic CSS. */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

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

:root {
  --brand: #3046AB;
  --brand-l: #5068C4;
  --brand-bg: #EEF0F9;
  --bg: #FFFFFF;
  --bg2: #F7F7F6;
  --bg3: #EEEEEC;
  --t1: #1A1A1A;
  --t2: #666666;
  --t3: #A3A3A3;
  --brd: #EBEBEB;
  --ok: #10B981;
  --ok-bg: #ECFDF5;
  --ok-brd: #A7F3D0;
  --err: #EF4444;
  --err-bg: #FEF2F2;
  --err-brd: #FECACA;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'Sora', sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--t1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection { background: var(--t1); color: #fff; }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: #fff; border-left: 1px solid var(--bg3); }
::-webkit-scrollbar-thumb { background: var(--t1); }
::-webkit-scrollbar-thumb:hover { background: var(--brand); }

a { color: inherit; text-decoration: none; }

/* ── Topbar ─────────────────────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; height: 52px;
  background: rgba(255,255,255,0.95); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--brd);
}
.topbar-logo { display: flex; align-items: center; gap: 8px; }
.topbar-logo img { height: 52px; width: auto; display: block; }
.topbar-logo-txt {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  letter-spacing: 0.06em; color: var(--t1);
}
.topbar-right {
  display: flex; align-items: center; gap: 20px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.03em;
}
.topbar-user { color: var(--t2); }
.topbar-link {
  color: var(--t3); cursor: pointer; text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 500; transition: color 0.12s;
  border: none; background: none; font-family: var(--mono); font-size: 11px;
  text-decoration: none;
}
.topbar-link:hover { color: var(--t1); }

/* ── Main Content ───────────────────────────────────────────────────────────── */
.main-content {
  flex: 1; display: flex; flex-direction: column;
  padding: 52px 0 0; /* topbar height */
}
.page-container {
  width: 100%; max-width: 960px; margin: 0 auto;
  padding: 28px 32px 48px;
}
.page-container--narrow { max-width: 520px; }
.page-container--medium { max-width: 720px; }

/* ── Page Header ────────────────────────────────────────────────────────────── */
.page-hdr { margin-bottom: 24px; }
.page-hdr-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.page-title {
  font-size: 36px; font-weight: 700; letter-spacing: -0.04em; line-height: 0.95;
}
.page-title .dot { color: var(--brand); }
.page-sub {
  font-family: var(--mono); font-size: 11px; color: var(--t3);
  letter-spacing: 0.04em; text-transform: uppercase; margin-top: 6px;
}
.page-hdr-bar {
  border-top: 1.5px solid var(--t1); margin-top: 14px; padding-top: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.page-hdr-bc {
  font-family: var(--mono); font-size: 11px; color: var(--t3);
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer; border: 1px solid transparent;
  transition: all 0.15s; text-decoration: none;
  line-height: 1; white-space: nowrap;
}
.btn svg, .btn i { width: 14px; height: 14px; flex-shrink: 0; }

.btn--primary {
  padding: 12px 24px; background: var(--t1); color: #fff; border-color: var(--t1);
}
.btn--primary:hover { background: #333; border-color: #333; }

.btn--accent {
  padding: 10px 20px; background: var(--brand); color: #fff; border-color: var(--brand);
}
.btn--accent:hover { background: var(--brand-l); border-color: var(--brand-l); }

.btn--outline {
  padding: 10px 20px; background: transparent; color: var(--t2); border-color: var(--brd);
}
.btn--outline:hover { border-color: var(--t3); color: var(--t1); }

.btn--danger {
  padding: 10px 20px; background: #fff; color: #B91C1C; border-color: var(--err-brd);
}
.btn--danger:hover { background: #B91C1C; border-color: #B91C1C; color: #fff; }

.btn--icon { padding: 10px; width: 44px; height: 44px; }

.btn--full { width: 100%; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg); border: 1px solid var(--brd);
  display: flex; flex-direction: column;
}
.card--shadow { box-shadow: 0 10px 24px rgba(26,26,26,0.06); }
.card--padded { padding: 24px; }

/* ── Device Cards (grid) ────────────────────────────────────────────────────── */
.devices-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0;
}
.dev-card { border: 1px solid var(--brd); display: flex; flex-direction: column; }

.dev-card-top {
  padding: 20px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--brd);
}
.dev-card-icon {
  width: 40px; height: 40px; background: var(--bg2);
  display: flex; align-items: center; justify-content: center; color: var(--t2); flex-shrink: 0;
}
.dev-card-info { flex: 1; min-width: 0; }
.dev-card-name { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; }
.dev-card-id {
  font-family: var(--mono); font-size: 10px; color: var(--t3);
  margin-top: 1px; word-break: break-all;
}

.dev-card-meta { padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.dev-card-row { display: flex; justify-content: space-between; align-items: center; }
.dev-card-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--t3);
}
.dev-card-val { font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--t1); }

.dev-card-actions { display: flex; gap: 0; border-top: 1px solid var(--brd); }
.dev-card-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px; font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer;
  border: none; background: var(--t1); color: #fff; transition: background 0.12s;
  text-decoration: none;
}
.dev-card-btn:hover { background: #333; }
.dev-card-btn--secondary {
  background: transparent; color: var(--t3); border-left: 1px solid var(--brd);
  flex: 0; width: 48px;
}
.dev-card-btn--secondary:hover { color: var(--t1); background: var(--bg2); }

/* ── Status Badge ───────────────────────────────────────────────────────────── */
.status-badge {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
  padding: 3px 8px; flex-shrink: 0; display: inline-block;
}
.status-badge--online { color: var(--ok); background: var(--ok-bg); }
.status-badge--offline { color: var(--err); background: var(--err-bg); }

/* ── Section Label ──────────────────────────────────────────────────────────── */
.section-label {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0 16px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--t3); font-weight: 600;
}
.section-label svg { width: 18px; height: 18px; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-field { margin-bottom: 20px; }
.form-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--t3); font-weight: 600;
  margin-bottom: 6px; display: block;
}
.form-input,
form input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
form select, form textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--brd);
  background: var(--bg); font-family: var(--sans); font-size: 14px;
  color: var(--t1); outline: none; transition: border-color 0.15s;
}
.form-input:focus,
form input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
form select:focus, form textarea:focus {
  border-color: var(--brand);
}
.form-input::placeholder, form input::placeholder, form textarea::placeholder { color: var(--t3); }
.form-hint { font-family: var(--mono); font-size: 10px; color: var(--t3); margin-top: 6px; }

/* ── Auth Layout (Login/Register) ───────────────────────────────────────────── */
.auth-layout {
  flex: 1; display: flex; justify-content: center; align-items: center;
  min-height: calc(100vh - 52px); padding: 32px;
}
.auth-visual {
  width: 360px; height: calc(100vh - 52px - 280px); min-height: 400px;
  background: #000; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; position: relative; overflow: hidden;
}
.auth-visual::after {
  content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0.10);
  pointer-events: none; z-index: 1;
}
.auth-visual-grid {
  position: absolute; inset: 0; opacity: 0.06;
  background-image: linear-gradient(rgba(255,255,255,0.5) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,0.5) 1px, transparent 1px);
  background-size: 24px 24px;
}
.auth-visual-logo { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 2; }
.auth-visual-logo img { height: 140px; filter: brightness(0) invert(1); }
.auth-visual-txt { display: none; }
.auth-form-area {
  flex: 1; height: calc(100vh - 52px - 280px); min-height: 400px;
  display: flex; flex-direction: column; justify-content: center;
  padding: 48px; max-width: 520px;
}
.auth-title { font-size: 32px; font-weight: 700; letter-spacing: -0.04em; line-height: 1; margin-bottom: 6px; }
.auth-title .dot { color: var(--brand); }
.auth-sub {
  font-family: var(--mono); font-size: 11px; color: var(--t3);
  letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 32px;
}
.auth-divider { height: 1px; background: var(--brd); margin: 24px 0; }
.auth-footer { font-size: 13px; color: var(--t2); }
.auth-footer a { color: var(--brand); text-decoration: none; font-weight: 600; }
.auth-footer a:hover { color: var(--t1); }

/* ── Connect (Claim) Page ───────────────────────────────────────────────────── */
.connect-content {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 40px; min-height: calc(100vh - 52px);
}
.connect-card { width: 100%; max-width: 440px; }
.connect-stripe { height: 3px; background: var(--brand); margin-bottom: 32px; }
.connect-icon {
  width: 48px; height: 48px; border: 1px solid var(--brd);
  display: flex; align-items: center; justify-content: center;
  color: var(--t3); margin-bottom: 20px;
}
.connect-title { font-size: 28px; font-weight: 700; letter-spacing: -0.04em; margin-bottom: 6px; }
.connect-title .dot { color: var(--brand); }
.connect-sub {
  font-family: var(--mono); font-size: 11px; color: var(--t3);
  letter-spacing: 0.03em; text-transform: uppercase; margin-bottom: 28px;
}
.connect-cancel {
  font-family: var(--mono); font-size: 11px; color: var(--t3);
  letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer;
  border: none; background: none; text-align: center; display: block;
  width: 100%; padding: 8px; transition: color 0.12s; text-decoration: none;
}
.connect-cancel:hover { color: var(--t1); }

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; font-size: 13px; font-weight: 500; margin-bottom: 16px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert--success { background: var(--ok-bg); color: #15803D; border: 1px solid var(--ok-brd); }
.alert--error { background: var(--err-bg); color: #DC2626; border: 1px solid var(--err-brd); }

.errorlist {
  margin-top: 6px; color: var(--err); font-size: 12px; font-weight: 500;
  list-style: none; padding-left: 0;
}

/* ── Settings Sections ──────────────────────────────────────────────────────── */
.settings-section {
  padding: 24px 28px; border-bottom: 1px solid var(--brd);
}
.settings-section:last-child { border-bottom: none; }
.settings-section--muted { background: var(--bg2); }
.settings-section--danger { background: #FEF2F240; }

.settings-title {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--t1);
  margin-bottom: 16px;
}
.settings-title--danger { color: var(--err); }

/* ── Info Grid (technical details) ──────────────────────────────────────────── */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.info-box { padding: 14px 16px; background: var(--bg2); border: 1px solid var(--brd); }
.info-box-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--t3); margin-bottom: 4px;
}
.info-box-val { font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--t1); word-break: break-all; }

/* ── Members List ───────────────────────────────────────────────────────────── */
.members-list { border: 1px solid var(--brd); margin-bottom: 20px; }
.member-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--brd); transition: background 0.12s;
}
.member-row:last-child { border-bottom: none; }
.member-row:hover { background: var(--bg2); }
.member-avatar {
  width: 36px; height: 36px; background: var(--bg2); border: 1px solid var(--brd);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-size: 13px; font-weight: 700; color: var(--t2);
}
.member-info { flex: 1; min-width: 0; }
.member-email { font-size: 13px; font-weight: 600; word-break: break-all; }
.member-role {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--t3); margin-top: 2px;
}
.member-tag {
  display: inline-block; padding: 2px 6px; font-family: var(--mono);
  font-size: 9px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; background: var(--brand-bg); color: var(--brand);
  margin-left: 6px;
}

/* ── Profile ────────────────────────────────────────────────────────────────── */
.profile-header {
  display: flex; align-items: center; gap: 16px;
  padding-bottom: 20px; margin-bottom: 24px; border-bottom: 1px solid var(--brd);
}
.profile-avatar {
  width: 56px; height: 56px; background: var(--t1); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; flex-shrink: 0;
}
.profile-email { font-size: 18px; font-weight: 700; word-break: break-all; }
.profile-sub {
  font-family: var(--mono); font-size: 11px; color: var(--t3);
  letter-spacing: 0.04em; text-transform: uppercase; margin-top: 4px;
}

/* ── Connection Hub (device_interface) ──────────────────────────────────────── */
.connection-shell { width: 100%; max-width: 900px; margin: 0 auto; }
.connection-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--brd);
}
.connection-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
@media (max-width: 640px) {
  .connection-grid { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-card { height: auto; }
  .auth-form-area { padding: 32px 20px; }
  .topbar { padding: 0 16px; }
  .page-container { padding: 20px 16px 40px; }
}

/* ── Standalone Pages (share, error) ────────────────────────────────────────── */
.standalone-center {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px; background: var(--bg2);
}
.standalone-card {
  width: 100%; max-width: 380px; background: var(--bg);
  border: 1px solid var(--brd); overflow: hidden;
}
.standalone-header {
  background: var(--t1); padding: 32px 24px; text-align: center;
  position: relative; overflow: hidden;
}
.standalone-header-grid {
  position: absolute; inset: 0; opacity: 0.06;
  background-image: linear-gradient(rgba(255,255,255,0.5) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,0.5) 1px, transparent 1px);
  background-size: 20px 20px;
}
.standalone-icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
}
.standalone-icon--error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); }
.standalone-icon--lock { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); }
.standalone-icon svg { width: 28px; height: 28px; }
.standalone-title {
  color: #fff; font-size: 18px; font-weight: 700; position: relative; z-index: 1;
}
.standalone-filename {
  font-family: var(--mono); font-size: 11px; color: var(--t3);
  margin-top: 4px; position: relative; z-index: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.standalone-body { padding: 32px 24px; text-align: center; }
.standalone-footer {
  padding: 0 24px 24px; text-align: center;
  font-family: var(--mono); font-size: 10px; color: var(--t3);
  letter-spacing: 0.04em; text-transform: uppercase;
}

/* ── Status Terminal ────────────────────────────────────────────────────────── */
.status-terminal {
  background: #0d1117; color: #c9d1d9;
  font-family: var(--mono); padding: 16px;
  height: 200px; overflow-y: auto; font-size: 12px;
  margin-top: 16px; border: 1px solid #1f2937;
}

/* ── Remote View ────────────────────────────────────────────────────────────── */
#remote-view {
  position: fixed; inset: 0; z-index: 9999; background: #000;
  display: none; flex-direction: column;
}
.remote-toolbar {
  position: absolute; bottom: 12px; right: 12px; z-index: 10000;
  opacity: 0.35; transition: opacity 0.25s;
}
.remote-toolbar:hover { opacity: 1; }
.remote-toolbar-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.7); border: 1px solid #555; color: #fff;
  padding: 8px 16px; font-family: var(--mono); font-size: 11px;
  font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer; backdrop-filter: blur(8px);
}
#remote-iframe { border: none; width: 100%; height: 100%; display: block; background: #fff; }

/* ── Utility ────────────────────────────────────────────────────────────────── */
.text-mono { font-family: var(--mono); }
.text-center { text-align: center; }
.mt-auto { margin-top: auto; }
.mb-0 { margin-bottom: 0; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.flex-row { display: flex; flex-direction: row; align-items: center; }
.flex-col { display: flex; flex-direction: column; }
.flex-1 { flex: 1; min-width: 0; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Animations ─────────────────────────────────────────────────────────────── */
.fade-up {
  opacity: 0; transform: translateY(20px);
  transition: opacity 0.8s cubic-bezier(0.16,1,0.3,1), transform 0.8s cubic-bezier(0.16,1,0.3,1);
}
.fade-up.visible { opacity: 1; transform: translateY(0); }
.animate-spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
