/* ============================================================
   NAW Controls — Algolia Search Modal
   Algolia Figma Search Plugin — Custom UI
   ============================================================ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --naw-navy:        #0f2044;
  --naw-navy-mid:    #1a3266;
  --naw-blue:        #1e5baa;
  --naw-blue-light:  #2e73d4;
  --naw-accent:      #e8a020;
  --naw-bg:          #ffffff;
  --naw-surface:     #f5f6f8;
  --naw-border:      #dde1e8;
  --naw-border-soft: #edf0f4;
  --naw-text:        #111827;
  --naw-text-mid:    #4b5563;
  --naw-text-muted:  #8b93a1;
  --naw-highlight:   #1e5baa;
  --naw-radius-sm:   4px;
  --naw-radius-md:   8px;
  --naw-radius-lg:   12px;
  --naw-shadow:      0 8px 40px rgba(15,32,68,.15), 0 2px 8px rgba(15,32,68,.08);
}

.ss-footer {
    display: none !important;
}
.modal-content.ss-exp {
    max-height: min(85vh, 800px);  /* was 640px */
}

[role="listbox"].ss-hits-container {
    max-height: 600px;  /* was 340px in the preview, increase as needed */
}
.ss-exp .search-panel{
    max-height: 600px !important;  /* was 340px in the preview, increase as needed */    
}
.ss-exp .ss-hits-container, .ss-exp .ss-chat-root{
    max-height: 600px !important;  /* was 340px in the preview, increase as needed */    
}
/* ── Backdrop ────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(10, 20, 45, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(40px, 8vh, 100px);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: naw-fade-in 0.15s ease;
}

@keyframes naw-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Modal shell ─────────────────────────────────────────── */
.modal-content.ss-exp {
  background: var(--naw-bg);
  border-radius: var(--naw-radius-lg);
  box-shadow: var(--naw-shadow);
  width: min(760px, calc(100vw - 32px));
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: naw-slide-in 0.18s cubic-bezier(0.16,1,0.3,1);
  border: 1px solid var(--naw-border);
}

@keyframes naw-slide-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Search panel (top bar) ──────────────────────────────── */
.search-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ── Search form ─────────────────────────────────────────── */
search.ss-searchbox-form,
form.ss-searchbox-form {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 16px;
  border-bottom: 1.5px solid var(--naw-border);
  height: 60px;
  flex-shrink: 0;
  background: var(--naw-bg);
}

.ss-search-left-button {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--naw-blue);
  flex-shrink: 0;
  width: 32px;
  cursor: default;
}

.ss-search-left-button svg {
  width: 20px;
  height: 20px;
  color: var(--naw-blue);
}

search.ss-searchbox-form input[type="search"],
form.ss-searchbox-form input[type="search"] {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  color: var(--naw-text);
  font-family: inherit;
  padding: 0 12px;
  min-width: 0;
  line-height: 1;
  -webkit-appearance: none;
  appearance: none;
}

search.ss-searchbox-form input[type="search"]::placeholder,
form.ss-searchbox-form input[type="search"]::placeholder {
  color: var(--naw-text-muted);
  font-weight: 400;
}

search.ss-searchbox-form input[type="search"]::-webkit-search-decoration,
search.ss-searchbox-form input[type="search"]::-webkit-search-cancel-button,
form.ss-searchbox-form input[type="search"]::-webkit-search-decoration,
form.ss-searchbox-form input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

/* ── Search action buttons ───────────────────────────────── */
.ss-search-action-buttons-container {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ss-search-clear-button {
  border: 1px solid var(--naw-border);
  background: var(--naw-surface);
  color: var(--naw-text-mid) !important;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--naw-radius-sm);
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.02em;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  line-height: 1.4;
}

.ss-search-clear-button:hover {
  border-color: var(--naw-blue);
  color: var(--naw-blue);
  background: #eef3fb;
}

.ss-search-close-button {
  border: none;
  background: transparent;
  color: var(--naw-text-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--naw-radius-sm);
  transition: background 0.15s, color 0.15s;
}

.ss-search-close-button:hover {
  background: var(--naw-surface);
  color: var(--naw-text);
}

.ss-search-close-button svg {
  width: 18px;
  height: 18px;
}

/* ── Hits container ──────────────────────────────────────── */
[role="listbox"].ss-hits-container {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 0;
  scroll-behavior: smooth;
}

[role="listbox"].ss-hits-container::-webkit-scrollbar {
  width: 5px;
}
[role="listbox"].ss-hits-container::-webkit-scrollbar-track {
  background: transparent;
}
[role="listbox"].ss-hits-container::-webkit-scrollbar-thumb {
  background: var(--naw-border);
  border-radius: 99px;
}

/* ── Hit item ────────────────────────────────────────────── */
a.ss-infinite-hits-item.ss-infinite-hits-anchor {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  text-decoration: none;
  color: var(--naw-text);
  transition: background 0.1s;
  border-radius: 0;
  cursor: pointer;
  outline: none;
  border-left: 3px solid transparent;
}

a.ss-infinite-hits-item.ss-infinite-hits-anchor:hover,
a.ss-infinite-hits-item.ss-infinite-hits-anchor[aria-selected="true"] {
  background: #eef3fb;
  border-left-color: var(--naw-blue);
}

a.ss-infinite-hits-item.ss-infinite-hits-anchor:focus-visible {
  background: #eef3fb;
  border-left-color: var(--naw-blue-light);
  box-shadow: inset 0 0 0 2px rgba(30,91,170,0.25);
}

/* ── Hit image ───────────────────────────────────────────── */
.ss-infinite-hits-item-image-container {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: var(--naw-radius-sm);
  overflow: hidden;
  border: 1px solid var(--naw-border-soft);
  background: var(--naw-surface);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ss-infinite-hits-item-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ── Hit content ─────────────────────────────────────────── */
.ss-infinite-hits-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ss-infinite-hits-item-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--naw-text);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.ss-infinite-hits-item-description {
  font-size: 12px;
  color: var(--naw-text-muted);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.ss-infinite-hits-item-tertiary {
  font-size: 11px;
  color: var(--naw-text-muted);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.3;
}

/* ── Algolia highlight marks ─────────────────────────────── */
.ais-Highlight mark.ais-Highlight-highlighted,
.ais-Highlight-highlighted {
  background: transparent;
  color: var(--naw-blue);
  font-weight: 600;
  font-style: normal;
}

.ais-Highlight-nonHighlighted {
  font-style: normal;
}

/* ── Footer ──────────────────────────────────────────────── */
.ss-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-top: 1px solid var(--naw-border-soft);
  background: var(--naw-surface);
  flex-shrink: 0;
  gap: 12px;
}

.ss-footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ss-footer-kbd-group {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--naw-text-muted);
  font-family: inherit;
}

.ss-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--naw-bg);
  border: 1px solid var(--naw-border);
  border-bottom-width: 2px;
  border-radius: var(--naw-radius-sm);
  padding: 2px 5px;
  min-width: 22px;
  height: 22px;
  box-shadow: 0 1px 0 var(--naw-border);
}

.ss-kbd svg {
  width: 13px;
  height: 13px;
  color: var(--naw-text-mid);
}

/* ── Powered by Algolia ──────────────────────────────────── */
.ss-footer-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.ss-footer-powered-by {
  display: flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  font-size: 11px;
  color: var(--naw-text-muted);
  opacity: 0.75;
  transition: opacity 0.15s;
}

.ss-footer-powered-by:hover {
  opacity: 1;
}

.ss-footer-powered-by span {
  white-space: nowrap;
}

.ss-footer-powered-by svg {
  max-width: 56px !important;
  height: auto;
  color: var(--naw-text-muted);
  fill: currentColor;
}

/* Force Algolia logo paths to inherit muted text color */
.ss-footer-powered-by svg .cls-1,
.ss-footer-powered-by svg .cls-2 {
  fill: var(--naw-text-muted);
}

/* ── Empty state ─────────────────────────────────────────── */
.ss-empty-state,
.autocomplete-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--naw-text-muted);
  font-size: 14px;
}

/* ── Separator between hit groups ────────────────────────── */
.ss-hits-section-title {
  padding: 10px 16px 4px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--naw-text-muted);
}

/* ── Scrollbar gap fix for narrow viewports ──────────────── */
@media (max-width: 600px) {
  .modal-backdrop {
    align-items: flex-start;
    padding-top: 0;
  }

  .modal-content.ss-exp {
    width: 100vw;
    border-radius: 0 0 var(--naw-radius-lg) var(--naw-radius-lg);
    max-height: 90vh;
  }

  .ss-footer-left {
    display: none;
  }
}
