/* ============================================================
   Tools Dashboard — ADR-104
   Hierarchical sections, collapsible subsections, placeholder cards
   Azia Light Theme — slate palette
   ============================================================ */

body.tools-active #expanded-title,
body.tools-active #detail-panel,
body.tools-active #bg-layer,
body.tools-active #c4-link { display: none !important; }

#tools-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: #F8FAFC;
  color: #475569;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
}

#tools-view::before { content: none; }

/* ---- Header ---- */
.tools-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  z-index: 250;
  flex-shrink: 0;
  border-bottom: 2px solid #64748B;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.tools-header-left { display: flex; align-items: center; gap: 12px; }
.tools-title { font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; color: #172351; }
.tools-subtitle { font-size: 0.75rem; font-weight: 400; color: rgba(71,85,105,0.7); text-transform: uppercase; letter-spacing: 0.08em; margin-left: 4px; }

/* ---- Two-Level Navigation ---- */
.tls-nav-container {
  flex-shrink: 0;
  background: #1E293B;
  border-bottom: 1px solid #334155;
  z-index: 240;
}

.tls-primary-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 28px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tls-pnav-item {
  padding: 7px 14px;
  border-radius: 8px 8px 0 0;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
  border: 1px solid transparent;
  border-bottom: none;
}

.tls-pnav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.tls-pnav-item.active {
  color: #fff;
  background: rgba(100, 116, 139, 0.3);
  border-color: rgba(100, 116, 139, 0.5);
  font-weight: 600;
}

.tls-sub-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 28px 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tls-sub-nav.hidden { display: none; }

.tls-snav-item {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 400;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tls-snav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.25); }


/* ---- Scrollable body ---- */
.tools-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
}

/* ---- Primary Section ---- */
.tls-section {
  margin-bottom: 8px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  border: 1px solid #E5E7EB;
  overflow: hidden;
}

.tls-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.tls-section-header:hover { background: #F8FAFC; }

.tls-section-header .tls-chevron {
  font-size: 0.7rem;
  color: #94A3B8;
  flex-shrink: 0;
  width: 14px;
}

.tls-section-label {
  font-size: 1rem;
  font-weight: 600;
  color: #172351;
  flex: 1;
}

.tls-worker-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #F1F5F9;
  color: #64748B;
  border: 1px solid #CBD5E1;
}

.tls-section-body {
  padding: 0 20px 20px;
}

.tls-section-body.collapsed { display: none; }

/* ---- Metric cards ---- */
.tools-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.tools-metric-card {
  background: #F8FAFC;
  border-radius: 8px;
  padding: 14px 16px;
  border: 1px solid #E5E7EB;
}

.tools-metric-card .metric-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: #94A3B8; margin-bottom: 4px;
}

.tools-metric-card .metric-value {
  font-size: 1.4rem; font-weight: 700; color: #172351;
}

/* ---- Subsection ---- */
.tls-subsection {
  margin-bottom: 4px;
  border-radius: 8px;
  border: 1px solid #F1F5F9;
  overflow: hidden;
}

.tls-subsection-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: #334155;
  background: #FAFBFC;
  user-select: none;
  transition: background 0.15s;
}

.tls-subsection-header:hover { background: #F1F5F9; }

.tls-subsection-header .tls-chevron {
  font-size: 0.65rem;
  color: #94A3B8;
  width: 12px;
  flex-shrink: 0;
}

.tls-subsection-body { padding: 12px 16px; }
.tls-subsection-body.collapsed { display: none; }

/* ---- Return to Top ---- */
.tls-return-top {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 14px;
  border-radius: 12px;
  border: 1px solid #E5E7EB;
  background: #F8FAFC;
  font-size: 0.72rem;
  font-weight: 500;
  color: #64748B;
  cursor: pointer;
  transition: all 0.15s;
}

.tls-return-top:hover { background: #F1F5F9; color: #334155; border-color: #CBD5E1; }

/* ---- Status Pills ---- */
.tls-status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-left: auto;
}

.tls-status-live { background: #DCFCE7; color: #166534; }
.tls-status-connected { background: #DCFCE7; color: #166534; }
.tls-status-blocked { background: #FEE2E2; color: #991B1B; }
.tls-status-pending { background: #FEF3C7; color: #92400E; }
.tls-status-notconn { background: #F3F4F6; color: #6B7280; }

/* ---- Placeholder Cards ---- */
.tls-placeholder-card {
  background: #FAFBFC;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 16px;
}

.tls-placeholder-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.tls-api-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 500;
  background: #F1F5F9;
  color: #64748B;
  border: 1px solid #CBD5E1;
}

.tls-mini-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.tls-mini-metric {
  background: #fff;
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid #E5E7EB;
  text-align: center;
}

.tls-mini-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94A3B8;
  margin-bottom: 4px;
}

.tls-mini-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: #CBD5E1;
}

.tls-placeholder-desc {
  font-size: 0.8rem;
  color: #64748B;
  line-height: 1.5;
  margin: 0 0 8px;
}

.tls-auth-note {
  font-size: 0.72rem;
  color: #94A3B8;
  padding-top: 8px;
  border-top: 1px solid #F1F5F9;
}

.tls-auth-note strong { color: #64748B; }

/* ---- Platform filter pills ---- */
.tools-filter-bar { display: flex; gap: 8px; margin-bottom: 16px; }

.tools-filter-pill {
  padding: 5px 14px;
  border-radius: 16px;
  border: 1px solid #E5E7EB;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  color: #475569;
  transition: all 0.15s;
}

.tools-filter-pill:hover { border-color: #64748B; color: #1E293B; }
.tools-filter-pill.active { background: #64748B; color: #fff; border-color: #64748B; }

/* ---- Stakeholder groups ---- */
.stk-group { background: #fff; border-radius: 10px; border: 1px solid #E5E7EB; margin-bottom: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.stk-group-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: #F8FAFC; cursor: pointer; border-bottom: 1px solid #E5E7EB; }
.stk-group-header:hover { background: #F1F5F9; }
.stk-group-name { font-weight: 600; font-size: 0.88rem; color: #172351; }
.stk-group-count { font-size: 0.75rem; color: #94A3B8; background: #F1F5F9; padding: 2px 8px; border-radius: 10px; }
.stk-group-body { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.stk-group-body.open { max-height: 2000px; }

/* ---- Stakeholder table ---- */
.stk-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.82rem; }
.stk-table th { background: #F1F5F9; color: #475569; font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 14px; text-align: left; border-bottom: 1px solid #E5E7EB; }
.stk-table td { padding: 8px 14px; border-bottom: 1px solid #F1F5F9; color: #475569; }
.stk-table tr:last-child td { border-bottom: none; }
.stk-table tr:hover td { background: #FAFBFC; }
.stk-social-link { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 0.72rem; color: #0693E3; text-decoration: none; background: #EFF6FF; margin-right: 4px; }
.stk-social-link:hover { background: #DBEAFE; }

/* ---- Tool inventory cards ---- */
.tools-inventory { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 16px; }
.tool-card { background: #fff; border-radius: 10px; padding: 20px; border: 1px solid #E5E7EB; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.tool-card h4 { font-size: 0.95rem; font-weight: 600; color: #172351; margin: 0 0 8px; }
.tool-card p { font-size: 0.82rem; color: #64748B; margin: 0 0 12px; line-height: 1.5; }
.tool-card-specs { display: flex; flex-direction: column; gap: 4px; }
.tool-card-spec { display: flex; justify-content: space-between; font-size: 0.75rem; }
.tool-card-spec .spec-label { color: #94A3B8; }
.tool-card-spec .spec-value { color: #172351; font-weight: 500; }

/* ---- Add Stakeholder Button ---- */
.stk-add-btn { display: inline-block; padding: 8px 20px; border-radius: 6px; background: #1E293B; color: #fff; font-size: 0.82rem; font-weight: 600; border: none; cursor: pointer; margin-bottom: 16px; transition: background 0.15s; }
.stk-add-btn:hover { background: #334155; }

/* ---- Stakeholder Form ---- */
.stk-form-wrapper { background: #fff; border: 2px solid #64748B; border-radius: 10px; padding: 24px; margin-bottom: 20px; box-shadow: 0 4px 12px rgba(100, 116, 139, 0.12); }
.stk-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px; }
.stk-form-field { display: flex; flex-direction: column; gap: 4px; }
.stk-form-field label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: #475569; }
.stk-req { color: #EF4444; }
.stk-form-field input, .stk-form-field select, .stk-form-field textarea { padding: 8px 12px; border: 1px solid #D1D5DB; border-radius: 6px; font-size: 0.85rem; font-family: inherit; color: #1E293B; background: #fff; transition: border-color 0.15s; }
.stk-form-field input:focus, .stk-form-field select:focus, .stk-form-field textarea:focus { outline: none; border-color: #64748B; box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.15); }
.stk-form-field input::placeholder, .stk-form-field textarea::placeholder { color: #94A3B8; }
.stk-form-full { margin-bottom: 14px; }
.stk-form-id { font-size: 0.78rem; color: #64748B; margin-bottom: 14px; }
.stk-id-badge { display: inline-block; padding: 1px 8px; border-radius: 4px; border: 1px solid #64748B; color: #64748B; font-weight: 600; font-size: 0.75rem; font-family: monospace; }
.stk-form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; padding-top: 14px; border-top: 1px solid #E5E7EB; }
.stk-form-cancel { padding: 8px 20px; border-radius: 6px; border: 1px solid #D1D5DB; background: #fff; color: #475569; font-size: 0.82rem; font-weight: 500; cursor: pointer; transition: background 0.15s; }
.stk-form-cancel:hover { background: #F1F5F9; }
.stk-form-submit { padding: 8px 20px; border-radius: 6px; border: none; background: #64748B; color: #fff; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.stk-form-submit:hover { background: #475569; }

/* ---- Search Bar ---- */
.stk-search-bar { margin-bottom: 16px; }
.stk-search-input { width: 100%; padding: 10px 16px; border: 1px solid #D1D5DB; border-radius: 8px; font-size: 0.85rem; font-family: inherit; color: #1E293B; background: #fff; box-sizing: border-box; transition: border-color 0.15s; }
.stk-search-input:focus { outline: none; border-color: #64748B; box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.15); }
.stk-search-input::placeholder { color: #94A3B8; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .tools-metrics { grid-template-columns: repeat(2, 1fr); }
  .tls-mini-metrics { grid-template-columns: repeat(2, 1fr); }
  .tls-primary-nav { padding: 8px 12px 0; }
  .tls-sub-nav { padding: 6px 12px 8px; }
  .tools-body { padding: 16px 12px; }
  .stk-form-row { grid-template-columns: 1fr; }
}
