/*
 * 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.
 */

/* ---- The "AI" buttons: base look only ----------------------------------
   Size, colour and placement in the search bar (outside the pill on desktop / tablet, the round button inside the
   phone pill) live in public/css/ip-chrome.css (handoff 2026-10-05). The layout row around the form is there too. */
.ai-search-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2, 8px);
  border: 0;
  background: var(--button-ai-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-ai-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;
}
.ai-search-trigger i { line-height: 1; }
/* The phone pill's round button only shows on phones (ip-chrome.css turns it on below 700px). */
.ai-search-trigger--pill { display: none; }

/* ---- 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: 700px;
  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: var(--scrim, rgba(0, 0, 0, 0.5)); }
.ai-search-dialog [hidden] { display: none !important; }
@media (max-width: 699px) {
  /* Phone sheet (handoff 2026-10-05, section 5.1): inset 16px from every edge, radius 28, padding 24, the page behind
     dimmed with the scrim and not scrolling. Height is the content's; max-height is only a cap, never a min-height. */
  body.ip-modal-open { overflow: hidden; }
  .ai-search-dialog {
    margin: calc(var(--ip-sheet-gap, 16px) + env(safe-area-inset-top, 0px)) auto auto;
    --ai-pad: var(--space-5, 24px);
    border-radius: 28px;
    box-shadow: var(--elevation-sheet, 0 12px 32px rgba(0, 0, 0, 0.3));
    width: calc(100vw - 2 * var(--ip-sheet-gap, 16px));
    max-width: none;
    max-height: calc(100vh - 2 * var(--ip-sheet-gap, 16px) - env(safe-area-inset-top, 0px));
    max-height: calc(100dvh - 2 * var(--ip-sheet-gap, 16px) - env(safe-area-inset-top, 0px));
  }
}

.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: 700px) {
  /* Desktop / tablet: 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: 699px) {
  .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);
}

/* Examples: a small "Przykłady:" label, then two plain text lines in quotes -
   brand blue, underlined on hover and focus. Real buttons, but with no border,
   pill or fill so they do not read as buttons; 44px tall to tap on phones. */
.ai-search-examples {
  margin: var(--space-4, 16px) 0 0;
}
.ai-search-examples__label {
  display: block;
  font: 700 12px/16px var(--font-sans);
  color: var(--ink-muted, #757575);
}
.ai-search-example {
  display: block;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  font: 400 16px/24px var(--font-sans);
  color: var(--brand-blue, #3270a2);
  cursor: pointer;
}
.ai-search-example:hover,
.ai-search-example:focus-visible { text-decoration: underline; }
.ai-search-example:focus-visible {
  outline: 2px solid var(--focus-ring, #3270a2);
  outline-offset: 2px;
}
@media (min-width: 700px) {
  .ai-search-example { min-height: 32px; }
}

/* How it works: three boxes (surface-100, radius-md, 12px padding, no border).
   Phone: stacked, icon square left and text right. Desktop (>= 768px): three
   equal columns, icon above the text. */
.ai-search-steps {
  list-style: none;
  margin: var(--space-4, 16px) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2, 8px);
}
.ai-search-step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3, 12px);
  padding: var(--space-3, 12px);
  border-radius: var(--radius-md, 8px);
  background: var(--surface-100, #f2f2f2);
  color: var(--ink, #44555b);
}
.ai-search-step__icon {
  flex: none;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md, 8px);
  background: var(--button-outline-hover, #eef3f7);
  color: var(--brand-blue, #3270a2);
  font-size: 20px;
  line-height: 1;
}
.ai-search-step__title {
  display: block;
  font: 700 15px/20px var(--font-sans);
}
.ai-search-step__desc {
  display: block;
  margin-top: 2px;
  font: 400 14px/20px var(--font-sans);
}
@media (min-width: 700px) {
  .ai-search-steps { flex-direction: row; }
  .ai-search-step { flex: 1; flex-direction: column; }
}

/* ---- "AI understood" chips on the results page ------------------------- */
/* The results line (one sentence, no pill): body-sm, ink; the AI icon and the
   "Search again" link are brand blue, the lead-in and the link bold. */
.ai-understood {
  margin: 0 0 var(--space-3, 12px);
  font: 400 14px/22px var(--font-sans);
  color: var(--ink, #44555b);
}
.ai-understood > i {
  color: var(--brand-blue, #3270a2);
  font-size: 18px;
  line-height: 1;
  vertical-align: -3px;
}
.ai-understood__again {
  color: var(--brand-blue, #3270a2);
  text-decoration: none;
}
.ai-understood__again:hover,
.ai-understood__again:focus-visible { text-decoration: underline; }
.ai-fallback-note {
  margin: 0 0 var(--space-3, 12px);
  font: 400 13px/1.4 var(--font-sans);
  color: var(--ink-muted, #757575);
}

/* Phone sheet details (handoff 2026-10-05, section 5.1): title 26/32, badge 28px pill, field 52px radius 16,
   example links 18px, the three step cards radius 14 on surface-100. */
@media (max-width: 699px) {
  .ai-search-title { font-size: 26px; line-height: 32px; font-weight: 600; }
  .ai-search-powered {
    height: 28px;
    box-sizing: border-box;
    padding: 0 var(--space-3, 12px);
    background: var(--button-ai-fill, #eef3f7);
    color: var(--brand-blue-dark, #295b84);
    font-size: 14px;
  }
  .ai-search-input { border-radius: var(--radius-xl, 16px); }
  .ai-search-submit { height: 48px; }
  .ai-search-example { font-size: 18px; }
  .ai-search-step { border-radius: 14px; }
}
