/*
 * AI Search ("Szukaj z AI", docs/IP-AI-Search.md) - the popup and every
 * entry point to it. Loaded site-wide from web.layouts.header. Tokens only
 * (tokens.css); the popup is the site's own native <dialog> pattern (same
 * shell as the login modal), the fields reuse .form-control-style borders,
 * the close button is the shared .ipflow-dialog-close, the example chips
 * are outline controls. No new colours.
 */

/* ---- Wrapper around the search form and the desktop AI button ---------
   Desktop: the form (the white pill) and the AI button side by side, the
   button OUTSIDE the pill. Phones: display:contents, so the form is a
   direct child of the band again, exactly as before. */
.ip-search-row {
  display: flex;
  align-items: center;
  gap: var(--space-4, 16px);
}
.ip-search-row > .ip-search {
  flex: 1 1 auto;
  min-width: 0;
}
@media (max-width: 640px) {
  .ip-search-row { display: contents; }
}

/* ---- The soft "Szukaj z AI" buttons ----------------------------------- */
.ai-search-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2, 8px);
  border: 0;
  background: var(--button-secondary-fill, #eef3f7);
  color: var(--brand-blue, #3270a2);
  font-family: var(--font-sans);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}
.ai-search-trigger:hover { background: var(--button-secondary-hover, #dfeaf2); }
.ai-search-trigger:active { background: var(--button-secondary-active, #cfe0ec); }
.ai-search-trigger:focus-visible {
  outline: 2px solid var(--focus-ring, #3270a2);
  outline-offset: 2px;
}
/* On the dark search band the plain ring is under 3:1: the family's white
   inner ring first (same as the Search button). */
.ip-search-band .ai-search-trigger:focus-visible {
  outline: 2px solid var(--focus-ring, #3270a2);
  box-shadow: 0 0 0 2px var(--focus-ring-inner, #ffffff);
}
.ai-search-trigger i { line-height: 1; }

/* Desktop band: 52px tall like the green Search button, 18px bold, 24px icon. */
.ai-search-trigger--band {
  flex: none;
  height: 52px;
  padding: 0 var(--space-5, 24px);
  border-radius: var(--radius-pill, 999px);
  font-size: 18px;
  line-height: 1;
}
.ai-search-trigger--band i { font-size: 24px; }

/* Phone pill: the third 40px round button, between the pin and the green Search. */
.ai-search-trigger--pill {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-pill, 999px);
  font-size: 20px;
}

/* Phone, expanded search: full width under the green Search button. */
.ai-search-trigger--expanded {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-4, 16px);
  border-radius: var(--radius-pill, 999px);
  font-size: 16px;
}
.ai-search-trigger--expanded i { font-size: 20px; }

/* Which one shows where. */
.ai-search-trigger--pill,
.ai-search-trigger--expanded { display: none; }
@media (max-width: 640px) {
  .ai-search-trigger--band { display: none; }
  .ai-search-trigger--pill { display: inline-flex; }
  /* The expanded form is only displayed once the pill is expanded. */
  .ai-search-trigger--expanded { display: inline-flex; }
}

/* ---- The popup --------------------------------------------------------- */
.ai-search-dialog {
  --ai-pad: var(--space-5, 24px);
  position: relative;
  border: none;
  background: var(--surface, #fff);
  border-radius: var(--radius-xl, 16px);
  box-shadow: var(--elevation-3, 0 8px 16px rgba(68, 85, 91, 0.18));
  padding: var(--ai-pad);
  width: 560px;
  max-width: calc(100vw - 2 * var(--space-4, 16px));
  max-height: calc(100vh - 2 * var(--space-6, 32px));
  max-height: calc(100dvh - 2 * var(--space-6, 32px));
  overflow-y: auto;
  margin: auto;
  color: var(--ink, #44555b);
}
.ai-search-dialog::backdrop { background: rgba(51, 51, 51, 0.6); }
.ai-search-dialog [hidden] { display: none !important; }
@media (max-width: 767px) {
  .ai-search-dialog {
    --ai-pad: var(--space-4, 16px);
    /* near full width, 10px side margin (no 10px token: the margin stays
       the owner's spec'd value) */
    width: calc(100vw - 20px);
    max-width: none;
    max-height: calc(100vh - 2 * var(--space-4, 16px));
    max-height: calc(100dvh - 2 * var(--space-4, 16px));
  }
}

.ai-search-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3, 12px);
}
.ai-search-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2, 8px);
  min-width: 0;
}
@media (min-width: 768px) {
  /* Desktop: the "Powered by Claude" pill beside the title, not under it. */
  .ai-search-heading {
    flex-direction: row;
    align-items: center;
    gap: var(--space-3, 12px);
    flex-wrap: wrap;
  }
}
.ai-search-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: var(--h3-size, 22px);
  line-height: var(--h3-line-height, 28px);
  font-weight: var(--h3-weight, 500);
  color: var(--ink, #44555b);
}
.ai-search-title[tabindex="-1"]:focus { outline: none; }
.ai-search-powered {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px var(--space-3, 12px);
  border-radius: var(--radius-pill, 999px);
  background: var(--info-bg, #eaf0f5);
  color: var(--info-text, #3270a2);
  font: 700 12px/1.4 var(--font-sans);
}
.ai-search-powered i { font-size: 14px; line-height: 1; }

/* Field row: field + green Search button side by side on desktop, the
   button full width under the field on phones. */
.ai-search-form { margin: var(--space-4, 16px) 0 0; }
.ai-search-row {
  display: flex;
  align-items: center;
  gap: var(--space-3, 12px);
}
.ai-search-field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.ai-search-input {
  display: block;
  width: 100%;
  height: 52px;
  box-sizing: border-box;
  padding: 0 56px 0 var(--space-4, 16px);
  border: 1px solid var(--border, #dedede);
  border-radius: var(--radius-md, 8px);
  background: var(--surface, #fff);
  color: var(--ink, #44555b);
  font: 400 16px/1.3 var(--font-sans);
}
.ai-search-input::placeholder { color: var(--ink-muted, #757575); opacity: 1; }
.ai-search-input:focus-visible {
  outline: 2px solid var(--focus-ring, #3270a2);
  outline-offset: 1px;
}
.ai-search-input[readonly] { background: var(--surface-100, #f2f2f2); }
.ai-search-field.has-error .ai-search-input { border-color: var(--danger, #9e4a46); }
.ai-search-mic {
  position: absolute;
  top: 50%;
  right: var(--space-2, 8px);
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius-pill, 999px);
  background: var(--button-secondary-fill, #eef3f7);
  color: var(--brand-blue, #3270a2);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.ai-search-mic:hover { background: var(--button-secondary-hover, #dfeaf2); }
.ai-search-mic[aria-pressed="true"] {
  background: var(--button-outline-active, #eef3f7);
  color: var(--button-outline-active-text, #3270a2);
  box-shadow: 0 0 0 2px var(--brand-blue, #3270a2);
}
.ai-search-mic:focus-visible {
  outline: 2px solid var(--focus-ring, #3270a2);
  outline-offset: 2px;
}
.ai-search-submit {
  flex: none;
  height: 52px;
  padding: 0 var(--space-5, 24px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2, 8px);
  border: 0;
  border-radius: var(--radius-pill, 999px);
  background: var(--button-success-fill);
  color: var(--ink-inverse, #fff);
  font: 700 18px/1 var(--font-sans);
  cursor: pointer;
  box-sizing: border-box;
  /* Same size while loading (the spinner replaces the magnifier). */
  min-width: 132px;
}
.ai-search-submit i { font-size: 24px; line-height: 1; }
.ai-search-submit:hover { background: var(--button-success-hover); }
.ai-search-submit:active { background: var(--button-success-active); }
.ai-search-submit[disabled] { cursor: progress; background: var(--button-success-fill); }
.ai-search-submit:focus-visible {
  outline: 2px solid var(--focus-ring, #3270a2);
  outline-offset: 2px;
}
@media (max-width: 767px) {
  .ai-search-row { flex-direction: column; align-items: stretch; }
  .ai-search-input { height: 52px; }
  .ai-search-submit { width: 100%; }
}
/* Field error: the standard flow-form message under the field, never a banner. */
.ai-search-error {
  margin: var(--space-2, 8px) 0 0;
  font: 400 14px/1.4 var(--font-sans);
  color: var(--danger, #9e4a46);
}

/* Example chips: outline chips, 32px. Tapping one fills the field. */
.ai-search-examples {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2, 8px);
  margin: var(--space-4, 16px) 0 0;
}
.ai-search-chip {
  height: 32px;
  padding: 0 var(--space-3, 12px);
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill, 999px);
  font: 400 14px/1 var(--font-sans);
  cursor: pointer;
}

/* The three steps: always one row of three equal columns, even on phones. */
.ai-search-steps {
  list-style: none;
  margin: var(--space-5, 24px) 0 0;
  padding: var(--space-4, 16px) 0 0;
  border-top: 1px solid var(--border, #dedede);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3, 12px);
}
.ai-search-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2, 8px);
  text-align: center;
  font: 400 13px/1.35 var(--font-sans);
  color: var(--ink, #44555b);
}
.ai-search-step__icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md, 8px);
  background: var(--category-blue-tint, #e6eff7);
  color: var(--brand-blue, #3270a2);
  font-size: 20px;
  line-height: 1;
}
.ai-search-step__long { display: none; }
@media (min-width: 768px) {
  .ai-search-step { font-size: 14px; }
  .ai-search-step__short { display: none; }
  .ai-search-step__long { display: inline; }
}

/* ---- "AI understood" chips on the results page ------------------------- */
.ai-understood {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2, 8px);
  margin: 0 0 var(--space-3, 12px);
}
.ai-understood__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 700 14px/1.3 var(--font-sans);
  color: var(--info-text, #3270a2);
}
.ai-understood__label i { font-size: 18px; line-height: 1; }
.ai-understood__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2, 8px);
  min-height: 32px;
  padding: 0 var(--space-2, 8px) 0 var(--space-3, 12px);
  border: 1px solid var(--border, #dedede);
  border-radius: var(--radius-pill, 999px);
  background: var(--surface, #fff);
  color: var(--ink, #44555b);
  font: 400 14px/1.2 var(--font-sans);
}
.ai-understood__remove {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill, 999px);
  color: var(--ink-muted, #757575);
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
}
.ai-understood__remove:hover { background: var(--button-outline-hover, #eef3f7); color: var(--ink, #44555b); }
.ai-understood__remove:focus-visible {
  outline: 2px solid var(--focus-ring, #3270a2);
  outline-offset: 1px;
}
.ai-understood__note {
  flex-basis: 100%;
  margin: 0;
  font: 400 13px/1.4 var(--font-sans);
  color: var(--ink-muted, #757575);
}
.ai-fallback-note {
  margin: 0 0 var(--space-3, 12px);
  font: 400 13px/1.4 var(--font-sans);
  color: var(--ink-muted, #757575);
}
