/* ============================================================
   linkhub.css  —  OneCube · Link Hub module styles
   Scoped to #tab-linkhub and .lh-* prefix
   Inherits Post Archiver CSS tokens from dashboard.css
   ============================================================ */

/* ── Sub-navigation ──────────────────────────────────────── */
.lh-subnav {
  display: flex;
  gap: 4px;
  padding: 0 0 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.lh-subbtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--muted);
  font: 700 11px/1 'Inter', system-ui, sans-serif;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.lh-subbtn span {
  font-size: 13px;
  opacity: 0.75;
}

.lh-subbtn em {
  font-style: normal;
  background: var(--line);
  color: var(--muted);
  border-radius: 100px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 800;
  min-width: 20px;
  text-align: center;
  transition: background 0.15s, color 0.15s;
}

.lh-subbtn:hover {
  background: #fff;
  border-color: var(--green);
  color: var(--green);
}

.lh-subbtn.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.lh-subbtn.active em {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

/* ── View panels ─────────────────────────────────────────── */
.lh-view {
  display: none;
  opacity: 0;
  animation: lhFadeIn 0.18s ease forwards;
}

.lh-view.active {
  display: block;
  opacity: 1;
}

@keyframes lhFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Page headers ────────────────────────────────────────── */
.lh-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.lh-page-header h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}

.lh-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lh-note {
  font-size: 10px;
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.85;
}

.lh-eyebrow {
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

/* ── Stats row ───────────────────────────────────────────── */
.lh-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.lh-stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}

.lh-stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--line);
  border-radius: 10px 0 0 10px;
}

.lh-stat-card.lh-stat-accent::before { background: var(--green); }
.lh-stat-card.lh-stat-success::before { background: #27ae60; }
.lh-stat-card.lh-stat-warn::before { background: var(--gold); }

.lh-stat-card small {
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.lh-stat-card strong {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 4px;
  letter-spacing: -0.03em;
}

.lh-stat-card span {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
}

/* ── Batch builder ───────────────────────────────────────── */
.lh-batch-builder {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  align-items: start;
}

.lh-bb-copy h2 {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  margin: 6px 0 8px;
}

.lh-bb-copy p {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
  line-height: 1.6;
}

.lh-bb-controls label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.lh-bb-entry {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.lh-bb-entry input[type="number"] {
  width: 90px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: 700 15px/1 'Inter', system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}

.lh-bb-entry input[type="number"]::-webkit-inner-spin-button,
.lh-bb-entry input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }

.lh-bb-entry input[type="number"]:focus {
  border-color: var(--green);
  background: #fff;
}

.lh-bb-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.lh-bb-presets button {
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--paper);
  font: 700 11px/1 'Inter', system-ui, sans-serif;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.14s;
}

.lh-bb-presets button:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-soft, #eaf5ed);
}

/* Batch builder equation preview */
.lh-bb-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
}

.lh-bb-preview > div {
  text-align: center;
}

.lh-bb-preview > div span {
  display: block;
  font-size: 26px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.03em;
}

.lh-bb-preview > div small {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lh-bb-div {
  font-size: 20px;
  color: var(--muted);
  font-weight: 300;
  opacity: 0.6;
}

.lh-bb-result span {
  color: var(--green) !important;
}

.lh-bb-feedback {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--muted);
  margin: -8px 0 0;
  min-height: 16px;
  font-style: italic;
}

/* ── Dashboard 2-col grid ────────────────────────────────── */
.lh-dash-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
}

.lh-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 8px;
  flex-wrap: wrap;
}

.lh-panel-header b {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* Quick list */
.lh-quick-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
}

.lh-quick-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}

.lh-quick-item:hover {
  border-color: var(--green);
  background: #fff;
}

.lh-quick-num {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  min-width: 32px;
  text-align: center;
  background: var(--line);
  border-radius: 5px;
  padding: 3px 6px;
}

.lh-quick-details {
  flex: 1;
  min-width: 0;
}

.lh-quick-details b {
  display: block;
  font-size: 12px;
  color: var(--ink);
  font-weight: 700;
}

.lh-quick-details small {
  font-size: 10px;
  color: var(--muted);
}

/* Notes panel */
.lh-notes-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lh-note-item {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.65;
  padding: 10px 12px;
  background: var(--paper);
  border-radius: 7px;
  border-left: 2px solid var(--line);
}

.lh-note-item b {
  display: block;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 2px;
}

.lh-notes-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* ── Small button variant ────────────────────────────────── */
.lh-btn-sm {
  font-size: 10px !important;
  padding: 5px 11px !important;
}

/* ── Toolbar (profiles view) ─────────────────────────────── */
.lh-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.lh-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.lh-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Search wrap */
.lh-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 380px;
}

.lh-search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s;
}

.lh-search-wrap:has(input:not(:placeholder-shown)) .lh-search-clear {
  opacity: 1;
  pointer-events: auto;
}

.lh-search-count {
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

/* Select */
.lh-select {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  font: 700 11px/1 'Inter', system-ui, sans-serif;
  color: var(--ink);
  cursor: pointer;
  outline: none;
  transition: border-color 0.14s;
}

.lh-select:focus { border-color: var(--green); }

/* ── Selection banner ────────────────────────────────────── */
.lh-selection-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.lh-selection-banner.visible {
  display: flex;
}

.lh-selection-banner span {
  font-size: 12px;
  font-weight: 700;
}

.lh-selection-banner > div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Profiles table ──────────────────────────────────────── */
.lh-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.lh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.lh-table thead th {
  background: var(--paper);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.lh-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink);
  transition: background 0.1s;
}

.lh-table tbody tr:last-child td {
  border-bottom: none;
}

.lh-table tbody tr:hover td {
  background: var(--paper);
}

.lh-table tbody tr.selected td {
  background: #eaf5ed;
}

.lh-table tbody tr.lh-alpha-group td {
  background: var(--paper);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--green);
  text-transform: uppercase;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
}

.lh-table td a {
  color: var(--green);
  text-decoration: none;
  font-weight: 500;
}

.lh-table td a:hover { text-decoration: underline; }

.lh-table td .lh-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}

/* ── Batches grid ────────────────────────────────────────── */
.lh-batches-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.lh-batch-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 360px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.lh-batch-card:hover {
  border-color: var(--green);
  box-shadow: 0 4px 16px rgba(33,123,73,0.08);
}

.lh-batch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  flex-shrink: 0;
  gap: 10px;
}

.lh-batch-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lh-batch-header b {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

.lh-batch-header small {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
}

.lh-batch-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.lh-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.lh-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 100px;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink);
  cursor: default;
  transition: border-color 0.12s;
  white-space: nowrap;
}

.lh-chip:hover {
  border-color: var(--green);
  color: var(--green);
}

/* ── Add / Manage grid ───────────────────────────────────── */
.lh-manage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 0;
}

.lh-mgr-icon {
  width: 36px;
  height: 36px;
  background: var(--green);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 300;
  flex-shrink: 0;
}

.lh-mgr-icon.lh-mgr-icon-rm {
  background: #c0392b;
}

.lh-textarea {
  width: 100%;
  min-height: 160px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 400 12px/1.65 'Courier New', Courier, monospace;
  color: var(--ink);
  background: var(--paper);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.lh-textarea:focus {
  border-color: var(--green);
  background: #fff;
}

.lh-textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.lh-mgr-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 10px;
}

.lh-mgr-footer span {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}

/* ── Modals ──────────────────────────────────────────────── */
.lh-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(23,28,25,0.55);
  z-index: 9000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.lh-modal-backdrop.visible {
  display: flex;
}

.lh-modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.22);
  width: 100%;
  max-width: 440px;
  margin: 20px;
  overflow: hidden;
  animation: lhModalIn 0.2s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

@keyframes lhModalIn {
  from { transform: scale(0.92) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.lh-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.lh-modal-header b {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}

.lh-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 5px;
  transition: color 0.12s, background 0.12s;
}

.lh-modal-close:hover {
  color: var(--ink);
  background: var(--line);
}

.lh-modal-body {
  padding: 20px;
}

.lh-modal-body p {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.6;
  margin: 0;
}

.lh-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

/* ── Toast tray ──────────────────────────────────────────── */
.lh-toast-tray {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 320px;
}

.lh-toast {
  background: var(--ink);
  color: #fff;
  padding: 11px 16px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0,0,0,0.2);
  pointer-events: auto;
  animation: lhToastIn 0.2s ease forwards;
  line-height: 1.4;
}

.lh-toast.lh-toast-success { background: var(--green); }
.lh-toast.lh-toast-error   { background: #c0392b; }
.lh-toast.lh-toast-warn    { background: var(--gold); color: var(--ink); }

@keyframes lhToastIn {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes lhToastOut {
  from { transform: translateY(0); opacity: 1; }
  to   { transform: translateY(8px); opacity: 0; }
}

.lh-toast.removing {
  animation: lhToastOut 0.2s ease forwards;
}

/* ── Copy-tools visibility ───────────────────────────────── */
.lh-copy-hidden .lh-copy-ctrl {
  display: none !important;
}

/* ── Settings grid additions ─────────────────────────────── */
.settings-grid-unified {
  grid-template-columns: 1fr 1fr;
}

.settings-section-label {
  grid-column: 1 / -1;
  padding: 10px 0 6px;
  border-top: 1px solid var(--line);
  margin-top: 10px;
}

.settings-section-label:first-child {
  border-top: none;
  margin-top: 0;
}

.stack-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1100px) {
  .lh-stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .lh-batch-builder {
    grid-template-columns: 1fr;
  }
  .lh-bb-preview {
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .lh-stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .lh-dash-grid {
    grid-template-columns: 1fr;
  }
  .lh-batches-grid {
    grid-template-columns: 1fr;
  }
  .lh-manage-grid {
    grid-template-columns: 1fr;
  }
  .settings-grid-unified {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .lh-stats-row {
    grid-template-columns: 1fr 1fr;
  }
  .lh-batch-builder {
    padding: 16px;
    gap: 16px;
  }
  .lh-page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
