/* Ad Testing Playground — lightweight, mobile-app-like shell */

:root {
  --bg-deep: #0c0e12;
  --bg-card: #161a22;
  --bg-elevated: #1e2430;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eaef;
  --text-muted: #8b93a5;
  --accent: #3d8bfd;
  --accent-soft: rgba(61, 139, 253, 0.15);
  --gold: #f4c430;
  --success: #34c759;
  --danger: #ff6b6b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --max-width: 420px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(165deg, #12151c 0%, var(--bg-deep) 45%, #0a0c10 100%);
  line-height: 1.45;
}

.app-shell {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  min-height: 100dvh;
}

.app-header {
  text-align: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.app-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #fff 0%, #a8b4cc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.app-subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow);
}

.card__title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.card__desc {
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.card__hint {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--accent);
}

/* Config */
.card--config {
  background: linear-gradient(145deg, var(--bg-elevated) 0%, var(--bg-card) 100%);
}

.config-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle__ui {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #2a3140;
  border: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}

.toggle__ui::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.toggle input:checked + .toggle__ui {
  background: var(--accent);
  border-color: transparent;
}

.toggle input:checked + .toggle__ui::after {
  transform: translateX(16px);
}

.toggle__label {
  font-size: 0.85rem;
  color: var(--text);
}

.config-url {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.config-url__label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.config-url__input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--text);
  font-size: 0.8rem;
}

.config-url__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Stats + log */
.stats-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.stat {
  flex: 1;
  background: var(--bg-deep);
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  text-align: center;
  border: 1px solid var(--border);
}

.stat__value {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.stat__label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.log-panel__title {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0.6rem;
  max-height: 120px;
  overflow-y: auto;
  background: var(--bg-deep);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-family: ui-monospace, "Cascadia Code", monospace;
  color: #b4bcc8;
}

.log-list li {
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.log-list li:last-child {
  border-bottom: none;
}

.log-list .log-time {
  color: var(--text-muted);
  margin-right: 0.35rem;
}

/* Banners */
.banner-stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.ad-slot {
  min-height: 52px;
  border-radius: var(--radius-sm);
  border: 2px dashed rgba(61, 139, 253, 0.35);
  background: rgba(61, 139, 253, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

/* 728×90 iframe can exceed narrow phone width */
.ad-slot--top {
  display: block;
  overflow-x: auto;
  text-align: center;
}

/* Sticky anchor-style bar (viewport bottom) — typical for mobile web apps */
.ad-slot--bottom.ad-slot--sticky {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, var(--max-width));
  max-width: var(--max-width);
  z-index: 50;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin: 0;
}

body.has-banner-footer {
  padding-bottom: 58px;
}

.ad-slot.hidden-slot {
  display: none;
}

.ad-slot__label {
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.banner-content {
  padding: 0.75rem;
  background: var(--bg-deep);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.ad-native-wrap {
  min-height: 120px;
  margin-bottom: 0.65rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(244, 196, 48, 0.25);
  background: rgba(244, 196, 48, 0.04);
}

.ad-slot__label--inline {
  display: block;
  margin-bottom: 0.35rem;
}

.banner-content__text {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.2s, opacity 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: linear-gradient(180deg, #4a9aff 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(61, 139, 253, 0.35);
}

.btn--accent {
  background: linear-gradient(180deg, #ffd54a 0%, var(--gold) 100%);
  color: #1a1408;
  box-shadow: 0 4px 14px rgba(244, 196, 48, 0.25);
}

.btn--secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--close {
  width: auto;
  margin-top: 0.75rem;
  padding: 0.5rem 1.25rem;
  background: var(--bg-deep);
  color: var(--text);
  border: 1px solid var(--border);
}

/* Progress */
.progress-wrap {
  margin-top: 0.85rem;
}

.progress-wrap.hidden {
  display: none;
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-deep);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar__fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #7eb6ff);
  transition: width 0.12s linear;
}

.progress-text {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.overlay.hidden {
  display: none;
}

.overlay__box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  text-align: center;
  max-width: 280px;
  box-shadow: var(--shadow);
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 1rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.overlay__title {
  margin: 0;
  font-size: 1rem;
}

.overlay__sub {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.fake-ad {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 320px;
  width: 100%;
  text-align: center;
}

.fake-ad__badge {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.fake-ad__title {
  margin: 0;
  font-size: 1.1rem;
}

.fake-ad__body {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 1001;
  padding: 0.65rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--success);
  color: var(--success);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: toastIn 0.35s ease;
}

.toast.hidden {
  display: none;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
}

.app-footer {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.app-footer p {
  margin: 0;
}

.hidden {
  display: none !important;
}
