/* ===== Base ===== */
:root {
  --bg0: #070a0c;
  --bg1: #0b0f14;
  --card: rgba(255, 255, 255, 0.06);
  --card2: rgba(255, 255, 255, 0.08);
  --stroke: rgba(255, 255, 255, 0.10);
  --stroke2: rgba(255, 255, 255, 0.16);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.62);
  --muted2: rgba(255, 255, 255, 0.46);
  --accent: #ffc83d;
  --accent2: rgba(255, 200, 61, 0.25);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% 20%, rgba(34, 120, 58, 0.25), transparent 55%),
              radial-gradient(900px 500px at 90% 10%, rgba(255, 200, 61, 0.12), transparent 60%),
              linear-gradient(180deg, var(--bg0), var(--bg1));
  min-height: 100vh;
}

/* keep compatibility with older global css that set black background */
body { background-color: transparent !important; }

/* ===== Appbar (same family as Home/Login) ===== */
.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(
    90deg,
    rgba(18, 50, 24, 0.85),
    rgba(0, 0, 0, 0.85) 45%,
    rgba(45, 32, 12, 0.85)
  );
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.appbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.traffic-lights {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.25);
}

.traffic-lights span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.traffic-lights span:nth-child(1) { background: #ff5f56; }
.traffic-lights span:nth-child(2) { background: #ffbd2e; }
.traffic-lights span:nth-child(3) { background: #27c93f; }

.brand { display: flex; flex-direction: column; line-height: 1.05; }
.brand-title { font-weight: 800; letter-spacing: 0.3px; }
.brand-sub { font-size: 12px; color: var(--muted2); }

.appbar-right { display: flex; align-items: center; gap: 10px; }

.appbar-btn {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  text-decoration: none;
  font-size: 0.92rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}
.appbar-btn:hover {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.08);
}

/* ===== Background glow ===== */
.bg-glow {
  position: fixed;
  inset: -120px -120px auto -120px;
  height: 380px;
  pointer-events: none;
  background: radial-gradient(500px 220px at 20% 60%, rgba(34, 120, 58, 0.22), transparent 70%),
              radial-gradient(520px 240px at 85% 40%, rgba(255, 200, 61, 0.16), transparent 75%);
  filter: blur(10px);
  z-index: 0;
}

/* ===== Layout ===== */
.page {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

.hero {
  padding: 22px 10px 18px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: var(--muted);
  font-size: 0.95rem;
}

.hero-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 200, 61, 0.12);
}

.hero-title {
  margin: 16px 0 8px;
  font-size: 40px;
  letter-spacing: -0.02em;
}

.hero-sub {
  margin: 0;
  color: var(--muted);
  max-width: 62ch;
  line-height: 1.55;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 14px;
}

@media (min-width: 920px) {
  .grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

/* ===== Cards ===== */
.card {
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, var(--card), rgba(0,0,0,0.10));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-head {
  padding: 18px 18px 10px;
}

.card-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.2px;
}

.card-sub {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.card-actions {
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.hint {
  margin-top: 10px;
  color: var(--muted2);
  font-size: 0.92rem;
}

/* ===== Controls ===== */
.controls {
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.label {
  display: block;
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--stroke2);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  outline: none;
  appearance: none;
}

.select:focus {
  border-color: rgba(255, 200, 61, 0.65);
  box-shadow: 0 0 0 4px rgba(255, 200, 61, 0.12);
}

.micro {
  margin-top: 12px;
  color: var(--muted2);
  line-height: 1.5;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* ===== Buttons ===== */
.btn {
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  line-height: 1;
  user-select: none;
}

.btn-primary {
  background: rgba(255, 200, 61, 0.14);
  border-color: rgba(255, 200, 61, 0.55);
  color: var(--text);
}

.btn-primary:hover {
  background: rgba(255, 200, 61, 0.22);
  border-color: rgba(255, 200, 61, 0.75);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.30);
}

/* Keep old IDs compatible but make them match the new styling */
#saveImageButton { width: auto; margin: 0; }
#refreshButton { width: auto; margin: 0; }
#refreshButtonBox { display: none; } /* no longer used, Refresh is in the row now */

/* ===== Output ===== */
.output {
  margin-top: 16px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(0,0,0,0.10));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.output-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.output-title {
  margin: 0;
  font-size: 18px;
}

.output-sub {
  margin: 8px 0 0;
  color: var(--muted2);
}

.image-frame {
  padding: 14px;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* This is used by your JS when the image is injected */
#imageElement {
  width: min(960px, 100%);
  height: auto;
  max-width: 100%;
  max-height: min(72vh, 760px);
  object-fit: contain;
  display: block;
  margin: auto;
  border-radius: 14px;
  box-shadow: 0 18px 55px rgba(0,0,0,0.65);
  border: 1px solid rgba(255,255,255,0.08);
}

/* ===== No Data Box ===== */
#noDataBox {
  display: none;
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.nodata-title {
  font-weight: 800;
  margin-bottom: 6px;
}

.nodata-sub {
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.5;
}

.nodata-note {
  color: var(--muted2);
  margin-top: 12px;
  line-height: 1.5;
}

/* ===== Footer ===== */
.footer {
  margin-top: 18px;
  padding: 14px 4px 0;
  color: var(--muted2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-brand { color: var(--text); font-weight: 800; }
.footer-sep { margin: 0 8px; color: rgba(255,255,255,0.22); }

/* ===== Loader (kept from your old CSS, only slightly cleaned) ===== */
.loader {
  width: 5rem;
  height: 7rem;
  margin: 10px auto 0;
  overflow: hidden;
  position: relative;
}

.loader-inner {
  height: 60px;
  margin: auto;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100px;
  transform: translate(-50%, -50%);
}

.loader-line-wrap {
  animation: spin 2000ms cubic-bezier(.175, .885, .32, 1.275) infinite;
  box-sizing: border-box;
  height: 50px;
  left: 0;
  overflow: hidden;
  position: absolute;
  top: 0;
  transform-origin: 50% 100%;
  width: 100px;
}

.loader-line {
  border: 4px solid transparent;
  border-radius: 100%;
  box-sizing: border-box;
  height: 100px;
  left: 0;
  margin: 0 auto;
  position: absolute;
  right: 0;
  top: 0;
  width: 100px;
}

.loader-line-wrap:nth-child(1) { animation-delay: -50ms; }
.loader-line-wrap:nth-child(2) { animation-delay: -100ms; }
.loader-line-wrap:nth-child(3) { animation-delay: -150ms; }
.loader-line-wrap:nth-child(4) { animation-delay: -200ms; }
.loader-line-wrap:nth-child(5) { animation-delay: -250ms; }

.loader-line-wrap:nth-child(1) .loader-line {
  border-color: hsl(0, 80%, 60%);
  height: 90px;
  width: 90px;
  top: 7px;
}
.loader-line-wrap:nth-child(2) .loader-line {
  border-color: hsl(60, 80%, 60%);
  height: 76px;
  width: 76px;
  top: 14px;
}
.loader-line-wrap:nth-child(3) .loader-line {
  border-color: hsl(120, 80%, 60%);
  height: 62px;
  width: 62px;
  top: 21px;
}
.loader-line-wrap:nth-child(4) .loader-line {
  border-color: hsl(180, 80%, 60%);
  height: 48px;
  width: 48px;
  top: 28px;
}
.loader-line-wrap:nth-child(5) .loader-line {
  border-color: hsl(240, 80%, 60%);
  height: 34px;
  width: 34px;
  top: 35px;
}

@keyframes spin {
  0%, 15% { transform: rotate(0); }
  100% { transform: rotate(360deg); }
}
