/**
 * Settings screen for Product Search for WooCommerce.
 *
 * Three columns: section navigation, settings, sidebar.
 *
 * Everything that was previously in this file styled markup this plugin does not
 * render - icon pickers, order-status metaboxes, a .wc-product-search-form table -
 * and had no matching selector anywhere in the codebase.
 */

.ajxsrc-wrap {
  --ajxsrc-accent: #2271b1;
  --ajxsrc-border: #dcdcde;
  --ajxsrc-bg: #fff;
  --ajxsrc-muted: #646970;
  --ajxsrc-ok: #00a32a;
  --ajxsrc-warn: #dba617;
  --ajxsrc-error: #d63638;
  --ajxsrc-radius: 6px;
  margin-right: 20px;
}

/**
 * Follow the admin colour scheme.
 *
 * The accent was a hardcoded blue, which is right only for the default scheme
 * and clashes with the other seven. WordPress puts the chosen scheme on <body>,
 * so the accent is remapped from there and every rule using the variable follows.
 */
body.admin-color-light .ajxsrc-wrap { --ajxsrc-accent: #0073aa; }
body.admin-color-modern .ajxsrc-wrap { --ajxsrc-accent: #3858e9; }
body.admin-color-blue .ajxsrc-wrap { --ajxsrc-accent: #096484; }
body.admin-color-coffee .ajxsrc-wrap { --ajxsrc-accent: #c7a589; }
body.admin-color-ectoplasm .ajxsrc-wrap { --ajxsrc-accent: #a3b745; }
body.admin-color-midnight .ajxsrc-wrap { --ajxsrc-accent: #e14d43; }
body.admin-color-ocean .ajxsrc-wrap { --ajxsrc-accent: #9ebaa0; }
body.admin-color-sunrise .ajxsrc-wrap { --ajxsrc-accent: #dd823b; }

.ajxsrc-app {
  margin-top: 16px;
}

/* Branding ---------------------------------------------------------------- */

.ajxsrc-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--ajxsrc-bg);
  border: 1px solid var(--ajxsrc-border);
  border-bottom: 0;
  border-radius: var(--ajxsrc-radius) var(--ajxsrc-radius) 0 0;
}

.ajxsrc-brand__mark {
  font-size: 26px;
  width: 26px;
  height: 26px;
  color: var(--ajxsrc-accent);
}

.ajxsrc-brand__text {
  flex: 1 1 auto;
  min-width: 0;
}

.ajxsrc-brand__title {
  margin: 0;
  padding: 0;
  font-size: 17px;
  line-height: 1.3;
  font-weight: 600;
}

.ajxsrc-brand__by {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ajxsrc-muted);
}

.ajxsrc-brand__version {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--ajxsrc-muted);
  border: 1px solid var(--ajxsrc-border);
  border-radius: 999px;
  padding: 2px 10px;
}

/* Layout ------------------------------------------------------------------ */

.ajxsrc-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 280px;
  /**
   * Columns stretch to the tallest of them, which is the default and is what
   * makes the rails' borders run the whole height. This was align-items:start,
   * so every column stopped at its own content: the section rail's right border
   * ended under the last tab, the sidebar's left border ended under the last
   * card, and the white panel ended wherever the longest column happened to
   * finish.
   */
  align-items: stretch;
  /**
   * Hold the panel down the page so switching sections does not resize it.
   * Subtracted: the admin bar, the .wrap and .ajxsrc-app margins, the branding
   * header and the admin footer. It is a minimum, so a section with more in it
   * than this simply grows.
   */
  min-height: calc(100vh - 200px);
  background: var(--ajxsrc-bg);
  border: 1px solid var(--ajxsrc-border);
  border-radius: 0 0 var(--ajxsrc-radius) var(--ajxsrc-radius);
}

/* Section navigation ------------------------------------------------------ */

.ajxsrc-nav {
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  border-right: 1px solid var(--ajxsrc-border);
}

.ajxsrc-nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: none;
  border: 0;
  border-left: 3px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: #2c3338;
  text-align: left;
  cursor: pointer;
}

.ajxsrc-nav__item:hover {
  background: #f6f7f7;
  color: var(--ajxsrc-accent);
}

.ajxsrc-nav__item.is-active {
  border-left-color: var(--ajxsrc-accent);
  background: #f0f6fc;
  color: var(--ajxsrc-accent);
}

.ajxsrc-nav__item:focus-visible {
  outline: 2px solid var(--ajxsrc-accent);
  outline-offset: -2px;
}

.ajxsrc-nav__item .dashicons {
  font-size: 18px;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

/* Settings panels --------------------------------------------------------- */

.ajxsrc-main {
  padding: 24px 28px;
  min-width: 0;
}

/**
 * Every section occupies the same grid cell, so this block is always as tall as
 * the tallest section and the screen does not resize as you move between them.
 * A min-height alone could not do this: it holds the panel open to the viewport,
 * but on a short screen the sections still fell back to their own heights.
 */
.ajxsrc-panels {
  display: grid;
}

.ajxsrc-panels > .ajxsrc-panel {
  grid-area: 1 / 1;
}

/**
 * Hidden sections keep their space rather than collapsing it. visibility also
 * takes them out of the tab order and out of the accessibility tree, which
 * display:none would do as well, but display:none would take the height with it
 * and that is the whole point of the cell sharing above.
 */
.ajxsrc-panel[hidden] {
  display: block;
  visibility: hidden;
}

/**
 * The gap is on the heading rather than on an adjacent-sibling rule naming each
 * thing that can follow it. That list was already incomplete: it missed the
 * status region and the disabled-search notice, both of which sat flush against
 * the heading, and it would have had to grow again for anything added later.
 */
.ajxsrc-panel__title {
  margin: 0 0 16px;
  padding: 0;
  font-size: 16px;
  font-weight: 600;
}

.ajxsrc-field {
  padding: 18px 0;
  border-bottom: 1px solid #f0f0f1;
  max-width: 620px;
}

.ajxsrc-field:last-of-type {
  border-bottom: 0;
}

.ajxsrc-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
}

.ajxsrc-help {
  margin: 6px 0 0;
  color: var(--ajxsrc-muted);
  font-size: 12px;
  line-height: 1.6;
}

.ajxsrc-input {
  width: 100%;
  max-width: 420px;
  padding: 6px 10px;
  border: 1px solid #8c8f94;
  border-radius: 4px;
  line-height: 1.6;
}

.ajxsrc-input--small {
  max-width: 100px;
}

.ajxsrc-input:focus {
  border-color: var(--ajxsrc-accent);
  box-shadow: 0 0 0 1px var(--ajxsrc-accent);
  outline: 2px solid transparent;
}

/* Toggle ------------------------------------------------------------------ */

.ajxsrc-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

/* Kept in the layout rather than display:none, so it stays keyboard focusable. */
.ajxsrc-toggle input {
  position: absolute;
  opacity: 0;
  width: 36px;
  height: 20px;
  margin: 0;
}

.ajxsrc-toggle__track {
  position: relative;
  flex: 0 0 auto;
  width: 36px;
  height: 20px;
  background: #c3c4c7;
  border-radius: 999px;
  transition: background .15s ease-in-out;
}

.ajxsrc-toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform .15s ease-in-out;
}

.ajxsrc-toggle input:checked + .ajxsrc-toggle__track {
  background: var(--ajxsrc-accent);
}

.ajxsrc-toggle input:checked + .ajxsrc-toggle__track .ajxsrc-toggle__thumb {
  transform: translateX(16px);
}

.ajxsrc-toggle input:focus-visible + .ajxsrc-toggle__track {
  outline: 2px solid var(--ajxsrc-accent);
  outline-offset: 2px;
}

/* Copy field -------------------------------------------------------------- */

.ajxsrc-copy {
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: 420px;
}

.ajxsrc-copy__value {
  font-family: Menlo, Consolas, monospace;
  font-size: 12px;
  background: #f6f7f7;
}

/* Status ------------------------------------------------------------------ */

.ajxsrc-status {
  margin: 0 0 20px;
  border: 1px solid var(--ajxsrc-border);
  border-radius: var(--ajxsrc-radius);
  overflow: hidden;
}

.ajxsrc-status__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f1;
  font-size: 13px;
}

.ajxsrc-status__row:last-child {
  border-bottom: 0;
}

.ajxsrc-status__label {
  color: var(--ajxsrc-muted);
}

.ajxsrc-status__value {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  text-align: right;
}

.ajxsrc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.ajxsrc-status__value--ok { color: var(--ajxsrc-ok); }
.ajxsrc-status__value--warn { color: var(--ajxsrc-warn); }

.ajxsrc-notice {
  margin-bottom: 20px;
  padding: 10px 14px;
  border-radius: 4px;
  border-left: 4px solid var(--ajxsrc-warn);
  background: #fcf9e8;
  font-size: 13px;
}

.ajxsrc-notice--error {
  border-left-color: var(--ajxsrc-error);
  background: #fcf0f1;
}

/* Progress ---------------------------------------------------------------- */

.ajxsrc-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f1;
}

/**
 * An author display rule outranks the user agent's [hidden] { display: none },
 * so without this the bar sat on the screen before any rebuild had started.
 */
.ajxsrc-progress[hidden] {
  display: none;
}

.ajxsrc-progress__bar {
  flex: 1 1 auto;
  /* Chrome and Safari need the appearance reset before height applies. */
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border: 0;
  border-radius: 999px;
  background: #f0f0f1;
  overflow: hidden;
}

.ajxsrc-progress__bar::-webkit-progress-bar {
  background: #f0f0f1;
  border-radius: 999px;
}

.ajxsrc-progress__bar::-webkit-progress-value {
  background: var(--ajxsrc-accent);
  border-radius: 999px;
}

.ajxsrc-progress__bar::-moz-progress-bar {
  background: var(--ajxsrc-accent);
  border-radius: 999px;
}

.ajxsrc-progress__count {
  flex: 0 0 auto;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ajxsrc-muted);
}

/* Tools ------------------------------------------------------------------- */

.ajxsrc-tools {
  border: 1px solid var(--ajxsrc-border);
  border-radius: var(--ajxsrc-radius);
}

.ajxsrc-tool {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px;
  border-bottom: 1px solid #f0f0f1;
}

.ajxsrc-tool__text h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.ajxsrc-tool__text .ajxsrc-help {
  max-width: 46ch;
}

.ajxsrc-tool .button.is-busy {
  opacity: .7;
}

.ajxsrc-tool-status {
  margin: 0;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--ajxsrc-muted);
}

.ajxsrc-tool-status:empty {
  display: none;
}

/* Actions ----------------------------------------------------------------- */

.ajxsrc-actions {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--ajxsrc-border);
}

/* Held in the layout, for the same reason the hidden sections are. */
.ajxsrc-actions.is-hidden {
  visibility: hidden;
}

/* Sidebar ----------------------------------------------------------------- */

.ajxsrc-aside {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 20px;
  border-left: 1px solid var(--ajxsrc-border);
}

.ajxsrc-card {
  padding: 16px;
  background: #fff;
  border: 1px solid var(--ajxsrc-border);
  border-radius: var(--ajxsrc-radius);
}

.ajxsrc-card__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
}

.ajxsrc-card__title .dashicons {
  font-size: 18px;
  width: 18px;
  height: 18px;
  color: var(--ajxsrc-accent);
}

.ajxsrc-card--pro {
  background: linear-gradient(180deg, #f0f6fc 0%, #fff 100%);
  border-color: #c5d9ed;
}

.ajxsrc-card--pro .ajxsrc-card__title .dashicons {
  color: #dba617;
}

.ajxsrc-card__list {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.ajxsrc-card__list li {
  position: relative;
  margin: 0 0 6px;
  padding-left: 20px;
  line-height: 1.5;
}

.ajxsrc-card__list li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ajxsrc-accent);
}

.ajxsrc-card__cta {
  width: 100%;
  text-align: center;
}

.ajxsrc-card__metric {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
}

.ajxsrc-card__state {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  font-size: 12px;
  font-weight: 600;
}

/* Responsive -------------------------------------------------------------- */

@media screen and (max-width: 1200px) {
  .ajxsrc-layout {
    grid-template-columns: 200px minmax(0, 1fr);
    /* The sidebar has dropped to its own row, so the slack from min-height goes
       to the row holding the rail and the settings rather than being shared out
       between the two and padding the sidebar. */
    grid-template-rows: 1fr auto;
  }

  .ajxsrc-aside {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    border-left: 0;
    border-top: 1px solid var(--ajxsrc-border);
  }

  .ajxsrc-card {
    flex: 1 1 260px;
  }
}

@media screen and (max-width: 782px) {
  .ajxsrc-wrap {
    margin-right: 10px;
  }

  .ajxsrc-layout {
    grid-template-columns: minmax(0, 1fr);
    /* Rail, settings, sidebar are each their own row now; the settings take the
       slack. */
    grid-template-rows: auto 1fr auto;
  }

  /* The vertical rail has nowhere to go on a phone, so it becomes a scrollable
     row above the settings. */
  .ajxsrc-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 0;
    border-right: 0;
    border-bottom: 1px solid var(--ajxsrc-border);
  }

  .ajxsrc-nav__item {
    flex: 0 0 auto;
    border-left: 0;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
  }

  .ajxsrc-nav__item.is-active {
    border-left-color: transparent;
    border-bottom-color: var(--ajxsrc-accent);
  }

  .ajxsrc-main {
    padding: 20px 16px;
  }

  .ajxsrc-aside {
    flex-direction: column;
  }

  .ajxsrc-tool {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Footer rating ------------------------------------------------------------ */

/**
 * The stars are a rating, so they lose the underline a footer link would
 * otherwise carry and take the star colour rather than the link colour. This
 * stylesheet only loads on the settings screen, which is the only screen whose
 * footer is rewritten.
 */
#wpfooter .ajxsrc-rating {
  text-decoration: none;
  letter-spacing: 2px;
  color: #dba617;
}

#wpfooter .ajxsrc-rating:hover,
#wpfooter .ajxsrc-rating:focus {
  color: #b8860b;
}

/* Motion ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .ajxsrc-toggle__track,
  .ajxsrc-toggle__thumb {
    transition: none;
  }
}
