/* ============================================================================
 * DEBUG TOOLBAR — Modern development debug panel
 * ----------------------------------------------------------------------------
 * Elegant, non-intrusive debug toolbar for capturing API calls and debug info.
 * Matches the Astra Nexus aesthetic with glassmorphism and HUD-style design.
 * ============================================================================ */

.an-debug-toolbar {
  --debug-bg: rgba(6, 13, 26, 0.95);
  --debug-border: rgba(78, 226, 255, 0.25);
  --debug-accent: #4ee2ff;
  --debug-accent-soft: rgba(78, 226, 255, 0.15);
  --debug-text: #e6f1ff;
  --debug-text-muted: #7a8aa8;
  --debug-success: #5cffa8;
  --debug-error: #ff4d6d;
  --debug-warning: #ffb347;

  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999999;
  font-family: var(--an-font-body, 'Rajdhani', sans-serif);
  font-size: 13px;
  pointer-events: none;
}

/* ── Toggle Button ────────────────────────────────────────────────────── */

.an-debug-toolbar__toggle {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  background: var(--debug-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--debug-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.an-debug-toolbar__toggle:hover {
  border-color: var(--debug-accent);
  box-shadow: 0 4px 24px rgba(78, 226, 255, 0.4);
  transform: translateY(-2px);
}

.an-debug-toolbar__toggle i {
  color: var(--debug-accent);
  font-size: 20px;
}

.an-debug-toolbar__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  background: var(--debug-error);
  color: white;
  border-radius: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  padding: 0 6px;
  box-shadow: 0 2px 8px rgba(255, 77, 109, 0.6);
}

/* ── Main Panel ───────────────────────────────────────────────────────── */

.an-debug-toolbar__panel {
  height: 0;
  background: var(--debug-bg);
  backdrop-filter: blur(16px);
  border-top: 2px solid var(--debug-border);
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.7);
  opacity: 0;
  overflow: hidden;
  transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease;
  pointer-events: none;
}

.an-debug-toolbar.is-open .an-debug-toolbar__panel {
  height: 400px;
  opacity: 1;
  pointer-events: auto;
}

.an-debug-toolbar.is-open .an-debug-toolbar__toggle {
  bottom: 416px;
}

/* ── Header ───────────────────────────────────────────────────────────── */

.an-debug-toolbar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 48px;
  border-bottom: 1px solid var(--debug-border);
}

.an-debug-toolbar__tabs {
  display: flex;
  gap: 4px;
}

.an-debug-toolbar__tab {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--debug-text-muted);
  font-family: var(--an-font-display, 'Orbitron', sans-serif);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.an-debug-toolbar__tab:hover {
  color: var(--debug-text);
  background: var(--debug-accent-soft);
}

.an-debug-toolbar__tab.is-active {
  color: var(--debug-accent);
  border-bottom-color: var(--debug-accent);
}

.an-debug-toolbar__tab .badge {
  background: var(--debug-accent-soft);
  color: var(--debug-accent);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

.an-debug-toolbar__actions {
  display: flex;
  gap: 8px;
}

.an-debug-toolbar__action {
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--debug-border);
  border-radius: 4px;
  color: var(--debug-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.an-debug-toolbar__action:hover {
  color: var(--debug-accent);
  border-color: var(--debug-accent);
  background: var(--debug-accent-soft);
}

/* ── Content ──────────────────────────────────────────────────────────── */

.an-debug-toolbar__content {
  height: calc(400px - 48px);
  overflow-y: auto;
  padding: 16px;
}

.an-debug-toolbar__tab-content {
  animation: debugFadeIn 0.3s ease;
}

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

/* ── Stats Grid ───────────────────────────────────────────────────────── */

.an-debug-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.an-debug-stat {
  background: rgba(2, 6, 13, 0.6);
  border: 1px solid var(--debug-border);
  border-left: 3px solid var(--debug-accent);
  padding: 12px 16px;
}

.an-debug-stat__label {
  font-family: var(--an-font-display, 'Orbitron', sans-serif);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--debug-text-muted);
  margin-bottom: 4px;
}

.an-debug-stat__value {
  font-family: var(--an-font-mono, 'JetBrains Mono', monospace);
  font-size: 18px;
  font-weight: 600;
  color: var(--debug-accent);
}

/* ── Info Section ─────────────────────────────────────────────────────── */

.an-debug-info h4 {
  font-family: var(--an-font-display, 'Orbitron', sans-serif);
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--debug-accent);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--debug-border);
}

.an-debug-info__item {
  padding: 8px 0;
  color: var(--debug-text);
  line-height: 1.6;
}

.an-debug-info__item strong {
  color: var(--debug-text-muted);
  margin-right: 8px;
}

.an-debug-info__item code {
  background: rgba(2, 6, 13, 0.8);
  border: 1px solid var(--debug-border);
  padding: 2px 8px;
  border-radius: 3px;
  font-family: var(--an-font-mono, 'JetBrains Mono', monospace);
  font-size: 11px;
  color: var(--debug-accent);
}

/* ── Requests List ────────────────────────────────────────────────────── */

.an-debug-requests {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.an-debug-request {
  background: rgba(2, 6, 13, 0.6);
  border: 1px solid var(--debug-border);
  border-left: 3px solid var(--debug-success);
  transition: all 0.2s;
}

.an-debug-request.error {
  border-left-color: var(--debug-error);
}

.an-debug-request__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
}

.an-debug-request__header:hover {
  background: var(--debug-accent-soft);
}

.an-debug-request__toggle {
  background: transparent;
  border: none;
  color: var(--debug-text-muted);
  cursor: pointer;
  padding: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.an-debug-request.is-expanded .an-debug-request__toggle {
  transform: rotate(90deg);
}

.an-debug-request__method {
  font-family: var(--an-font-mono, 'JetBrains Mono', monospace);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--debug-accent-soft);
  color: var(--debug-accent);
  text-transform: uppercase;
}

.an-debug-request__url {
  flex: 1;
  font-family: var(--an-font-mono, 'JetBrains Mono', monospace);
  font-size: 12px;
  color: var(--debug-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.an-debug-request__duration {
  font-family: var(--an-font-mono, 'JetBrains Mono', monospace);
  font-size: 11px;
  color: var(--debug-text-muted);
}

.an-debug-request__sql-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(255, 179, 71, 0.15);
  color: var(--debug-warning);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

.an-debug-request__time {
  font-family: var(--an-font-mono, 'JetBrains Mono', monospace);
  font-size: 10px;
  color: var(--debug-text-muted);
}

.an-debug-request__body {
  display: none;
  padding: 16px;
  border-top: 1px solid var(--debug-border);
  background: rgba(2, 6, 13, 0.4);
}

.an-debug-request.is-expanded .an-debug-request__body {
  display: block;
}

.an-debug-request__section {
  margin-bottom: 16px;
}

.an-debug-request__section:last-child {
  margin-bottom: 0;
}

.an-debug-request__section strong {
  display: block;
  font-family: var(--an-font-display, 'Orbitron', sans-serif);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--debug-accent);
  margin-bottom: 8px;
}

.an-debug-request__section pre {
  background: rgba(2, 6, 13, 0.8);
  border: 1px solid var(--debug-border);
  padding: 12px;
  border-radius: 4px;
  font-family: var(--an-font-mono, 'JetBrains Mono', monospace);
  font-size: 11px;
  color: var(--debug-text);
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  max-height: 300px;
  overflow-y: auto;
}

/* ── SQL Queries ──────────────────────────────────────────────────────── */

.an-debug-sql-query {
  margin-bottom: 12px;
  background: rgba(2, 6, 13, 0.9);
  border: 1px solid var(--debug-border);
  border-radius: 4px;
  overflow: hidden;
}

.an-debug-sql-query:last-child {
  margin-bottom: 0;
}

.an-debug-sql-query__header {
  padding: 8px 12px;
  background: rgba(255, 179, 71, 0.1);
  border-bottom: 1px solid var(--debug-border);
  font-family: var(--an-font-display, 'Orbitron', sans-serif);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--debug-warning);
}

.an-debug-sql-query__header span {
  color: var(--debug-text-muted);
  margin-left: 8px;
}

.an-debug-sql-query pre {
  padding: 12px;
  margin: 0;
  background: rgba(2, 6, 13, 0.6);
  color: var(--debug-warning);
  font-family: var(--an-font-mono, 'JetBrains Mono', monospace);
  font-size: 11px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ── Empty State ──────────────────────────────────────────────────────── */

.an-debug-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--debug-text-muted);
  font-style: italic;
}

/* ── Performance Section ──────────────────────────────────────────────── */

.an-debug-performance {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Scrollbar ────────────────────────────────────────────────────────── */

.an-debug-toolbar__content::-webkit-scrollbar {
  width: 8px;
}

.an-debug-toolbar__content::-webkit-scrollbar-track {
  background: rgba(2, 6, 13, 0.6);
}

.an-debug-toolbar__content::-webkit-scrollbar-thumb {
  background: var(--debug-border);
  border-radius: 4px;
}

.an-debug-toolbar__content::-webkit-scrollbar-thumb:hover {
  background: var(--debug-accent);
}

.an-debug-request__section pre::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.an-debug-request__section pre::-webkit-scrollbar-track {
  background: rgba(2, 6, 13, 0.4);
}

.an-debug-request__section pre::-webkit-scrollbar-thumb {
  background: var(--debug-border);
  border-radius: 3px;
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .an-debug-toolbar.is-open .an-debug-toolbar__panel {
    height: 300px;
  }

  .an-debug-toolbar.is-open .an-debug-toolbar__toggle {
    bottom: 316px;
  }

  .an-debug-toolbar__content {
    height: calc(300px - 48px);
  }

  .an-debug-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .an-debug-request__url {
    max-width: 150px;
  }
}
