/* ============================================
   VibeDrop Widget — Settings UI Styles
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-base:        #0d0d12;
  --bg-surface:     #13131a;
  --bg-elevated:    #1a1a24;
  --bg-hover:       #1f1f2e;
  --border-subtle:  rgba(255, 255, 255, 0.07);
  --border-focus:   rgba(124, 58, 237, 0.6);
  --accent-violet:  #7c3aed;
  --accent-violet-light: #a78bfa;
  --accent-violet-glow:  rgba(124, 58, 237, 0.25);
  --text-primary:   #f0f0f5;
  --text-secondary: #8b8ba0;
  --text-muted:     #555568;
  --success:        #22c55e;
  --success-glow:   rgba(34, 197, 94, 0.2);
  --toggle-on:      #7c3aed;
  --toggle-off:     #2a2a3a;
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      14px;
  --radius-full:    999px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

html, body {
  min-height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- App Container ---- */
.vd-app {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0 16px;
  max-width: 100%;
}

/* ---- Header ---- */
.vd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 10;
}

.vd-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vd-logo-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.vd-logo-accent {
  color: var(--accent-violet-light);
}

.vd-tagline {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.vd-fallback-note {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px 12px;
  margin: 12px 16px 0;
  padding: 10px 12px;
  border: 1px solid rgba(167, 139, 250, 0.22);
  border-radius: var(--radius-md);
  background: rgba(124, 58, 237, 0.08);
  color: var(--text-secondary);
  font-size: 11px;
}

.vd-fallback-note strong {
  color: var(--text-primary);
}

.vd-fallback-note a {
  color: var(--accent-violet-light);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.vd-fallback-note a:hover {
  text-decoration: underline;
}

@media (max-width: 520px) {
  .vd-fallback-note {
    grid-template-columns: 1fr;
  }
}

/* ---- Section ---- */
.vd-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.vd-section:last-child {
  border-bottom: none;
}

/* ---- Label ---- */
.vd-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

/* ---- Textarea ---- */
.vd-textarea-wrap {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  overflow: hidden;
  transition: border-color 0.15s;
}

.vd-textarea-wrap:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-violet-glow);
}

.vd-textarea {
  width: 100%;
  min-height: 160px;
  padding: 12px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.6;
  resize: vertical;
  tab-size: 2;
}

.vd-textarea::placeholder {
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
}

.vd-textarea-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

.vd-char-count {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.vd-clear-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.vd-clear-btn:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
  background: var(--bg-hover);
}

/* ---- Toggles ---- */
.vd-toggles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vd-toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}

.vd-toggle-row:hover {
  background: var(--bg-hover);
  border-color: rgba(124, 58, 237, 0.2);
}

.vd-toggle-row + .vd-toggle-row {
  margin-top: 4px;
}

/* Toggle pill */
.vd-toggle {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
}

.vd-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.vd-toggle-slider {
  display: block;
  width: 36px;
  height: 20px;
  background: var(--toggle-off);
  border-radius: var(--radius-full);
  transition: background 0.2s;
  position: relative;
  border: 1px solid rgba(255,255,255,0.06);
}

.vd-toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  background: #fff;
  transition: transform 0.2s, background 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.vd-toggle input:checked + .vd-toggle-slider {
  background: var(--toggle-on);
  border-color: rgba(124, 58, 237, 0.4);
}

.vd-toggle input:checked + .vd-toggle-slider::after {
  transform: translateX(16px);
}

/* Toggle info */
.vd-toggle-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.vd-toggle-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.vd-toggle-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.vd-toggle-desc code {
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 10.5px;
  background: rgba(124, 58, 237, 0.15);
  color: var(--accent-violet-light);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid rgba(124, 58, 237, 0.2);
}

/* ---- Popup Config ---- */
.vd-popup-config {
  background: linear-gradient(135deg, rgba(124,58,237,0.06), rgba(124,58,237,0.02));
  border-top: 1px solid rgba(124, 58, 237, 0.2) !important;
}

.vd-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 12.5px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.vd-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-violet-glow);
}

.vd-input::placeholder {
  color: var(--text-muted);
}

.vd-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---- Apply Button ---- */
.vd-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.vd-apply-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
  font-family: var(--font);
}

.vd-apply-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
  filter: brightness(1.05);
}

.vd-apply-btn:active {
  transform: translateY(0);
}

.vd-apply-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.vd-apply-status {
  font-size: 12px;
  color: var(--success);
  opacity: 0;
  transition: opacity 0.3s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.vd-apply-status.visible {
  opacity: 1;
}

.vd-apply-status.error {
  color: #f87171;
}

/* ---- Footer Info Pills ---- */
.vd-footer {
  padding: 10px 16px 0;
}

.vd-footer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.vd-info-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 10.5px;
  color: var(--text-secondary);
}

.vd-info-pill svg {
  color: var(--success);
  flex-shrink: 0;
}

/* ---- Live Preview ---- */
.vd-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.vd-device-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.vd-device-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.vd-device-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.vd-device-btn.active {
  background: var(--accent-violet);
  color: #fff;
}

.vd-preview-stage {
  position: relative;
  width: 100%;
  height: 460px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background:
    linear-gradient(45deg, #16161f 25%, transparent 25%),
    linear-gradient(-45deg, #16161f 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #16161f 75%),
    linear-gradient(-45deg, transparent 75%, #16161f 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  display: flex;
  justify-content: center;
}

.vd-preview-scaler {
  width: 100%;
}

.vd-preview-frame {
  width: 100%;
  height: 460px;
  border: 0;
  display: block;
  background: #fff;
}

/* ---- Editor tools (mode + device toggles) ---- */
.vd-editor-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vd-mode-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.vd-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s, color 0.15s;
}

.vd-mode-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.vd-mode-btn.active { background: var(--accent-violet); color: #fff; }

/* ---- Section rail ---- */
.vd-sec-wrap {
  margin-bottom: 10px;
}

.vd-sec-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 210px;
  overflow-y: auto;
  padding-right: 2px;
}

.vd-sec-empty {
  padding: 14px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

.vd-sec-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.vd-sec-row:hover {
  background: var(--bg-hover);
  border-color: rgba(124, 58, 237, 0.3);
}

.vd-sec-row.is-hidden { opacity: 0.5; }

.vd-sec-num {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  flex-shrink: 0;
}

.vd-sec-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.vd-sec-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vd-sec-meta {
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vd-sec-ctrls {
  display: flex;
  gap: 1px;
  flex-shrink: 0;
}

.vd-sec-ctrls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.vd-sec-ctrls button:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.vd-sec-ctrls button:disabled { opacity: 0.3; cursor: not-allowed; }
.vd-sec-ctrls button[data-act="del"]:hover { color: #f87171; }

.vd-sec-add {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  justify-content: center;
  margin-top: 6px;
  padding: 7px;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.vd-sec-add:hover {
  color: var(--text-primary);
  border-color: rgba(124, 58, 237, 0.4);
  background: var(--bg-elevated);
}

/* ---- Publish & Host ---- */
.vd-host-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.vd-host-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(124, 58, 237, 0.4);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s, border-color 0.15s;
}

.vd-host-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-violet);
}

.vd-host-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.vd-host-result {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.vd-host-url {
  flex: 1;
  font-size: 12px;
  color: var(--accent-violet-light);
  text-decoration: none;
  word-break: break-all;
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
}

.vd-host-url:hover { text-decoration: underline; }

.vd-host-copy {
  flex-shrink: 0;
  padding: 4px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.vd-host-copy:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

/* ---- Usage dashboard ---- */
.vd-usage-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.vd-usage-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: center;
}

.vd-usage-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-violet-light);
  font-variant-numeric: tabular-nums;
}

.vd-usage-lbl {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media (max-width: 420px) {
  .vd-usage-grid { grid-template-columns: 1fr; }
}

/* ---- HighLevel mobile mode support ---- */
.--mobile .vd-toggle-row {
  padding: 8px 10px;
}

.--mobile .vd-textarea {
  min-height: 120px;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.18);
}
