/* SearchQueriesEditor — Unified Table (Design D) */

:root {
  --sqe-bg:           #0a0a0a;
  --sqe-card:         #141414;
  --sqe-card-alt:     #1a1a1a;
  --sqe-border:       #262626;
  --sqe-border-str:   #333;
  --sqe-text:         #e5e5e5;
  --sqe-text-dim:     #a3a3a3;
  --sqe-text-faint:   #737373;
  --sqe-green:        #16a34a;
  --sqe-green-soft:   rgba(22,163,74,0.14);
  --sqe-green-border: rgba(22,163,74,0.4);
  --sqe-purple:       #a855f7;
  --sqe-purple-soft:  rgba(168,85,247,0.14);
  --sqe-purple-border:rgba(168,85,247,0.4);
  --sqe-blue:         #60a5fa;
  --sqe-blue-soft:    rgba(96,165,250,0.14);
  --sqe-blue-border:  rgba(96,165,250,0.4);
  --sqe-red:          #ef4444;
  --sqe-mono:         "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

/* ── Shell ──────────────────────────────────────────────────────────── */
.sqe-shell {
  background: var(--sqe-card-alt);
  border: 1px solid var(--sqe-border);
  border-radius: 10px;
  padding: 20px 22px 18px;
  margin: 20px 0;
  box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset;
}

.sqe-head { margin-bottom: 14px; }

.sqe-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.sqe-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.1px;
  margin: 0;
  color: var(--sqe-text);
}
.sqe-title svg { color: var(--sqe-green); flex-shrink: 0; }

.sqe-chips { display: flex; gap: 8px; flex-wrap: wrap; }

.sqe-sub {
  font-size: 12px;
  color: var(--sqe-text-dim);
  margin: 8px 0 0;
  line-height: 1.5;
}
.sqe-sub kbd { margin: 0 2px; }

/* ── Chips / badges ─────────────────────────────────────────────────── */
.sqe-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  border-radius: 4px;
  border: 1px solid;
  white-space: nowrap;
}
.sqe-chip-sm { padding: 1px 7px; font-size: 9.5px; }

.sqe-chip-anchor  { background: var(--sqe-green-soft);  color: var(--sqe-green);  border-color: var(--sqe-green-border); }
.sqe-chip-target  { background: var(--sqe-purple-soft); color: var(--sqe-purple); border-color: var(--sqe-purple-border);}
.sqe-chip-url     { background: var(--sqe-blue-soft);   color: var(--sqe-blue);   border-color: var(--sqe-blue-border);  }
.sqe-chip-neutral { background: rgba(255,255,255,0.04); color: var(--sqe-text-dim); border-color: rgba(255,255,255,0.08); }

/* ── Kbd ────────────────────────────────────────────────────────────── */
.sqe-kbd {
  display: inline-flex;
  padding: 1px 5px;
  font-size: 9.5px;
  font-family: var(--sqe-mono);
  color: var(--sqe-text-dim);
  background: var(--sqe-card-alt);
  border: 1px solid var(--sqe-border);
  border-radius: 3px;
  font-weight: 500;
  line-height: 1.5;
  vertical-align: middle;
}

/* ── Toolbar ────────────────────────────────────────────────────────── */
.sqe-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--sqe-card);
  border: 1px solid var(--sqe-border);
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.sqe-filter-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: 32px;
  background: var(--sqe-bg);
  border: 1px solid var(--sqe-border);
  border-radius: 6px;
  transition: border-color .12s, box-shadow .12s;
  min-width: 0;
}
.sqe-filter-wrap:focus-within {
  border-color: var(--sqe-green-border);
  box-shadow: 0 0 0 3px rgba(22,163,74,0.08);
}
.sqe-filter-wrap svg { color: var(--sqe-text-faint); flex-shrink: 0; }
.sqe-filter-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--sqe-text);
  font-size: 12.5px;
  font-family: var(--sqe-mono);
  min-width: 0;
  height: 100%;
}
.sqe-filter-input::placeholder { color: var(--sqe-text-faint); }

.sqe-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 32px;
  font-size: 12.5px;
  font-weight: 500;
  background: var(--sqe-bg);
  color: var(--sqe-text);
  border: 1px solid var(--sqe-border);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
  font-family: inherit;
}
.sqe-tool-btn:hover { background: var(--sqe-card-alt); border-color: var(--sqe-border-str); }
.sqe-tool-btn .sqe-kbd { margin-left: 2px; background: rgba(0,0,0,0.3); }
.sqe-clear-all-btn { color: var(--sqe-text-dim); }

/* ── Table ──────────────────────────────────────────────────────────── */
.sqe-table {
  background: var(--sqe-card);
  border: 1px solid var(--sqe-border);
  border-top: none;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  overflow: hidden;
}

.sqe-row {
  display: grid;
  grid-template-columns: 32px 76px minmax(0,1fr) 68px 130px 52px 70px;
  align-items: center;
  padding: 0 12px;
  height: 40px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  position: relative;
  transition: background .1s;
}
.sqe-row > * { padding-right: 8px; min-width: 0; overflow: hidden; }
.sqe-row > *:last-child { padding-right: 0; }

.sqe-row-head {
  height: 30px;
  background: var(--sqe-bg);
  font-size: 9.5px;
  font-weight: 600;
  color: var(--sqe-text-faint);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.sqe-row-data:nth-child(even) { background: rgba(255,255,255,0.012); }
.sqe-row-data:hover           { background: rgba(255,255,255,0.025); }
.sqe-row-data.sqe-selected    { background: rgba(22,163,74,0.05); }
.sqe-row-data.sqe-selected::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--sqe-green);
}
.sqe-row-data { cursor: pointer; }

.sqe-row-add {
  border-top: 1px dashed var(--sqe-border-str);
  border-bottom: none;
  background: transparent;
  cursor: default;
}
.sqe-row-add:focus-within { background: rgba(22,163,74,0.04); }

/* Cell types */
.sqe-cell-num {
  color: var(--sqe-text-faint);
  font-family: var(--sqe-mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.sqe-cell-text {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--sqe-mono);
  font-size: 12.5px;
  color: var(--sqe-text);
  white-space: nowrap;
  overflow: hidden;
}
.sqe-url-icon { color: var(--sqe-blue); flex-shrink: 0; }

.sqe-text-inner {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  outline: none;
  border-radius: 3px;
  padding: 0 2px;
  cursor: text;
  flex: 1;
  min-width: 0;
}
.sqe-text-inner:focus {
  background: rgba(22,163,74,0.06);
  box-shadow: 0 0 0 1px var(--sqe-green-border);
  white-space: nowrap;
  overflow: visible;
}

.sqe-cell-meta {
  font-family: var(--sqe-mono);
  font-size: 11px;
  color: var(--sqe-text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sqe-cell-src {
  font-family: var(--sqe-mono);
  font-size: 11px;
  color: var(--sqe-text-faint);
  text-transform: lowercase;
}

.sqe-cell-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
  opacity: 0.4;
  transition: opacity .1s;
}
.sqe-row-data:hover .sqe-cell-actions,
.sqe-row-data.sqe-selected .sqe-cell-actions { opacity: 1; }
.sqe-row-add .sqe-cell-actions { opacity: 1; }

.sqe-detail-inline {
  display: flex;
  gap: 4px;
  align-items: center;
  overflow: hidden;
}

/* ── Icon buttons ───────────────────────────────────────────────────── */
.sqe-icon-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--sqe-text-dim);
  padding: 0;
  transition: background .1s, color .1s;
  flex-shrink: 0;
}
.sqe-icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--sqe-text); }
.sqe-del-btn:hover  { background: rgba(239,68,68,0.12); color: var(--sqe-red); }

/* ── Inline selects ─────────────────────────────────────────────────── */
select.sqe-inline-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  border: 1px solid transparent;
  color: var(--sqe-text-dim);
  font-family: var(--sqe-mono);
  font-size: 11px;
  padding: 3px 18px 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  max-width: 100%;
  transition: background-color .1s, border-color .1s;
}
select.sqe-inline-select:hover { background-color: rgba(255,255,255,0.04); }
select.sqe-inline-select:focus {
  outline: none;
  border-color: var(--sqe-green-border);
  background-color: rgba(22,163,74,0.06);
}
select.sqe-inline-select option { background: var(--sqe-card-alt); color: var(--sqe-text); }

/* ── Inline input (add-row) ─────────────────────────────────────────── */
input.sqe-inline-input {
  border: 1px solid transparent;
  outline: none;
  background: transparent;
  color: var(--sqe-text);
  font-family: var(--sqe-mono);
  font-size: 12.5px;
  padding: 4px 6px;
  border-radius: 4px;
  width: 100%;
  transition: background-color .1s, border-color .1s;
}
input.sqe-inline-input::placeholder { color: var(--sqe-text-faint); font-style: italic; }
input.sqe-inline-input:focus {
  background-color: rgba(22,163,74,0.06);
  border-color: var(--sqe-green-border);
}

/* ── Empty state ────────────────────────────────────────────────────── */
.sqe-empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--sqe-text-faint);
  font-size: 13px;
  line-height: 1.6;
}
.sqe-empty .sqe-kbd { margin: 0 3px; }
.sqe-empty .sqe-tool-btn {
  display: inline-flex;
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  vertical-align: middle;
}

/* ── Footer ─────────────────────────────────────────────────────────── */
.sqe-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.sqe-hints {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--sqe-text-faint);
  font-family: var(--sqe-mono);
}
.sqe-hints span { display: inline-flex; align-items: center; gap: 5px; }

.sqe-continue-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 22px;
  height: 40px;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--sqe-green);
  color: #041309;
  border: 1px solid var(--sqe-green);
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .1s, box-shadow .1s;
  font-family: inherit;
  white-space: nowrap;
}
.sqe-continue-btn:hover {
  background: #15803d;
  border-color: #15803d;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22,163,74,0.3);
}

/* ── Toast ──────────────────────────────────────────────────────────── */
#sqe-toast {
  display: none;
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10001;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 12.5px;
  font-family: inherit;
  background: var(--sqe-card-alt);
  border: 1px solid var(--sqe-border);
  color: var(--sqe-text);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  animation: sqe-toast-in .2s ease;
}
.sqe-toast-success { border-color: var(--sqe-green-border) !important; color: var(--sqe-green) !important; }
.sqe-toast-error   { border-color: rgba(239,68,68,0.4) !important;     color: var(--sqe-red) !important;   }

@keyframes sqe-toast-in {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .sqe-row {
    grid-template-columns: 28px 66px minmax(0,1fr) 58px 0px 0px 56px;
  }
  .sqe-col-detail, .sqe-col-src { display: none; }
  .sqe-toolbar { flex-wrap: wrap; }
  .sqe-filter-wrap { flex-basis: 100%; order: -1; }
  .sqe-continue-btn { width: 100%; justify-content: center; }
  .sqe-footer { flex-direction: column; align-items: stretch; }
}
