/* ===================================
   AI Agent Usage Auditor - Styles
   Dark Terminal Aesthetic
=================================== */

:root {
  --bg: #0B0F14;
  --bg-surface: #131A24;
  --bg-border: #1E2A3A;
  --primary: #00D4FF;
  --success: #00FF88;
  --warning: #FFB800;
  --danger: #FF3366;
  --text: #E8F0FF;
  --text-muted: #6B8096;
  --purple: #A855F7;
}

/* Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

.font-mono { font-family: 'JetBrains Mono', monospace; }
.font-heading { font-family: 'Space Grotesk', system-ui, sans-serif; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Selection */
::selection { background-color: rgba(0, 212, 255, 0.3); }

/* App Layout */
.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--bg-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--bg-border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 2rem;
  height: 2rem;
  background: rgba(0, 212, 255, 0.2);
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.logo-title {
  font-size: 0.875rem;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
}

.logo-subtitle {
  font-size: 0.625rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: rgba(30, 42, 58, 0.5);
  color: var(--text);
}

.nav-item.active {
  background: rgba(0, 212, 255, 0.1);
  color: var(--primary);
  border-left: 2px solid var(--primary);
  font-weight: 500;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--bg-border);
}

.demo-badge {
  font-size: 0.625rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
}

/* Main Area */
.main-area {
  flex: 1;
  margin-left: 240px;
  min-height: 100vh;
}

/* Top Bar */
.topbar {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-left h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.125rem;
  font-weight: 600;
}

.topbar-divider {
  color: var(--text-muted);
  font-size: 0.875rem;
}

#current-date {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bg);
}

/* Buttons */
.btn-primary {
  background-color: var(--primary);
  color: var(--bg);
  font-weight: 500;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background-color 0.15s ease;
}

.btn-primary:hover {
  background-color: rgba(0, 212, 255, 0.9);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  transition: color 0.15s ease;
}

.btn-ghost:hover {
  color: var(--text);
}

/* Dashboard Content */
.dashboard-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* KPI Strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.kpi-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: 0.5rem;
  padding: 1rem;
  position: relative;
  overflow: hidden;
  transition: all 0.15s ease;
}

.kpi-card:hover {
  border-color: rgba(0, 212, 255, 0.3);
}

.kpi-card:hover .sparkline {
  opacity: 1;
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.kpi-icon {
  font-size: 1rem;
}

.kpi-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

.kpi-delta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 0.25rem;
}

.kpi-delta.positive { color: var(--danger); }
.kpi-delta.negative { color: var(--success); }

.sparkline {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  width: 60px;
  height: 24px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

/* Sections */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-header h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.125rem;
  font-weight: 600;
}

/* Chart Section */
.chart-section {
  background-color: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: 0.5rem;
  padding: 1rem;
}

.chart-container {
  height: 220px;
  position: relative;
}

.range-toggle {
  display: flex;
  gap: 0.25rem;
}

.range-btn {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  border-radius: 0.25rem;
  border: none;
  background: rgba(30, 42, 58, 0.5);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.range-btn:hover {
  background: var(--bg-border);
}

.range-btn.active {
  background: var(--primary);
  color: var(--bg);
}

/* Active Agents Section */
.active-agents-section {
  background-color: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: 0.5rem;
  padding: 1rem;
}

.active-count {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.live-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: var(--success);
  animation: pulse 2s infinite;
}

.count-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
}

.agent-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.agent-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  border-radius: 0.375rem;
  background: var(--bg);
  transition: background 0.15s ease;
}

.agent-list-item:hover {
  background: rgba(30, 42, 58, 0.3);
}

.agent-list-item .agent-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.agent-list-item .status-dot {
  flex-shrink: 0;
}

.agent-list-item .agent-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-list-item .agent-rate {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Agent Table Section */
.agent-table-section {
  background-color: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.table-toolbar {
  padding: 1rem;
  border-bottom: 1px solid var(--bg-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.toolbar-left {
  display: flex;
  gap: 0.75rem;
  flex: 1;
}

.search-input, .filter-select {
  background: var(--bg);
  border: 1px solid var(--bg-border);
  border-radius: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input {
  max-width: 240px;
  width: 100%;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus, .filter-select:focus {
  border-color: rgba(0, 212, 255, 0.5);
}

.filter-select option {
  background: var(--bg);
}

.agent-count {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.table-wrapper {
  overflow-x: auto;
}

.agent-table {
  width: 100%;
  border-collapse: collapse;
}

.agent-table th {
  text-align: left;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1rem;
  border-bottom: 1px solid var(--bg-border);
  font-weight: 500;
}

.agent-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
}

.agent-table th.sortable:hover {
  color: var(--text);
}

.agent-table th.text-right {
  text-align: right;
}

.agent-table th.text-center {
  text-align: center;
}

.sort-icon {
  margin-left: 0.25rem;
  opacity: 0.5;
}

.sort-icon::after {
  content: '↕';
}

.agent-table td {
  padding: 1rem;
  border-bottom: 1px solid rgba(30, 42, 58, 0.5);
  font-size: 0.875rem;
}

.agent-table td.text-right {
  text-align: right;
}

.agent-table td.text-center {
  text-align: center;
}

.agent-table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.agent-table tbody tr:hover {
  background: rgba(30, 42, 58, 0.2);
}

.agent-table tbody tr.expanded {
  background: rgba(30, 42, 58, 0.2);
}

.agent-name-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.agent-name-cell .agent-name {
  font-family: 'JetBrains Mono', monospace;
}

.provider-badge {
  font-size: 0.75rem;
  padding: 1px 8px;
  border-radius: 0.25rem;
  text-transform: capitalize;
}

.provider-badge.anthropic {
  background: rgba(6, 182, 212, 0.2);
  color: #06b6d4;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.provider-badge.openai {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.provider-badge.google {
  background: rgba(168, 85, 247, 0.2);
  color: #a855f7;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

/* Action buttons in table */
.action-buttons {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
}

.action-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn.audit {
  background: rgba(0, 212, 255, 0.1);
  color: var(--primary);
}

.action-btn.audit:hover {
  background: rgba(0, 212, 255, 0.2);
}

.action-btn.alert {
  background: rgba(30, 42, 58, 0.5);
  color: var(--text-muted);
}

.action-btn.alert:hover {
  background: var(--bg-border);
}

/* Row details expansion */
.row-details {
  background: var(--bg);
  padding: 0.75rem;
  border: 1px solid var(--bg-border);
  border-radius: 0.375rem;
  margin: 0.5rem 1rem;
}

.row-details-header {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.row-details table {
  width: 100%;
  font-size: 0.875rem;
}

.row-details th {
  text-align: left;
  padding: 0.25rem 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.row-details td {
  padding: 0.25rem 0;
  border-top: 1px solid rgba(30, 42, 58, 0.3);
}

.row-details td.text-right {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

/* Bottom Row */
.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* Alerts Section */
.alerts-section {
  background-color: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: 0.5rem;
  padding: 1rem;
  max-height: 340px;
  display: flex;
  flex-direction: column;
}

.alerts-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}

.alert-item {
  border: 1px solid var(--bg-border);
  border-radius: 0.375rem;
  padding: 0.75rem;
  transition: border-color 0.15s ease;
}

.alert-item:hover {
  border-color: rgba(0, 212, 255, 0.3);
}

.alert-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.alert-badge {
  font-size: 0.625rem;
  padding: 2px 6px;
  border-radius: 0.25rem;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid;
}

.alert-badge.over-budget {
  background: rgba(255, 184, 0, 0.2);
  color: var(--warning);
  border-color: rgba(255, 184, 0, 0.3);
}

.alert-badge.spike-detected {
  background: rgba(255, 51, 102, 0.2);
  color: var(--danger);
  border-color: rgba(255, 51, 102, 0.3);
}

.alert-badge.unusual-pattern {
  background: rgba(168, 85, 247, 0.2);
  color: var(--purple);
  border-color: rgba(168, 85, 247, 0.3);
}

.alert-badge.token-threshold {
  background: rgba(0, 212, 255, 0.2);
  color: var(--primary);
  border-color: rgba(0, 212, 255, 0.3);
}

.alert-timestamp {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.alert-agent {
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alert-message {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.alert-dismiss {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.75rem;
  border-radius: 0.25rem;
  transition: all 0.15s ease;
}

.alert-dismiss:hover {
  color: var(--text);
  background: var(--bg-border);
}

.alert-item {
  position: relative;
}

/* Activity Section */
.activity-section {
  background-color: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: 0.5rem;
  padding: 1rem;
  max-height: 340px;
  display: flex;
  flex-direction: column;
}

.activity-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: background 0.15s ease;
}

.activity-item:hover {
  background: rgba(30, 42, 58, 0.2);
}

.activity-icon {
  font-size: 1rem;
}

.activity-info {
  flex: 1;
  min-width: 0;
}

.activity-type {
  font-size: 0.75rem;
  font-weight: 500;
}

.activity-type.audit { color: #06b6d4; }
.activity-type.report { color: var(--success); }
.activity-type.alert { color: var(--warning); }
.activity-type.threshold { color: var(--purple); }

.activity-details {
  font-size: 0.875rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 28rem;
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.visible .modal {
  transform: scale(1);
}

.modal-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.modal-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.form-group input,
.form-group select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--bg-border);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-group input:focus,
.form-group select:focus {
  border-color: rgba(0, 212, 255, 0.5);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

.form-actions .btn-ghost {
  color: var(--text-muted);
}


.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }

/* Toast */
.toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: 0.375rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 2000;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.warning { border-color: var(--warning); color: var(--warning); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.info { border-color: var(--primary); color: var(--primary); }

/* Animate in utilities */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

.animate-fade { animation: fadeIn 0.2s ease forwards; }
.animate-slide-right { animation: slideInRight 0.2s ease forwards; }
.animate-slide-bottom { animation: slideInBottom 0.2s ease forwards; }

/* Status dot colors */
.status-dot.normal { background: var(--success); }
.status-dot.warning { background: var(--warning); }
.status-dot.critical { background: var(--danger); animation: pulse 1s infinite; }

/* Responsive */
@media (max-width: 1024px) {
  .kpi-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .main-grid {
    grid-template-columns: 1fr;
  }

  .bottom-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main-area {
    margin-left: 0;
  }

  .kpi-strip {
    grid-template-columns: 1fr;
  }
}

/* Text utility classes */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-4xl { font-size: 2.25rem; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.uppercase { text-transform: uppercase; }
.tracking-wider { letter-spacing: 0.05em; }

/* Margin utilities */
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-0\.5 { margin-top: 0.125rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }

/* Flex utilities */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }

/* Animation pulse for danger */
.animate-pulse {
  animation: pulse 1s infinite;
}
