/* ── Component: SettingsPage ──
 * Class prefix: stg-
 */

/* ── Settings Page ── scoped under .stg ── */

.stg {
  position: fixed;
  top: var(--topbar-h, 0);
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 400;
  background: var(--bg, #0A0B0F);
  display: flex;
  flex-direction: column;
}

.stg-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── Sidebar ── */
.stg-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: rgba(17, 19, 24, 0.95);
  border-right: 1px solid rgba(255,255,255,0.07);
  padding: 28px 0;
  position: sticky;
  top: 0;
  height: 100%;
  overflow-y: auto;
}

.stg-sidebar-top {
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 12px;
}

.stg-back-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #5A5F7A;
  cursor: pointer;
  margin-bottom: 14px;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}
.stg-back-row svg {
  width: 13px; height: 13px;
  stroke: currentColor; fill: none;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.stg-back-row:hover { color: #E2E4EE; }

.stg-sidebar-title {
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.stg-sidebar-sub {
  font-size: 11px;
  color: #5A5F7A;
  margin-top: 2px;
}

/* ── Nav items ── */
.stg-nav-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #2E3148;
  padding: 14px 20px 6px;
}

.stg-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  cursor: pointer;
  font-size: 13px;
  color: #5A5F7A;
  transition: all 0.12s;
  border-left: 2px solid transparent;
  background: none;
  border-right: none;
  border-top: none;
  border-bottom: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.stg-nav-item svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.stg-nav-item:hover {
  color: #E2E4EE;
  background: rgba(255,255,255,0.03);
}
.stg-nav-item.active {
  color: #fff;
  border-left-color: #fff;
  background: rgba(255,255,255,0.04);
}

.stg-nav-badge {
  margin-left: auto;
  background: rgba(251,191,36,0.15);
  color: #FBBF24;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
}
.stg-nav-badge-r {
  margin-left: auto;
  background: rgba(248,113,113,0.12);
  color: #F87171;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
}

.stg-nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 10px 0;
}

/* ── Main content ── */
.stg-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 860px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.stg-main-content {
  flex: 1;
  padding: 0 48px 40px;
}

/* ── Search bar ── */
.stg-search-wrap {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 20px 48px 12px;
  background: var(--bg, #0A0B0F);
  display: flex;
  align-items: center;
}

.stg-search-input {
  width: 100%;
  padding: 10px 36px 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(17,19,24,0.95);
  color: #E2E4EE;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235A5F7A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.stg-search-input::placeholder { color: #3A3F5A; }
.stg-search-input:focus { border-color: rgba(255,255,255,0.2); }

.stg-search-clear {
  position: absolute;
  right: 56px;
  background: none;
  border: none;
  color: #5A5F7A;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
}
.stg-search-clear:hover { color: #E2E4EE; }

/* ── Gray count badge (nav) ── */
.stg-nav-badge-g {
  margin-left: auto;
  background: rgba(90,95,122,0.12);
  color: #5A5F7A;
  font-size: 9px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
}

/* ── Category sub-heading (All Tools view) ── */
.stg-cat-subhead {
  font-size: 13px;
  font-weight: 600;
  color: #E2E4EE;
  margin: 20px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stg-cat-subhead:first-child { margin-top: 0; }
.stg-cat-subhead-count {
  font-size: 11px;
  font-weight: 500;
  color: #5A5F7A;
}

.stg-page-head {
  margin-bottom: 28px;
}
.stg-page-title {
  font-family: 'Syne', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}
.stg-page-sub {
  font-size: 13px;
  color: #5A5F7A;
}

/* ── Section label with horizontal rule ── */
.stg-slabel {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #2E3148;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.stg-slabel::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.07);
}
.stg-slabel-count {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.stg-slabel-count.red { color: #F87171; }
.stg-slabel-count.muted { color: #5A5F7A; font-weight: 500; }

/* ── Tool grid ── */
.stg-tool-grid {
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 32px;
}

.stg-tool-row {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  gap: 14px;
  background: rgba(17,19,24,0.95);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  transition: background 0.12s;
}
.stg-tool-row:last-child { border-bottom: none; }
.stg-tool-row:hover { background: rgba(22,24,31,0.95); }

.stg-tool-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: #16181F;
  border: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.stg-tool-info {
  flex: 1;
  min-width: 0;
}
.stg-tool-name {
  font-size: 13px;
  font-weight: 600;
  color: #E2E4EE;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stg-tool-desc {
  font-size: 11px;
  color: #5A5F7A;
  margin-top: 2px;
}

/* ── Status badges ── */
.stg-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}
.stg-badge.ready {
  color: #4ADE80;
  background: rgba(74,222,128,0.08);
  border: 1px solid rgba(74,222,128,0.2);
}
.stg-badge.needed {
  color: #FBBF24;
  background: rgba(251,191,36,0.08);
  border: 1px solid rgba(251,191,36,0.2);
}
.stg-badge.env {
  color: #5A5F7A;
  background: #1C1F28;
  border: 1px solid rgba(255,255,255,0.07);
  font-size: 9px;
}

/* ── Action buttons ── */
.stg-tool-action {
  flex-shrink: 0;
}
.stg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 7px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}
.stg-btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: #5A5F7A;
}
.stg-btn-ghost:hover {
  color: #E2E4EE;
  border-color: #5A5F7A;
}
.stg-btn-sm {
  padding: 5px 12px;
  font-size: 11px;
  border-radius: 6px;
}

/* ── Wallet section ── */
.stg-wallet-card {
  background: rgba(17,19,24,0.95);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 12px;
}
.stg-wallet-header {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stg-wallet-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5A5F7A;
}
.stg-wallet-body {
  padding: 16px 18px;
}

/* ── API Keys section ── */
.stg-key-grid {
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 32px;
}
.stg-key-row {
  display: flex;
  align-items: center;
  padding: 13px 18px;
  gap: 14px;
  background: rgba(17,19,24,0.95);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.stg-key-row:last-child { border-bottom: none; }
.stg-key-name {
  width: 160px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 500;
  color: #E2E4EE;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stg-key-name svg {
  width: 13px; height: 13px;
  stroke: #5A5F7A; fill: none;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.stg-key-val {
  flex: 1;
  font-size: 12px;
  color: #5A5F7A;
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  background: #16181F;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 6px;
  padding: 5px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stg-key-status {
  flex-shrink: 0;
}

/* ── Loading / empty ── */
.stg-loading {
  text-align: center;
  padding: 48px 16px;
  color: #5A5F7A;
  font-size: 14px;
}

.stg-empty {
  text-align: center;
  padding: 32px 16px;
  color: #5A5F7A;
}
.stg-empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}
.stg-empty-text {
  font-size: 14px;
  margin: 4px 0;
}
.stg-empty-sub {
  font-size: 12px;
  color: #475569;
}

/* ── Red dot on tool icon (Must Setup) ── */
.stg-icon-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #F87171;
  border: 2px solid rgba(17,19,24,0.95);
}

/* ── Settings dot on hamburger ── */
.hamburger-settings-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #F87171;
  border: 2px solid var(--bg, #080B14);
}
.hamburger-item-settings-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #F87171;
  margin-left: 6px;
  flex-shrink: 0;
}

/* ── Mobile responsive ── */
@media (max-width: 768px) {
  .stg-sidebar {
    display: none;
  }
  .stg-mobile-filter {
    display: block;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
  }
  .stg-mobile-filter select {
    width: 100%;
    padding: 8px 12px;
    background: #16181F;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: #E2E4EE;
    font-size: 13px;
    font-family: inherit;
    -webkit-appearance: none;
  }
  .stg-search-wrap {
    padding: 12px 16px 8px;
  }
  .stg-main-content {
    padding: 0 16px 20px;
  }
  .stg-search-clear {
    right: 24px;
  }
  .stg-tool-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .stg-tool-info {
    min-width: 60%;
  }
  .stg-key-name {
    width: auto;
    min-width: 100px;
  }
}

@media (min-width: 769px) {
  .stg-mobile-filter {
    display: none;
  }
}

/* ── Landscape mode: phones held sideways ── */
@media (orientation: landscape) and (max-height: 500px) {
  .stg-sidebar { width: 160px; padding: 12px 0; }
  .stg-search-wrap { padding: 10px 16px 6px; }
  .stg-main-content { padding: 0 24px 20px; }
}
