/**
 * Dev Tools - Dark Ops Console Theme
 * Version: 1.0.0
 * Distinct from main dashboard (light theme)
 */

/* =========================================================================
   RESET & BASE
   ========================================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'IBM Plex Mono', 'SF Mono', 'Fira Code', monospace;
  background: #0d1117;
  color: #c9d1d9;
  min-height: 100vh;
}

/* =========================================================================
   LOGIN SCREEN
   ========================================================================= */
.dt-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 24px;
}

.dt-login-title {
  font-size: 28px;
  font-weight: 700;
  color: #58a6ff;
  letter-spacing: -0.5px;
}

.dt-login-subtitle {
  font-size: 13px;
  color: #484f58;
  margin-top: -12px;
}

.dt-login-btn {
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  padding: 12px 32px;
  font-size: 14px;
  font-family: inherit;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.dt-login-btn:hover {
  background: #30363d;
  border-color: #58a6ff;
  color: #58a6ff;
}

#authLoading {
  color: #f0883e;
  font-size: 13px;
  display: none;
}

#authErrorMsg {
  color: #f85149;
  font-size: 13px;
  background: #21090d;
  padding: 8px 16px;
  border-radius: 4px;
  border: 1px solid #f851494d;
  display: none;
}

/* =========================================================================
   MAIN LAYOUT
   ========================================================================= */
.dt-main {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}

/* =========================================================================
   HEADER
   ========================================================================= */
.dt-header {
  background: #161b22;
  border-bottom: 1px solid #21262d;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.dt-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dt-header-title {
  font-size: 15px;
  font-weight: 700;
  color: #58a6ff;
}

.dt-header-badge {
  background: #f0883e1a;
  color: #f0883e;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dt-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: #484f58;
}

.dt-header-right a {
  color: #484f58;
  text-decoration: none;
  cursor: pointer;
}

.dt-header-right a:hover { color: #f85149; }

.dt-back-link {
  color: #58a6ff !important;
  text-decoration: none;
  font-size: 12px;
}

.dt-back-link:hover { text-decoration: underline; }

/* =========================================================================
   NAVIGATION BAR
   ========================================================================= */
.dt-nav {
  background: #161b22;
  border-bottom: 1px solid #21262d;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.dt-nav-btn {
  background: transparent;
  color: #484f58;
  border: none;
  padding: 10px 16px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.dt-nav-btn:hover {
  color: #c9d1d9;
  background: #21262d;
}

.dt-nav-btn.active {
  color: #58a6ff;
  border-bottom-color: #58a6ff;
}

/* =========================================================================
   CONTEXT SELECTORS (Tenant / Practitioner)
   ========================================================================= */
.dt-context {
  background: #161b22;
  border-bottom: 1px solid #21262d;
  padding: 8px 24px;
  display: none;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}

.dt-context label {
  color: #484f58;
  font-weight: 600;
}

.dt-context select {
  background: #0d1117;
  color: #c9d1d9;
  border: 1px solid #30363d;
  padding: 6px 10px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  min-width: 200px;
}

.dt-context select:focus {
  border-color: #58a6ff;
  outline: none;
}

.dt-refresh-btn {
  background: none;
  border: 1px solid #30363d;
  color: #484f58;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.dt-refresh-btn:hover {
  border-color: #58a6ff;
  color: #58a6ff;
}

/* =========================================================================
   CONTENT AREA
   ========================================================================= */
.dt-content {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* =========================================================================
   CATEGORY GROUPS (Tenant level)
   ========================================================================= */
.dt-category {
  margin-bottom: 16px;
  border: 1px solid #21262d;
  border-radius: 6px;
  overflow: hidden;
}

.dt-category-header {
  background: #161b22;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #c9d1d9;
  user-select: none;
}

.dt-category-header:hover { background: #1c2129; }

.dt-chevron {
  font-size: 11px;
  color: #484f58;
  transition: transform 0.15s;
}

.dt-category-body {
  padding: 8px;
}

/* =========================================================================
   ENDPOINT CARDS
   ========================================================================= */
.dt-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 6px;
  margin-bottom: 8px;
  overflow: hidden;
}

.dt-card-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.dt-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dt-card-label {
  font-size: 13px;
  font-weight: 600;
  color: #c9d1d9;
}

.dt-card-desc {
  font-size: 11px;
  color: #484f58;
}

.dt-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.dt-endpoint-path {
  font-size: 10px;
  color: #484f58;
  background: #0d1117;
  padding: 3px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

/* =========================================================================
   BUTTONS
   ========================================================================= */
.dt-btn-check, .dt-btn-action {
  font-family: inherit;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid #30363d;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.dt-btn-check {
  background: #21262d;
  color: #58a6ff;
}

.dt-btn-check:hover {
  background: #30363d;
  border-color: #58a6ff;
}

.dt-btn-action {
  background: #1f6feb26;
  color: #58a6ff;
  border-color: #1f6feb;
}

.dt-btn-action:hover {
  background: #1f6feb40;
}

.dt-btn-confirm {
  color: #f0883e;
  border-color: #f0883e4d;
  background: #f0883e0d;
}

.dt-btn-confirm:hover {
  background: #f0883e1a;
  border-color: #f0883e;
}

.dt-btn-check:disabled, .dt-btn-action:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* =========================================================================
   OUTPUT PANELS
   ========================================================================= */
.dt-output {
  display: none;
  border-top: 1px solid #21262d;
  background: #0d1117;
}

.dt-output.active {
  display: block;
}

.dt-output-header {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #21262d;
  font-size: 12px;
}

.dt-status-ok { color: #3fb950; }
.dt-status-err { color: #f85149; }
.dt-output-time { color: #484f58; margin-left: auto; }

.dt-copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
}

.dt-json {
  padding: 12px 16px;
  font-size: 11px;
  line-height: 1.5;
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.dt-json.dt-error { color: #f85149; }

/* Syntax highlighting */
.dt-key { color: #79c0ff; }
.dt-str { color: #a5d6ff; }
.dt-num { color: #d2a8ff; }
.dt-bool { color: #f0883e; }
.dt-null { color: #484f58; }

.dt-loading {
  color: #f0883e;
  font-size: 12px;
  padding: 12px 16px;
  display: block;
  animation: dtPulse 1.2s ease-in-out infinite;
}

@keyframes dtPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* =========================================================================
   SYNC COVERAGE MONITOR
   ========================================================================= */
.dt-monitor-card { border-color: #1f6feb4d; }
.dt-monitor-card .dt-card-header { border-bottom: 1px solid #21262d; }

.dt-auto-refresh {
  font-size: 11px;
  color: #484f58;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.dt-auto-refresh input { cursor: pointer; }

/* Summary bar */
.sc-summary { padding: 12px 16px; border-bottom: 1px solid #21262d; }

.sc-summary-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.sc-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px;
  border-radius: 6px;
  min-width: 80px;
}

.sc-badge-num { font-size: 22px; font-weight: 700; }
.sc-badge-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

.sc-badge-total { background: #21262d; color: #c9d1d9; }
.sc-badge-ok { background: #0d2818; color: #3fb950; }
.sc-badge-stale { background: #2a1e00; color: #f0883e; }
.sc-badge-never { background: #21090d; color: #f85149; }
.sc-badge-pct { background: #0d1d3a; color: #58a6ff; }

/* Progress bar */
.sc-progress-bar {
  height: 6px;
  background: #21262d;
  border-radius: 3px;
  margin-top: 10px;
  display: flex;
  overflow: hidden;
}

.sc-progress-fill { height: 100%; transition: width 0.4s ease; }
.sc-fill-ok { background: #3fb950; }
.sc-fill-stale { background: #f0883e; }

.sc-summary-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
  color: #484f58;
}

/* Sort bar */
.sc-sort-bar {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid #21262d;
  background: #0d1117;
}

.sc-sort-label { font-size: 11px; color: #484f58; }

.sc-sort-btn {
  font-family: inherit;
  font-size: 11px;
  padding: 3px 8px;
  background: #21262d;
  color: #484f58;
  border: 1px solid #30363d;
  border-radius: 3px;
  cursor: pointer;
}

.sc-sort-btn:hover { color: #c9d1d9; border-color: #484f58; }
.sc-sort-btn.sc-sort-active { color: #58a6ff; border-color: #1f6feb; background: #1f6feb1a; }

.sc-client-count { margin-left: auto; font-size: 11px; color: #484f58; }

/* Client grid */
.sc-grid { max-height: 600px; overflow-y: auto; }

.sc-grid-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1.5fr 0.7fr;
  padding: 6px 16px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  font-size: 10px;
  font-weight: 600;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.sc-grid-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1.5fr 0.7fr;
  padding: 5px 16px;
  font-size: 12px;
  border-bottom: 1px solid #21262d08;
  transition: background 0.1s;
}

.sc-grid-row:hover { background: #161b2280; }

/* Row status colours */
.sc-row-ok { border-left: 3px solid #3fb950; }
.sc-row-ok .sc-col-sync { color: #3fb950; }
.sc-row-ok .sc-col-ago { color: #3fb950; }

.sc-row-recent { border-left: 3px solid #58a6ff; }
.sc-row-recent .sc-col-sync { color: #58a6ff; }

.sc-row-stale { border-left: 3px solid #f0883e; }
.sc-row-stale .sc-col-sync { color: #f0883e; }
.sc-row-stale .sc-col-ago { color: #f0883e; }

.sc-row-old { border-left: 3px solid #f85149; }
.sc-row-old .sc-col-sync { color: #f85149; }
.sc-row-old .sc-col-ago { color: #f85149; }

.sc-row-never { border-left: 3px solid #484f58; opacity: 0.6; }
.sc-row-never .sc-col-sync { color: #484f58; font-style: italic; }
.sc-row-never .sc-col-ago { color: #484f58; }

.sc-col-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-col-clinic { color: #484f58; overflow: hidden; text-overflow: ellipsis; }
.sc-col-sync { font-variant-numeric: tabular-nums; }
.sc-col-ago { text-align: right; font-variant-numeric: tabular-nums; }

/* =========================================================================
   ENHANCED TRIGGER CARDS
   ========================================================================= */
.dt-enhanced-card { border-color: #f0883e33; }

.et-reset-toggle {
  font-size: 11px;
  color: #f0883e;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 3px 8px;
  border: 1px solid #f0883e33;
  border-radius: 3px;
  background: #f0883e0a;
}

.et-reset-toggle input { cursor: pointer; accent-color: #f0883e; }

/* Progress panel */
.et-progress-panel {
  display: none;
  border-top: 1px solid #21262d;
  background: #0d1117;
}

.et-progress-panel.active { display: block; }

.et-progress-inner { padding: 12px 16px; }

/* Status row */
.et-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.et-status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
}

.et-s-trigger { background: #1f6feb1a; color: #58a6ff; }
.et-s-running { background: #f0883e1a; color: #f0883e; animation: dtPulse 1.5s ease-in-out infinite; }
.et-s-done { background: #3fb9501a; color: #3fb950; }
.et-s-err { background: #f851491a; color: #f85149; }
.et-s-idle { background: #21262d; color: #484f58; }

.et-phase-badge {
  font-size: 11px;
  color: #c9d1d9;
  background: #21262d;
  padding: 2px 8px;
  border-radius: 3px;
}

.et-refresh-btn {
  background: none;
  border: 1px solid #30363d;
  color: #484f58;
  width: 24px;
  height: 24px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.et-refresh-btn:hover { color: #58a6ff; border-color: #58a6ff; }

.et-last-activity {
  font-size: 10px;
  color: #484f58;
  margin-left: auto;
}

/* Progress bar */
.et-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.et-bar-track {
  flex: 1;
  height: 8px;
  background: #21262d;
  border-radius: 4px;
  overflow: hidden;
}

.et-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.et-bar-trigger { background: #58a6ff; }
.et-bar-running { background: #f0883e; animation: etBarPulse 2s ease-in-out infinite; }
.et-bar-done { background: #3fb950; }
.et-bar-err { background: #f85149; }
.et-bar-idle { background: #484f58; }

@keyframes etBarPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.et-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: #c9d1d9;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Stats chips */
.et-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.et-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
}

.et-chip-ok { background: #0d2818; color: #3fb950; }
.et-chip-err { background: #21090d; color: #f85149; }
.et-chip-info { background: #0d1d3a; color: #58a6ff; }
.et-chip-dim { background: #21262d; color: #484f58; }

/* Timestamps */
.et-timestamps {
  display: flex;
  gap: 16px;
  font-size: 10px;
  color: #484f58;
  margin-top: 4px;
}

.et-message {
  font-size: 12px;
  color: #c9d1d9;
  padding: 4px 0;
}

/* =========================================================================
   SCROLLBAR
   ========================================================================= */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #0d1117; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }
