/* ============================================================
   ASD BRIDGE
   ------------------------------------------------------------
   Restyles the All Social Downloader Client widget
   ([all_social_downloader] / [retatube_downloader]) to match this
   theme, without touching the plugin.

   The plugin declares its own custom properties on .asd-widget,
   so almost all of this is token remapping rather than CSS
   overrides — which means plugin updates can't break it, and its
   own layout, JS states and responsive rules keep working.

   Class names below are the plugin's own (asd-*). Don't rename
   them; they're the contract.
   ============================================================ */

.asd-widget {
  /* Colour */
  --asd-ink:        var(--md-text);
  --asd-ink-soft:   var(--md-text-2);
  --asd-muted:      var(--md-muted);
  --asd-border:     var(--md-border);
  --asd-bg:         var(--md-surface);
  --asd-panel:      var(--md-surface-alt);

  /* The plugin ships a cyan→violet gradient. This design has one
     accent, so both stops become the accent and the "gradient"
     flattens to a solid fill. */
  --asd-grad-start: var(--md-accent);
  --asd-grad-end:   var(--md-accent);

  /* Shape — inherit the theme's radius scale so sharp/balanced/soft
     from the setup wizard carries into the widget. */
  --asd-radius-lg:  var(--md-r-card);
  --asd-radius-md:  var(--md-r-input);
  --asd-radius-sm:  var(--md-r-input);

  --asd-shadow:     var(--md-shadow-tool);

  max-width: 100%;
  font-family: inherit;
}

/* ---------- input row ----------
   One field, one border. The row is the input: it owns the border, the
   radius and the focus ring, and everything inside it — the text input,
   the paste control, the submit button — is drawn without a border of its
   own so the control never reads as a box inside a box.
   The plugin ships a 999px pill; this system's inputs are rectangles on a
   shared radius, so it squares off to match the rest of the UI. */
.asd-widget .asd-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--md-border-strong);
  border-radius: var(--md-r-button);
  padding: 7px 7px 7px 16px;
  box-shadow: none;
  background: var(--md-surface);
  transition: border-color .15s var(--md-ease, ease), box-shadow .15s var(--md-ease, ease);
}
.asd-widget .asd-input-row:focus-within {
  border-color: var(--md-accent);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--md-accent) 18%, transparent);
}
/* The text input is a bare text run inside that border. */
.asd-widget .asd-input,
.asd-widget .asd-input-row input[type="text"],
.asd-widget .asd-input-row input[type="url"],
.asd-widget .asd-input-row input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  border: 0 !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  font: inherit;
  font-size: 15.5px;
  padding: 0;
  color: var(--md-text) !important;
  -webkit-text-fill-color: var(--md-text);
}
.asd-widget .asd-input:focus,
.asd-widget .asd-input-row input:focus { outline: none !important; box-shadow: none !important; }
.asd-widget .asd-input::placeholder,
.asd-widget .asd-input-row input::placeholder { color: var(--md-muted); opacity: 1; }
/* Chrome's autofill repaints the field white with dark text; hold the tokens. */
.asd-widget .asd-input:-webkit-autofill,
.asd-widget .asd-input-row input:-webkit-autofill {
  -webkit-text-fill-color: var(--md-text);
  box-shadow: 0 0 0 100px var(--md-surface) inset !important;
}
/* Nothing nested inside the row draws a border either. */
.asd-widget .asd-input-row > *:not(.asd-submit):not(.asd-paste-btn) { border: 0; background: none; }
.asd-widget .asd-input-row .asd-icon,
.asd-widget .asd-input-row svg { flex: none; color: var(--md-muted); }

.asd-widget .asd-paste-btn {
  border-radius: var(--md-r-button);
  border-color: var(--md-border);
  background: var(--md-surface-alt);
  color: var(--md-text-2);
  font-size: 13px;
  padding: 9px 14px;
}
.asd-widget .asd-paste-btn:hover {
  background: var(--md-accent-soft);
  border-color: var(--md-accent);
  color: var(--md-accent-dark);
}

/* ---------- primary buttons ----------
   Flat accent fill, accent-tinted lift on hover, no purple glow. */
.asd-widget .asd-submit,
.asd-widget .asd-download-btn,
.asd-widget .asd-tab.is-active {
  background: var(--md-accent);
  border-radius: var(--md-r-button);
  box-shadow: none;
}
.asd-widget .asd-submit {
  flex: none;
  height: 44px;
  padding: 0 22px;
  border: 0;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -.005em;
  color: #fff;
}
.asd-widget .asd-paste-btn { flex: none; height: 36px; }
.asd-widget .asd-submit:hover:not(:disabled),
.asd-widget .asd-download-btn:hover {
  background: var(--md-accent-dark);
  transform: none;
  box-shadow: none;
}
.asd-widget .asd-submit:focus-visible,
.asd-widget .asd-download-btn:focus-visible,
.asd-widget .asd-paste-btn:focus-visible,
.asd-widget .asd-tab:focus-visible {
  outline: 2px solid var(--md-accent);
  outline-offset: 2px;
}
.asd-widget .asd-download-btn {
  font-size: 13.5px;
  padding: 12px 18px;
}

/* ---------- cards, hero, skeleton ---------- */
.asd-widget .asd-hero-card,
.asd-widget .asd-card,
.asd-widget .asd-skeleton {
  border-color: var(--md-border);
  box-shadow: var(--md-shadow-tool);
}
.asd-widget .asd-hero-title {
  font-family: var(--md-font-heading, inherit);
  font-size: 15.5px;
  color: var(--md-text);
}
.asd-widget .asd-hero-media,
.asd-widget .asd-card-thumb { background: #101318; }

.asd-widget .asd-quality-select {
  border-radius: var(--md-r-input);
  border-color: var(--md-border-strong);
  background: var(--md-surface);
  color: var(--md-text);
}
.asd-widget .asd-quality-select:focus {
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--md-accent) 22%, transparent);
  border-color: var(--md-accent);
}

/* ---------- chips, tabs, meta ---------- */
.asd-widget .asd-tab { border-radius: var(--md-r-button); }
.asd-widget .asd-cached-chip {
  border-radius: 999px;
  color: var(--md-success);
  background: color-mix(in oklab, var(--md-success) 10%, transparent);
  border-color: color-mix(in oklab, var(--md-success) 28%, transparent);
}
.asd-widget .asd-platform-badge { background: var(--md-accent); }

/* ---------- alerts — reuse the system's error treatment ---------- */
.asd-widget .asd-alert {
  border-radius: var(--md-r-card);
  font-size: 14px;
}
.asd-widget .asd-alert-error {
  background: color-mix(in oklab, var(--md-error) 7%, var(--md-surface));
  border-color: color-mix(in oklab, var(--md-error) 32%, transparent);
  color: var(--md-error);
}
.asd-widget .asd-alert-error .asd-alert-icon { background: var(--md-error); }

/* ---------- skeleton shimmer, retuned to the theme's greys ---------- */
.asd-widget .asd-skeleton-thumb,
.asd-widget .asd-skeleton-line {
  background: linear-gradient(100deg, var(--md-divider) 30%, var(--md-surface-alt) 45%, var(--md-divider) 60%);
  background-size: 200% 100%;
}
.asd-widget .asd-skeleton-line.btn { border-radius: var(--md-r-button); }

/* ============================================================
   DARK MODE
   The plugin has none of its own, so this is the whole of it:
   remap the same properties to the theme's dark values.
   ============================================================ */
html[data-md-theme="dark"] .asd-widget {
  --asd-ink:      var(--md-text);
  --asd-ink-soft: var(--md-text-2);
  --asd-muted:    var(--md-muted);
  --asd-border:   var(--md-border);
  --asd-bg:       var(--md-surface);
  --asd-panel:    var(--md-surface-alt);
}
html[data-md-theme="dark"] .asd-widget .asd-input-row,
html[data-md-theme="dark"] .asd-widget .asd-quality-select {
  background: var(--md-surface-alt);
}
/* The plugin repaints the field on focus, which left light text on a light
   field in dark mode. The input stays transparent in every state. */
html[data-md-theme="dark"] .asd-widget .asd-input,
html[data-md-theme="dark"] .asd-widget .asd-input:focus,
html[data-md-theme="dark"] .asd-widget .asd-input-row input,
html[data-md-theme="dark"] .asd-widget .asd-input-row input:focus {
  background: transparent !important;
  color: var(--md-text) !important;
  -webkit-text-fill-color: var(--md-text);
  caret-color: var(--md-accent);
}
html[data-md-theme="dark"] .asd-widget .asd-input:-webkit-autofill,
html[data-md-theme="dark"] .asd-widget .asd-input-row input:-webkit-autofill {
  box-shadow: 0 0 0 100px var(--md-surface-alt) inset !important;
}
html[data-md-theme="dark"] .asd-widget .asd-admin-notice {
  background: color-mix(in oklab, var(--md-warning) 14%, var(--md-surface));
  border-color: color-mix(in oklab, var(--md-warning) 36%, transparent);
  color: var(--md-text);
}

/* ============================================================
   REDUCED MOTION — the plugin animates unconditionally.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .asd-widget .asd-hero-card,
  .asd-widget .asd-card,
  .asd-widget .asd-skeleton,
  .asd-widget .asd-alert,
  .asd-widget .asd-tab-panel.is-active { animation: none; }
  .asd-widget .asd-skeleton-thumb,
  .asd-widget .asd-skeleton-line { animation: none; }
}

/* ============================================================
   SLOT CHROME
   The theme's own trust chips and fineprint, reused around the
   plugin widget so the section reads the same either way.
   ============================================================ */
/* The slot draws the card (.md-tool-slot__card), so the widget inside it must
   not draw a second one, and must not add its own outer spacing — otherwise
   the form sits in a box inside a box with a double gutter. */
.md-tool-slot__card .asd-widget {
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  max-width: none;
}
.md-tool-slot__card .asd-widget > :first-child { margin-top: 0; }
.md-tool-slot__card .asd-widget > :last-child  { margin-bottom: 0; }
.md-tool-slot__card .asd-widget form { margin: 0; }

/* Trust chips read left-to-right under the field, as in the design system;
   only the rights line below the card is centred. */
.md-tool-slot--asd .md-tool__trust { justify-content: flex-start; margin-top: 20px; }
