/* ============================================================
   viewer.css — Mobile Viewer App Section Styles
   Depends on the CSS variables defined in styles.css
============================================================ */

/* ── Section wrapper ── */
#viewer-app {
  background: var(--bg-2);
  padding: 100px 0 120px;
  position: relative;
  overflow: hidden;
}
#viewer-app::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 900px; height: 300px;
  background: radial-gradient(ellipse, rgba(0, 240, 216, 0.06) 0%, transparent 70%);
  pointer-events: none;
}
.viewer-header p {
  max-width: 540px;
}

/* ── Shell ── */
.viewer-shell {
  background: var(--bg-card);
  border: 1px solid rgba(0, 240, 216, 0.18);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0,240,216,0.04);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Top Bar ── */
.viewer-topbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px 12px;
  background: rgba(5, 11, 24, 0.7);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
}

/* URL group row */
.viewer-url-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.viewer-url-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0 12px;
  height: 40px;
  transition: border-color 0.2s;
}
.viewer-url-bar:focus-within {
  border-color: rgba(0, 240, 216, 0.5);
  box-shadow: 0 0 0 3px rgba(0, 240, 216, 0.08);
}
.url-lock-icon {
  color: var(--text-dim);
  flex-shrink: 0;
}
.viewer-url-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
  min-width: 0;
}
.viewer-url-input::placeholder {
  color: var(--text-dim);
}
.viewer-url-clear {
  color: var(--text-dim);
  padding: 4px;
  border-radius: 4px;
  line-height: 0;
  transition: color 0.2s;
  flex-shrink: 0;
  display: none;
}
.viewer-url-clear:hover { color: var(--text); }
.viewer-url-clear.visible { display: flex; }

.viewer-load-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 18px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent) 0%, #00c9b8 100%);
  color: #050b18;
  font-weight: 700;
  font-size: 0.875rem;
  font-family: var(--font-body);
  border-radius: 8px;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 12px rgba(0, 240, 216, 0.3);
  white-space: nowrap;
}
.viewer-load-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0, 240, 216, 0.45);
}
.viewer-load-btn:active { transform: translateY(0); }
.viewer-load-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Presets row */
.viewer-presets {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.viewer-preset-btn {
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.viewer-preset-btn:hover {
  color: var(--accent);
  border-color: rgba(0, 240, 216, 0.4);
  background: rgba(0, 240, 216, 0.06);
}

/* Toolbar (right side icons) */
.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  padding-top: 4px;
}
.viewer-tool-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  line-height: 0;
}
.viewer-tool-btn:hover {
  color: var(--text);
  border-color: rgba(0, 240, 216, 0.3);
  background: rgba(0, 240, 216, 0.06);
}
.viewer-tool-btn.active {
  color: var(--accent);
  border-color: rgba(0, 240, 216, 0.5);
  background: rgba(0, 240, 216, 0.1);
}
.viewer-tool-accent {
  border-color: rgba(0, 240, 216, 0.25);
  color: var(--accent);
}
.viewer-tool-accent:hover {
  background: rgba(0, 240, 216, 0.12);
  border-color: var(--accent);
}

.viewer-zoom-group {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.viewer-zoom-group .viewer-tool-btn {
  border: none;
  border-radius: 0;
  background: transparent;
  width: 30px;
  height: 34px;
}
.viewer-zoom-group .viewer-tool-btn:hover {
  background: rgba(0,240,216,0.08);
  border: none;
}
.viewer-zoom-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 36px;
  text-align: center;
  padding: 0 2px;
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  line-height: 34px;
  height: 34px;
  display: block;
}

/* ── Device Picker Bar ── */
.viewer-device-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: rgba(5, 11, 24, 0.5);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-wrap: nowrap;
  min-height: 56px;
}
.viewer-device-bar::-webkit-scrollbar { display: none; }

.device-categories {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.device-cat-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 100px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.device-cat-btn:hover { color: var(--text); border-color: rgba(0,240,216,0.3); }
.device-cat-btn.active {
  color: var(--accent);
  background: rgba(0, 240, 216, 0.1);
  border-color: rgba(0, 240, 216, 0.4);
}

/* divider */
.device-categories::after {
  content: '';
  display: block;
  width: 1px;
  height: 28px;
  background: var(--border-subtle);
  margin: auto 4px;
}

.device-list {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.device-list::-webkit-scrollbar { display: none; }

.device-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.device-btn:hover {
  color: var(--text);
  border-color: rgba(0, 240, 216, 0.3);
}
.device-btn.active {
  color: var(--accent);
  background: rgba(0, 240, 216, 0.08);
  border-color: rgba(0, 240, 216, 0.45);
  box-shadow: 0 0 12px rgba(0, 240, 216, 0.1);
}
.device-btn-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: inherit;
  font-family: var(--font-body);
}
.device-btn-size {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* Custom size inputs */
.viewer-custom-size {
  display: none;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.viewer-custom-size[aria-hidden="false"] { display: flex; }
.custom-size-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.custom-size-input {
  width: 68px;
  height: 32px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-align: center;
  outline: none;
  padding: 0 6px;
  transition: border-color 0.2s;
}
.custom-size-input:focus { border-color: rgba(0,240,216,0.5); }
.custom-select { width: 56px; cursor: pointer; }
.custom-size-sep {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.dpr-label { margin-left: 8px; }
.viewer-apply-btn {
  height: 32px;
  padding: 0 14px;
  font-size: 0.8rem;
}

/* ── Info Strip ── */
.viewer-info-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  background: rgba(8, 15, 34, 0.6);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  overflow: hidden;
  white-space: nowrap;
}
.info-device-name { color: var(--accent); font-weight: 600; }
.info-sep { color: var(--text-dim); }
.info-spacer { flex: 1; }
.info-ua {
  color: var(--text-dim);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.65rem;
}

/* ── Stage ── */
.viewer-stage {
  position: relative;
  background:
    linear-gradient(rgba(0,240,216,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,240,216,0.015) 1px, transparent 1px),
    var(--bg);
  background-size: 20px 20px;
  min-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 32px 24px;
}

/* Empty state */
.viewer-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 40px 20px;
}
.viewer-empty-icon { opacity: 0.7; }
.viewer-empty-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
}
.viewer-empty-sub {
  font-size: 0.875rem;
  color: var(--text-dim);
  max-width: 340px;
  line-height: 1.6;
}
.viewer-empty-sub strong { color: var(--accent); font-weight: 600; }

/* Loading */
.viewer-loading {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: absolute;
  inset: 0;
  background: rgba(5,11,24,0.85);
  backdrop-filter: blur(4px);
  z-index: 20;
  justify-content: center;
}
.viewer-loading.visible { display: flex; }
.viewer-spinner {
  width: 36px; height: 36px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.viewer-loading-text {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Error */
.viewer-error {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
}
.viewer-error.visible { display: flex; }
.viewer-error-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--danger);
}
.viewer-error-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 360px;
  line-height: 1.6;
}
.viewer-ext-link {
  margin-top: 8px;
}

/* ── Device Frame Wrap ── */
.viewer-device-frame-wrap {
  display: none;
  position: relative;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.viewer-device-frame-wrap.visible { display: flex; }

/* Rulers */
.viewer-ruler {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  display: none;
}
.viewer-ruler.visible { display: block; }
.viewer-ruler-h {
  top: 0; left: 0; right: 0;
  height: 20px;
  background: repeating-linear-gradient(
    90deg,
    transparent, transparent 9px,
    rgba(0,240,216,0.15) 9px, rgba(0,240,216,0.15) 10px
  );
  border-bottom: 1px solid rgba(0,240,216,0.15);
}
.viewer-ruler-v {
  top: 0; left: 0; bottom: 0;
  width: 20px;
  background: repeating-linear-gradient(
    180deg,
    transparent, transparent 9px,
    rgba(0,240,216,0.15) 9px, rgba(0,240,216,0.15) 10px
  );
  border-right: 1px solid rgba(0,240,216,0.15);
}

/* Breakpoint badge */
.viewer-breakpoint-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  background: rgba(77,108,250,0.9);
  color: white;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  pointer-events: none;
  display: none;
  backdrop-filter: blur(4px);
}
.viewer-breakpoint-badge.visible { display: block; }

/* ── Device Chrome ── */
.viewer-device-chrome {
  position: relative;
  border-radius: 36px;
  background: #0e1a30;
  border: 2px solid rgba(0,240,216,0.25);
  box-shadow:
    0 0 0 1px rgba(0,240,216,0.06),
    0 32px 80px rgba(0,0,0,0.7),
    0 0 60px rgba(0,240,216,0.08),
    inset 0 0 0 1px rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  overflow: hidden;
}

/* Notch (phone) */
.device-notch {
  width: 120px; height: 28px;
  background: #0e1a30;
  border-radius: 0 0 20px 20px;
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.device-notch::after {
  content: '';
  width: 8px; height: 8px;
  background: rgba(0,240,216,0.4);
  border-radius: 50%;
}
.device-notch.hidden { display: none; }

/* Screen area */
.device-screen {
  width: 100%;
  flex: 1;
  overflow: hidden;
  background: #fff;
  position: relative;
  border-radius: 28px;
  margin: 28px 8px 24px;
}

/* Home bar */
.device-home-bar {
  width: 40%; height: 5px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.device-home-bar.hidden { display: none; }

/* iframe */
.viewer-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ── Status Bar ── */
.viewer-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px;
  background: rgba(5, 11, 24, 0.7);
  border-top: 1px solid var(--border-subtle);
}
.status-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-indicator {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.3s;
}
.status-indicator.loading { background: #ffc800; animation: pulse-dot 1s ease infinite; }
.status-indicator.success { background: var(--success); }
.status-indicator.error   { background: var(--danger); }
@keyframes pulse-dot {
  0%,100% { opacity: 1; } 50% { opacity: 0.4; }
}
.status-text {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}
.status-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.status-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.status-btn:hover { color: var(--accent); border-color: rgba(0,240,216,0.3); background: rgba(0,240,216,0.05); }
.status-btn.active { color: var(--accent); border-color: rgba(0,240,216,0.4); }

/* ── Toast ── */
.viewer-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 25, 50, 0.95);
  border: 1px solid rgba(0,240,216,0.25);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 10px 20px;
  border-radius: 100px;
  backdrop-filter: blur(16px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.viewer-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Fullscreen mode ── */
.viewer-shell.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9000;
  border-radius: 0;
  border: none;
}
.viewer-shell.fullscreen .viewer-stage {
  flex: 1;
  min-height: 0;
}
body.viewer-fullscreen { overflow: hidden; }

/* ── Landscape / rotated device ── */
.viewer-device-chrome.landscape {
  border-radius: 20px;
}
.viewer-device-chrome.landscape .device-screen {
  margin: 8px 28px;
  border-radius: 16px;
}
.viewer-device-chrome.landscape .device-notch {
  width: 28px; height: 60px;
  border-radius: 0 14px 14px 0;
  top: 50%; left: 0;
  transform: translateY(-50%);
  flex-direction: column;
}
.viewer-device-chrome.landscape .device-home-bar {
  width: 5px; height: 30%;
  margin: 0 12px 0 0;
  position: absolute;
  right: 0; top: 50%;
  transform: translateY(-50%);
}

/* ── Tablet chrome overrides ── */
.viewer-device-chrome.tablet {
  border-radius: 20px;
}
.viewer-device-chrome.tablet .device-notch {
  width: 12px; height: 12px;
  top: 50%; left: 8px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: #0e1a30;
}
.viewer-device-chrome.tablet .device-notch::after {
  width: 6px; height: 6px;
}
.viewer-device-chrome.tablet .device-home-bar { display: none; }
.viewer-device-chrome.tablet .device-screen { margin: 12px 8px; border-radius: 16px; }

/* ── Laptop chrome overrides ── */
.viewer-device-chrome.laptop {
  border-radius: 12px 12px 0 0;
}
.viewer-device-chrome.laptop .device-notch { display: none; }
.viewer-device-chrome.laptop .device-home-bar { display: none; }
.viewer-device-chrome.laptop .device-screen { margin: 32px 8px 8px; border-radius: 4px; }
.viewer-device-chrome.laptop::after {
  content: '';
  display: block;
  width: 130%;
  height: 18px;
  background: #0a1525;
  border: 1px solid rgba(0,240,216,0.15);
  border-top: none;
  border-radius: 0 0 12px 12px;
  position: absolute;
  bottom: -19px;
  left: 50%; transform: translateX(-50%);
}

/* ── Responsive ── */
@media (min-width: 900px) {
  .viewer-topbar {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }
  .viewer-url-group { flex: 1; min-width: 0; }
  .viewer-presets { flex: 0 0 auto; }
  .viewer-toolbar { margin-left: auto; }
}

@media (max-width: 768px) {
  #viewer-app { padding: 72px 0 80px; }
  .viewer-stage { min-height: 400px; padding: 20px 12px; }
  .viewer-topbar { padding: 12px; }
  .viewer-device-bar { padding: 8px 12px; }
  .viewer-info-strip { font-size: 0.68rem; padding: 6px 12px; }
  .viewer-statusbar { padding: 6px 12px; }
  .status-right { gap: 2px; }
  .info-ua { display: none; }
  .viewer-presets { display: none; }
  .viewer-toolbar { gap: 2px; }
}

@media (max-width: 480px) {
  .device-categories { gap: 2px; }
  .device-cat-btn { padding: 4px 8px; font-size: 0.7rem; }
  .status-btn span { display: none; }
}
