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

:root {
  --bg:          #0a0b1a;
  --surface:     rgba(255,255,255,0.04);
  --surface-2:   rgba(255,255,255,0.08);
  --border:      rgba(255,255,255,0.08);
  --accent:      #6366f1;
  --accent-glow: rgba(99,102,241,0.35);
  --green:       #22c55e;
  --amber:       #f59e0b;
  --red:         #ef4444;
  --text:        #e2e8f0;
  --text-muted:  #64748b;
  --radius:      16px;
  --radius-sm:   8px;
  --font:        'Inter', system-ui, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Background Orbs ────────────────────────────────────────────────── */
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orb {
  position: absolute; border-radius: 50%;
  filter: blur(90px); opacity: 0.20;
}
.orb-1 { width: 500px; height: 500px; background: #6366f1; top: -100px; left: -100px; animation: drift 12s ease-in-out infinite alternate; }
.orb-2 { width: 400px; height: 400px; background: #06b6d4; bottom: 0; right: -100px; animation: drift 16s ease-in-out infinite alternate-reverse; }
.orb-3 { width: 300px; height: 300px; background: #8b5cf6; top: 50%; left: 50%; animation: drift 10s ease-in-out infinite alternate; }

@keyframes drift {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(40px, 30px) scale(1.1); }
}

/* ─── Layout ─────────────────────────────────────────────────────────── */
.header, .main, .footer { position: relative; z-index: 1; }

.header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  background: rgba(10,11,26,0.7);
  position: sticky; top: 0; z-index: 100;
}
.header-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 26px; }
.logo-text { font-size: 20px; font-weight: 700; color: white; }
.logo-sub { font-size: 12px; color: var(--text-muted); margin-left: 4px; }

.status-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 100px; padding: 6px 14px; font-size: 13px;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  transition: background .4s;
}
.status-pill.online .status-dot { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse-dot 2s infinite; }
.status-pill.offline .status-dot { background: var(--red); }

@keyframes pulse-dot {
  0%,100% { box-shadow: 0 0 6px var(--green); }
  50%      { box-shadow: 0 0 14px var(--green); }
}

.main { max-width: 1200px; margin: 0 auto; padding: 40px 24px; }

.page-title { text-align: center; margin-bottom: 40px; }
.page-title h1 { font-size: clamp(28px, 4vw, 42px); font-weight: 800; background: linear-gradient(135deg, #e2e8f0, #6366f1); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.page-title p { color: var(--text-muted); margin-top: 10px; font-size: 15px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

/* ─── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: blur(24px);
}
.card-title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title .icon { font-size: 20px; }
.card-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; margin-bottom: 24px; }

/* ─── Cloud Config Banner ────────────────────────────────────────────── */
.cloud-config {
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 28px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.cloud-config input {
  flex: 1;
  font-size: 13px;
}
.cloud-config label {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: 0;
}
.cloud-config .field-group { flex: 1; margin: 0; }
.btn-connect {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .2s, transform .1s;
}
.btn-connect:hover { opacity: .85; transform: translateY(-1px); }

/* ─── Form Fields ────────────────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.unit { color: var(--text-muted); font-weight: 400; }
.slider-value {
  font-weight: 700;
  color: var(--accent);
  min-width: 44px;
  text-align: right;
}
.field-group input[type="text"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field-group input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Range Slider */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  background: var(--surface-2);
  border-radius: 100px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
  cursor: pointer;
  transition: transform .1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

.range-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }
.slider-group { gap: 10px; }

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity .2s, transform .15s, box-shadow .2s;
  margin-top: 8px;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) { opacity: .9; transform: translateY(-2px); box-shadow: 0 8px 30px var(--accent-glow); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  font-family: var(--font);
  transition: border-color .2s, color .2s;
  margin-top: 16px;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }

/* Presets */
.presets { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.preset-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 10px; font-weight: 600; }
.preset-row { display: flex; gap: 8px; flex-wrap: wrap; }
.preset-btn {
  flex: 1; min-width: 100px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: all .2s;
}
.preset-low:hover    { border-color: var(--green); color: var(--green); }
.preset-moderate:hover { border-color: var(--amber); color: var(--amber); }
.preset-high:hover   { border-color: var(--red); color: var(--red); }

/* ─── Result States ───────────────────────────────────────────────────── */
.result-idle { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.idle-icon { font-size: 48px; margin-bottom: 12px; }
.idle-sub { font-size: 13px; margin-top: 6px; }

/* Loading */
.result-loading { text-align: center; padding: 30px 20px; }
.spinner-wrap { display: flex; justify-content: center; margin-bottom: 20px; }
.spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--surface-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title { font-size: 16px; font-weight: 600; margin-bottom: 20px; }
.loading-steps { text-align: left; max-width: 260px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.step { font-size: 13px; color: var(--text-muted); transition: color .3s; }
.step.step-done { color: var(--green); }
.step.step-active { color: var(--text); }
.step.dim { opacity: .4; }

/* Result Output */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; margin-bottom: 24px; }
.gauge { width: 220px; }
#gaugeProgress { transition: stroke-dashoffset 1s cubic-bezier(.4,0,.2,1); }
.category-badge {
  margin-top: 8px;
  padding: 6px 24px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.category-low      { background: rgba(34,197,94,.15); color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.category-moderate { background: rgba(245,158,11,.15); color: var(--amber); border: 1px solid rgba(245,158,11,.3); }
.category-high     { background: rgba(239,68,68,.15);  color: var(--red);   border: 1px solid rgba(239,68,68,.3); }

/* Flags */
.flags-section { margin-bottom: 20px; }
.flags-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 600; margin-bottom: 8px; }
.flags-list { display: flex; flex-wrap: wrap; gap: 8px; }
.flag-tag {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 100px;
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.2);
  color: #fca5a5;
}
.no-flags { color: var(--green); font-size: 13px; }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.stat-label { font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: .06em; }
.stat-value { font-size: 15px; font-weight: 600; margin-top: 4px; }

/* Meta */
.meta-row { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.8; }
.meta-row span { color: var(--text); }

/* Raw JSON */
.raw-json {
  background: rgba(0,0,0,.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 12px;
  overflow-x: auto;
  color: #94a3b8;
  margin-top: 8px;
  max-height: 200px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
}

/* Error */
.result-error { text-align: center; padding: 50px 20px; }
.error-icon { font-size: 48px; margin-bottom: 12px; }
.error-title { font-size: 16px; font-weight: 600; color: var(--red); }
.error-msg { font-size: 13px; color: var(--text-muted); margin-top: 8px; max-width: 300px; margin-inline: auto; }

/* History */
.history-card { margin-top: 24px; }
.history-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.empty-history { color: var(--text-muted); font-size: 14px; text-align: center; padding: 20px; }
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: background .2s;
}
.history-item:hover { background: rgba(255,255,255,.08); }
.history-item .h-left { display: flex; flex-direction: column; gap: 2px; }
.history-item .h-id { font-family: 'Courier New', monospace; font-size: 11px; color: var(--text-muted); }
.history-item .h-device { font-weight: 500; }
.history-item .h-badge { padding: 3px 10px; border-radius: 100px; font-size: 11px; font-weight: 600; text-transform: uppercase; }

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

/* Utilities */
.hidden { display: none !important; }
