/* Ayneta AI Search — Enterprise v5 — Integrates with Child Theme Dark Mode */

/* ── Uses child theme CSS variables directly ────── */
.aie-overlay {
  --aie-primary: var(--ayneta-primary, #009000);
  --aie-primary-hover: var(--ayneta-primary-light, #00b800);
  --aie-primary-rgb: 0,144,0;
  --aie-orange: var(--ayneta-secondary, #ff660d);
  --aie-blue: #3b82f6;
  --aie-red: #ef4444;
  --aie-radius: 8px;

  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.aie-overlay.aie-open {
  opacity: 1;
  visibility: visible;
}

.aie-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ── Container ─────────────────────────────────── */
.aie-container {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 16px;
  background: var(--ayneta-card-bg, #ffffff);
  border: 2px solid var(--ayneta-border-color, #e4e4e7);
  border-radius: var(--aie-radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  overflow: hidden;
  transform: translateY(-8px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s, border-color 0.2s;
}

.aie-overlay.aie-open .aie-container {
  transform: translateY(0) scale(1);
}

/* ── Dark mode: inherit from child theme ────────── */
body.ayneta-dark-mode .aie-container,
html[data-theme="dark"] .aie-container {
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

body.ayneta-dark-mode .aie-backdrop,
html[data-theme="dark"] .aie-backdrop {
  background: rgba(0,0,0,0.6);
}

.aie-body {
  max-height: 60vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--ayneta-surface-200, #e4e4e7) transparent;
}

.aie-body::-webkit-scrollbar { width: 6px; }
.aie-body::-webkit-scrollbar-thumb { background: var(--ayneta-surface-200, #e4e4e7); border-radius: 3px; }

/* ══════════════════════════════════════════════════
   SEARCH BAR — Matches child theme exactly
   ══════════════════════════════════════════════════ */
.aie-search-bar {
  border-bottom: 1px solid var(--ayneta-border-color, #e4e4e7);
}

.aie-search-bar-inner {
  display: flex;
  align-items: center;
  gap: 0;
  height: 42px;
  background: var(--ayneta-surface-50, #fafafa);
  border: 2px solid var(--ayneta-surface-200, #e4e4e7);
  border-radius: 8px;
  margin: 10px 12px;
  padding: 0;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.aie-search-bar-inner:focus-within {
  border-color: var(--aie-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

body.ayneta-dark-mode .aie-search-bar-inner,
html[data-theme="dark"] .aie-search-bar-inner {
  background: var(--ayneta-surface-100, #27272a);
  border-color: var(--ayneta-surface-200, #3f3f46);
}

body.ayneta-dark-mode .aie-search-bar-inner:focus-within,
html[data-theme="dark"] .aie-search-bar-inner:focus-within {
  border-color: var(--aie-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.aie-search-icon-wrap {
  display: none;
}
.aie-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--ayneta-surface-200, #e4e4e7);
  color: var(--ayneta-surface-600, #52525b);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.aie-close:hover {
  background: var(--ayneta-surface-300, #d4d4d8);
  color: var(--ayneta-surface-800, #27272a);
}

.aie-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  font-weight: 400;
  color: var(--ayneta-text-primary, #18181b);
  height: 100%;
  min-width: 0;
  padding: 0 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.aie-input::placeholder {
  color: var(--ayneta-surface-500, #71717a);
}

body.ayneta-dark-mode .aie-input,
html[data-theme="dark"] .aie-input {
  color: var(--ayneta-text-primary, #ffffff);
}

.aie-search-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 100%;
  padding: 0 14px;
  background: var(--aie-primary, #009000);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
  flex-shrink: 0;
  border-radius: 0 6px 6px 0;
}

.aie-search-submit:hover {
  background: var(--aie-primary-hover, #007a00);
}

body.ayneta-dark-mode .aie-search-submit,
html[data-theme="dark"] .aie-search-submit {
  background: var(--aie-primary, #009000);
}

body.ayneta-dark-mode .aie-search-submit:hover,
html[data-theme="dark"] .aie-search-submit:hover {
  background: var(--aie-primary-hover, #007a00);
}

/* ══════════════════════════════════════════════════
   SECTION TITLES
   ══════════════════════════════════════════════════ */
.aie-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ayneta-surface-500, #71717a);
}

.aie-section-title i {
  font-size: 11px;
  color: var(--aie-orange);
}

.aie-group-label {
  padding: 8px 14px 2px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ayneta-text-muted, #a1a1aa);
}

/* ══════════════════════════════════════════════════
   SUGGESTION ITEMS
   ══════════════════════════════════════════════════ */
.aie-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  text-decoration: none;
  color: var(--ayneta-text-primary, #18181b);
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--ayneta-border-light, rgba(0,0,0,0.08));
  min-height: 42px;
}

.aie-item:last-child { border-bottom: none; }

.aie-item:hover,
.aie-item.aie-active {
  background: var(--ayneta-surface-50, #fafafa);
}

body.ayneta-dark-mode .aie-item:hover,
body.ayneta-dark-mode .aie-item.aie-active,
html[data-theme="dark"] .aie-item:hover,
html[data-theme="dark"] .aie-item.aie-active {
  background: var(--ayneta-surface-100, #27272a);
}

.aie-icon-muted {
  width: 18px;
  text-align: center;
  color: var(--ayneta-surface-500, #71717a);
  font-size: 12px;
  flex-shrink: 0;
}

.aie-icon-orange { color: var(--aie-orange) !important; }

.aie-item-text {
  flex: 1;
  font-size: 13px;
  font-weight: 450;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aie-item-text mark {
  background: rgba(0, 144, 0, 0.1);
  color: var(--ayneta-text-primary, #18181b);
  border-radius: 2px;
  padding: 0 1px;
}

body.ayneta-dark-mode .aie-item-text mark,
html[data-theme="dark"] .aie-item-text mark {
  background: rgba(0, 144, 0, 0.2);
  color: var(--ayneta-text-primary, #ffffff);
}

.aie-item-badge {
  font-size: 10px;
  font-weight: 500;
  color: var(--ayneta-surface-500, #71717a);
  background: var(--ayneta-surface-100, #f4f4f5);
  padding: 2px 7px;
  border-radius: 10px;
  flex-shrink: 0;
}

body.ayneta-dark-mode .aie-item-badge,
html[data-theme="dark"] .aie-item-badge {
  background: var(--ayneta-surface-200, #3f3f46);
  color: var(--ayneta-surface-500, #a1a1aa);
}

.aie-item-badge-hot {
  background: rgba(239, 68, 68, 0.08) !important;
  color: var(--aie-red) !important;
}

.aie-item-badge-rising {
  background: rgba(0, 144, 0, 0.08) !important;
  color: var(--aie-primary) !important;
}

/* ══════════════════════════════════════════════════
   TWO-COLUMN DEFAULT LAYOUT
   ══════════════════════════════════════════════════ */
.aie-default-panel { padding: 8px 0; }

.aie-default-row { display: flex; gap: 0; }

.aie-default-col { flex: 1; min-width: 0; }

.aie-default-col + .aie-default-col {
  border-left: 1px solid var(--ayneta-border-color, #e4e4e7);
}

.aie-default-col .aie-section-title { padding: 6px 14px 4px; }
.aie-default-col .aie-item { padding: 7px 14px; min-height: 38px; }

/* ══════════════════════════════════════════════════
   MATCHING RECENT SEARCHES
   ══════════════════════════════════════════════════ */
.aie-matching-panel {
  border-bottom: 1px solid var(--ayneta-border-color, #e4e4e7);
}

.aie-matching-panel .aie-item { padding: 9px 14px; min-height: 42px; }

.aie-matching-panel .aie-search-exact {
  background: rgba(0, 144, 0, 0.03);
}

body.ayneta-dark-mode .aie-matching-panel .aie-search-exact,
html[data-theme="dark"] .aie-matching-panel .aie-search-exact {
  background: rgba(0, 144, 0, 0.08);
}

/* ══════════════════════════════════════════════════
   TRENDING
   ══════════════════════════════════════════════════ */
.aie-trending-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--ayneta-border-color, #e4e4e7);
  padding: 0 14px;
  background: var(--ayneta-surface-50, #fafafa);
}

body.ayneta-dark-mode .aie-trending-tabs,
html[data-theme="dark"] .aie-trending-tabs {
  background: var(--ayneta-surface-100, #27272a);
}

.aie-trending-tab {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ayneta-surface-500, #71717a);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.aie-trending-tab:hover { color: var(--ayneta-text-primary, #18181b); }

.aie-trending-tab.aie-active {
  color: var(--aie-primary);
  border-bottom-color: var(--aie-primary);
}

body.ayneta-dark-mode .aie-trending-tab:hover,
html[data-theme="dark"] .aie-trending-tab:hover {
  color: var(--ayneta-text-primary, #ffffff);
}

.aie-trending-rank {
  width: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ayneta-surface-300, #d4d4d8);
  text-align: center;
  flex-shrink: 0;
}

.aie-trending-rank-1 { color: var(--aie-orange); }
.aie-trending-rank-2 { color: var(--ayneta-surface-500, #71717a); }
.aie-trending-rank-3 { color: var(--aie-orange); opacity: 0.7; }
