/* ===================================================================
   Redroid Manager — 公共样式框架 v2.0
   基于 VOIP-SIP 设计系统 · 适配云手机管理 H5
   =================================================================== */

/* ===================================================================
   1. DESIGN TOKENS (Dark 主题)
   =================================================================== */
:root {
  --bg-0: #0d0d12;
  --bg-1: #16161e;
  --bg-2: #1e1e28;
  --bg-3: #282834;
  --bg-hover: #2a2a36;
  --bg-active: #323240;

  --border-1: #2a2a36;
  --border-2: #363648;
  --border-strong: #4a4a60;

  --fg-0: #f0f0f5;
  --fg-1: #b0b0c8;
  --fg-2: #787898;
  --fg-3: #505068;

  --accent-teal:    #4dd4b0;
  --accent-amber:   #f0b84d;
  --accent-magenta: #e05578;
  --accent-blue:    #5b8dee;
  --accent-violet:  #a07cdc;
  --accent-lime:    #8cd44a;

  --tint-teal:    rgba(77, 212, 176, 0.12);
  --tint-amber:   rgba(240, 184, 77, 0.12);
  --tint-magenta: rgba(224, 85, 120, 0.12);
  --tint-blue:    rgba(91, 141, 238, 0.12);
  --tint-violet:  rgba(160, 124, 220, 0.12);

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, monospace;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --fs-xs: 10.5px;
  --fs-sm: 11.5px;
  --fs-base: 12px;
  --fs-md: 13px;
  --fs-lg: 15px;
  --fs-xl: 20px;
  --fs-2xl: 26px;

  --scrim: rgba(0, 0, 0, 0.65);
}

/* ===================================================================
   2. RESET & BASE
   =================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--font-ui);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ===================================================================
   3. ANIMATIONS
   =================================================================== */
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.55} }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes slideUp { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
@keyframes slideDown { from{opacity:0;transform:translateY(-8px)} to{opacity:1;transform:translateY(0)} }
@keyframes spin { to{transform:rotate(360deg)} }
@keyframes pulseDot { 0%,100%{box-shadow:0 0 0 0 rgba(77,212,176,0.5)} 50%{box-shadow:0 0 0 6px rgba(77,212,176,0)} }
@keyframes toastIn { from{opacity:0;transform:translateX(24px)} to{opacity:1;transform:translateX(0)} }

/* ===================================================================
   4. HEADER / TOP NAV
   =================================================================== */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  height: 50px;
  background: color-mix(in srgb, var(--bg-0) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--fg-0);
}
.brand .mark {
  width: 20px; height: 20px;
  border-radius: 5px;
  background: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
  flex-shrink: 0;
}
.brand .sub { color: var(--fg-2); font-weight: 400; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--fg-2);
}
.header-stat { display: flex; align-items: center; gap: 6px; }

/* ===================================================================
   5. BUTTONS
   =================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  height: 32px;
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  color: var(--fg-0);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { background: var(--bg-active); transform: scale(0.97); }

.btn.primary {
  background: var(--accent-teal);
  border-color: var(--accent-teal);
  color: var(--bg-0);
}
.btn.primary:hover { filter: brightness(1.1); }
.btn.primary:active { filter: brightness(0.95); }

.btn.ghost { background: transparent; border-color: transparent; color: var(--fg-1); }
.btn.ghost:hover { background: var(--bg-2); color: var(--fg-0); }

.btn.danger { color: var(--accent-magenta); border-color: transparent; }
.btn.danger:hover { background: var(--tint-magenta); border-color: var(--accent-magenta); }

.btn.primary-danger {
  background: var(--accent-magenta);
  border-color: var(--accent-magenta);
  color: #fff;
}

.btn.sm { height: 28px; padding: 4px 10px; font-size: 11px; }
.btn.lg { height: 38px; padding: 9px 20px; font-size: var(--fs-md); }
.btn.icon-only { padding: 0; width: 32px; justify-content: center; }
.btn.sm.icon-only { width: 28px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-group.grow .btn { flex: 1; min-width: 0; }

/* ===================================================================
   6. CARD
   =================================================================== */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  animation: slideUp 0.25s ease-out both;
}
.card:hover { border-color: var(--border-2); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-1);
  gap: 8px;
}
.card-title {
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--fg-0);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.card-title .hash { color: var(--fg-3); }
.card-body { padding: 16px; }

/* ===================================================================
   7. BADGE & STATUS
   =================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  border-radius: 4px;
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  color: var(--fg-1);
  line-height: 1.5;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge.teal    { color: var(--accent-teal); background: var(--tint-teal); border-color: color-mix(in srgb, var(--accent-teal) 30%, transparent); }
.badge.amber   { color: var(--accent-amber); background: var(--tint-amber); border-color: color-mix(in srgb, var(--accent-amber) 30%, transparent); }
.badge.magenta { color: var(--accent-magenta); background: var(--tint-magenta); border-color: color-mix(in srgb, var(--accent-magenta) 30%, transparent); }
.badge.blue    { color: var(--accent-blue); background: var(--tint-blue); border-color: color-mix(in srgb, var(--accent-blue) 30%, transparent); }
.badge.violet  { color: var(--accent-violet); background: var(--tint-violet); border-color: color-mix(in srgb, var(--accent-violet) 30%, transparent); }

.badge .dot, .status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.teal    { background: var(--accent-teal); box-shadow: 0 0 0 3px var(--tint-teal); }
.status-dot.amber   { background: var(--accent-amber); box-shadow: 0 0 0 3px var(--tint-amber); }
.status-dot.magenta { background: var(--accent-magenta); box-shadow: 0 0 0 3px var(--tint-magenta); }
.status-dot.blue    { background: var(--accent-blue); box-shadow: 0 0 0 3px var(--tint-blue); }
.status-dot.gray    { background: var(--fg-3); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg-3) 30%, transparent); }

.status-dot.pulse {
  animation: pulseDot 1.6s ease-in-out infinite;
}

/* ===================================================================
   8. FORM
   =================================================================== */
.input, .select {
  width: 100%;
  padding: 8px 12px;
  height: 36px;
  background: var(--bg-3);
  color: var(--fg-0);
  border: 1px solid var(--border-1);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  transition: border-color 0.12s, background 0.12s;
  outline: none;
}
.input:focus, .select:focus { border-color: var(--accent-teal); background: var(--bg-2); }
.input::placeholder { color: var(--fg-3); }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23787898' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-2);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.form-label .opt { color: var(--fg-3); }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; min-width: 0; }

/* ===================================================================
   9. MODAL
   =================================================================== */
.modal-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--scrim);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 16px;
  animation: fadeIn 0.12s ease-out;
}
.modal-scrim.active { display: flex; }

.modal {
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  animation: slideDown 0.18s ease-out;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title {
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  font-weight: 600;
}
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-1);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===================================================================
   10. TOAST
   =================================================================== */
.toast-stack {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  max-width: 360px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--ts, var(--accent-teal));
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toastIn 0.25s cubic-bezier(0.2,0.8,0.2,1);
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.teal    { --ts: var(--accent-teal); }
.toast.amber   { --ts: var(--accent-amber); }
.toast.magenta { --ts: var(--accent-magenta); }

.toast-close {
  background: none; border: none; color: var(--fg-3);
  cursor: pointer; padding: 2px; margin-left: auto;
  font-size: 14px; line-height: 1;
}

/* ===================================================================
   11. SKELETON LOADING
   =================================================================== */
.skeleton {
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  height: 180px;
  animation: pulse 1.5s ease-in-out infinite;
}

/* ===================================================================
   12. PAGE LAYOUT
   =================================================================== */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-title {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.page-subtitle {
  color: var(--fg-2);
  font-size: var(--fs-md);
  margin-top: 4px;
}

/* ===================================================================
   13. BENTO GRID (设备列表)
   =================================================================== */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

/* ===================================================================
   14. PHONE INFO META
   =================================================================== */
.phone-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-bottom: 14px;
}
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.meta-value {
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  color: var(--fg-0);
  font-variant-numeric: tabular-nums;
}
.meta-value.sm { font-size: var(--fs-sm); color: var(--fg-1); }

/* ===================================================================
   15. EMPTY STATE
   =================================================================== */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: var(--fs-md);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }

/* ===================================================================
   16. UTILITY
   =================================================================== */
.mono { font-family: var(--font-mono); }
.dim   { color: var(--fg-3); }
.muted { color: var(--fg-2); }
.flex  { display: flex; }
.items-center { align-items: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================================================================
   17. SCROLLBAR
   =================================================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; border: 2px solid var(--bg-1); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ===================================================================
   18. SPINNER
   =================================================================== */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent-teal);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

/* ===================================================================
   19. LOGIN PAGE
   =================================================================== */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%; max-width: 380px;
  text-align: center;
  animation: slideUp 0.3s ease-out;
}
.login-card .logo {
  width: 52px; height: 52px; margin: 0 auto 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}
.login-card h1 { font-family: var(--font-mono); font-size: var(--fs-lg); margin-bottom: 4px; }
.login-card .subtitle { color: var(--fg-2); font-size: var(--fs-md); margin-bottom: 24px; }
.login-card .input { margin-bottom: 14px; text-align: center; }
.login-card .btn.primary { width: 100%; justify-content: center; }
.login-error { color: var(--accent-magenta); font-size: var(--fs-sm); font-family: var(--font-mono); margin-top: 8px; display: none; }

/* ===================================================================
   20. CONFIRM DIALOG
   =================================================================== */
.dialog-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 150;
  background: var(--scrim);
  align-items: center; justify-content: center;
  padding: 20px;
}
.dialog-overlay.active { display: flex; }

.dialog-box {
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  animation: slideDown 0.15s ease-out;
}
.dialog-box .icon { font-size: 36px; margin-bottom: 12px; }
.dialog-box h3 { font-family: var(--font-mono); font-size: var(--fs-lg); margin-bottom: 8px; }
.dialog-box p { color: var(--fg-1); font-size: var(--fs-md); margin-bottom: 20px; line-height: 1.5; }
.dialog-box .btn-group { justify-content: center; }

/* ===================================================================
   21. RESPONSIVE (MOBILE)
   =================================================================== */
@media (max-width: 640px) {
  .page { padding: 16px 12px 32px; }
  .bento-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 17px; }
  .header { padding: 0 12px; }
  .header-stats { display: none; }
  .phone-meta { grid-template-columns: 1fr 1fr; }
  .form-row { flex-direction: column; }
  .form-row > * { flex: none; }
  .toast-stack { left: 16px; right: 16px; max-width: none; }
  .btn-group.grow .btn { font-size: 11px; padding: 6px 8px; }
}
