/* ============================================================
   TAB HELP ICONS & FLOATING BUBBLE
   Context-sensitive help for Automations and Deployment tabs.

   ADDING HELP FOR A NEW TAB
   - Add an entry to SWAM.tabHelp.content in js/tab_help.js
   - Add a .tab-help-icon span inside the new tab button
   - See skills.md for the full pattern rule
============================================================ */

/* ── Help icon (inside tab button) ────────────────────────────────────── */

.tab-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 6px;
  font-size: 9px;
  font-weight: 700;
  font-family: var(--font-mono, ui-monospace, monospace);
  color: rgba(148, 163, 184, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 50%;
  line-height: 1;
  vertical-align: middle;
  cursor: pointer;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease,
              box-shadow 0.14s ease;
  flex-shrink: 0;
  user-select: none;
  position: relative;
  top: -1px;
}

.settings-tab.active .tab-help-icon {
  color: rgba(147, 197, 253, 0.75);
  border-color: rgba(147, 197, 253, 0.4);
}

.tab-help-icon:hover {
  color: #ffffff !important;
  background: rgba(59, 130, 246, 0.28) !important;
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
}

/* Light theme */
body.theme-light .tab-help-icon {
  color: rgba(71, 85, 105, 0.5);
  border-color: rgba(71, 85, 105, 0.22);
}

body.theme-light .settings-tab.active .tab-help-icon {
  color: #2563eb;
  border-color: rgba(37, 99, 235, 0.38);
}

body.theme-light .tab-help-icon:hover {
  color: #1d4ed8 !important;
  background: rgba(59, 130, 246, 0.1) !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* ── Floating help bubble ──────────────────────────────────────────────── */

.tab-help-bubble {
  position: fixed;
  top: 120px;
  right: 752px;           /* default fallback; JS overrides per icon position */
  width: 380px;
  max-width: calc(100vw - 60px);
  max-height: 80vh;
  background: var(--bg-alt, #0f172a);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 14px;
  box-shadow: -8px 4px 32px rgba(0, 0, 0, 0.55),
              0 2px 12px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  z-index: calc(var(--z-panel, 200) + 20);
  overflow: hidden;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 0.17s ease, transform 0.17s ease;
  pointer-events: none;
}

.tab-help-bubble[hidden] {
  display: none;
}

.tab-help-bubble.open {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

/* Arrow pointing right toward the panel */
.tab-help-bubble::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 94px;              /* positioned below header roughly */
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 7px solid var(--bg-alt, #0f172a);
  pointer-events: none;
}

.tab-help-bubble::before {
  content: "";
  position: absolute;
  right: -9px;
  top: 93px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 8px solid rgba(148, 163, 184, 0.16);
  pointer-events: none;
}

/* ── Bubble header ─────────────────────────────────────────────────────── */

.tab-help-bubble-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  gap: 8px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.03);
}

.tab-help-bubble-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #93c5fd;
}

.tab-help-bubble-close {
  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
  padding: 0 !important;
  font-size: 11px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50% !important;
  opacity: 0.7;
  transition: opacity 0.14s ease, background 0.14s ease;
}

.tab-help-bubble-close:hover {
  opacity: 1;
}

/* ── Bubble body ───────────────────────────────────────────────────────── */

.tab-help-bubble-body {
  overflow-y: auto;
  padding: 14px 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.2) transparent;
}

.tab-help-bubble-body::-webkit-scrollbar {
  width: 4px;
}

.tab-help-bubble-body::-webkit-scrollbar-track {
  background: transparent;
}

.tab-help-bubble-body::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 2px;
}

/* ── Section elements ──────────────────────────────────────────────────── */

.thb-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.thb-section-heading {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #60a5fa;
  margin-bottom: 1px;
}

.thb-text {
  font-size: 12px;
  line-height: 1.62;
  color: var(--text-secondary, #94a3b8);
  margin: 0;
}

.thb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.thb-list li {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-secondary, #94a3b8);
  padding-left: 14px;
  position: relative;
}

.thb-list li::before {
  content: "›";
  position: absolute;
  left: 0;
  top: -1px;
  color: #60a5fa;
  font-weight: 700;
  font-size: 14px;
}

/* ── Light theme overrides ─────────────────────────────────────────────── */

body.theme-light .tab-help-bubble {
  background: #f1f5f9;
  border-color: rgba(30, 41, 59, 0.14);
  box-shadow: -6px 4px 24px rgba(0, 0, 0, 0.1),
              0 2px 8px rgba(0, 0, 0, 0.07);
}

body.theme-light .tab-help-bubble::after {
  border-left-color: #f1f5f9;
}

body.theme-light .tab-help-bubble::before {
  border-left-color: rgba(30, 41, 59, 0.14);
}

body.theme-light .tab-help-bubble-header {
  border-bottom-color: rgba(30, 41, 59, 0.08);
  background: rgba(0, 0, 0, 0.02);
}

body.theme-light .tab-help-bubble-title {
  color: #1d4ed8;
}

body.theme-light .thb-section-heading {
  color: #2563eb;
}

body.theme-light .thb-text,
body.theme-light .thb-list li {
  color: #475569;
}

body.theme-light .thb-list li::before {
  color: #3b82f6;
}
