/* ==========================================================================
   Premium Glassmorphic Design System (nytlabeler stylesheet)
   ========================================================================== */

:root {
  /* OKLCH Color Palette for maximum vibrancy */
  --bg-space: oklch(12% 0.02 240);
  --bg-card: rgba(18, 20, 32, 0.45);
  --bg-card-hover: rgba(26, 29, 46, 0.6);
  --border-color: rgba(255, 255, 255, 0.07);
  --border-glow: rgba(138, 92, 246, 0.2);
  
  /* Neon Accents */
  --neon-purple: oklch(65% 0.25 290);
  --neon-pink: oklch(65% 0.26 340);
  --neon-blue: oklch(60% 0.22 230);
  --neon-green: oklch(75% 0.18 140);
  --neon-yellow: oklch(80% 0.17 90);
  --neon-red: oklch(62% 0.22 25);
  
  /* Text */
  --text-primary: oklch(95% 0.01 240);
  --text-secondary: oklch(75% 0.02 240);
  --text-muted: oklch(50% 0.02 240);
  
  /* Glassmorphism blurs */
  --blur-radius: 12px;
  
  /* Layout sizes */
  --sidebar-width: 260px;
  
  color-scheme: dark;
  accent-color: var(--neon-purple);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-space);
  background-image: 
    radial-gradient(at 10% 10%, rgba(99, 102, 241, 0.1) 0px, transparent 40%),
    radial-gradient(at 90% 90%, rgba(236, 72, 153, 0.1) 0px, transparent 40%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbars */
:root {
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

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

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background: rgba(10, 11, 18, 0.7);
  backdrop-filter: blur(var(--blur-radius));
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.logo-emoji {
  font-size: 2rem;
}

.logo-glow {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 50px;
  height: 50px;
  background: var(--neon-purple);
  filter: blur(25px);
  opacity: 0.4;
  z-index: -1;
}

.brand-text h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.env-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-pink));
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  transform: translateX(4px);
}

.nav-item.active {
  background: rgba(138, 92, 246, 0.15);
  color: var(--neon-purple);
  box-shadow: inset 0 0 10px rgba(138, 92, 246, 0.05);
  border: 1px solid rgba(138, 92, 246, 0.2);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.connection-status {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.pulsing {
  box-shadow: 0 0 8px currentColor;
  animation: pulse 1.5s infinite;
}

.status-dot.red { background-color: var(--neon-red); color: var(--neon-red); }
.status-dot.yellow { background-color: var(--neon-yellow); color: var(--neon-yellow); }
.status-dot.green { background-color: var(--neon-green); color: var(--neon-green); }

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.5; }
}

.uptime-display {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  margin-left: var(--sidebar-width);
  padding: 40px;
  max-width: calc(100% - var(--sidebar-width));
}

/* Dry Run Warning Banner */
.dry-run-banner {
  background: linear-gradient(90deg, rgba(234, 179, 8, 0.15) 0%, rgba(234, 179, 8, 0.03) 100%);
  border: 1px solid rgba(234, 179, 8, 0.3);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 24px;
  color: oklch(85% 0.14 90);
  font-size: 0.9rem;
  backdrop-filter: blur(10px);
  animation: slideInDown 0.5s ease-out;
}

.hidden {
  display: none !important;
}

/* Headers */
.tab-header {
  margin-bottom: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tab-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.tab-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 4px;
}

/* Glassmorphism Containers */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(var(--blur-radius));
  -webkit-backdrop-filter: blur(var(--blur-radius));
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s ease;
}

.glass:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(var(--blur-radius));
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
  transform: translateY(-4px);
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
  box-shadow: 0 10px 25px -10px rgba(138, 92, 246, 0.15);
}

.card-glow {
  position: absolute;
  width: 100px;
  height: 100px;
  background: var(--neon-purple);
  filter: blur(50px);
  opacity: 0;
  bottom: -50px;
  right: -50px;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

.stat-card:hover .card-glow {
  opacity: 0.25;
}

.stat-icon {
  font-size: 1.75rem;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
}

.stat-icon.purple { background-color: rgba(138, 92, 246, 0.1); color: var(--neon-purple); }
.stat-icon.pink { background-color: rgba(236, 72, 153, 0.1); color: var(--neon-pink); }
.stat-icon.blue { background-color: rgba(59, 130, 246, 0.1); color: var(--neon-blue); }
.stat-icon.green { background-color: rgba(16, 185, 129, 0.1); color: var(--neon-green); }

.stat-info h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.85rem;
  font-weight: 700;
  margin-top: 4px;
}

.stat-value .unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Layout Rows */
.dashboard-row {
  margin-bottom: 32px;
}

.diagnostics-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

@media (max-width: 1024px) {
  .diagnostics-row {
    grid-template-columns: 1fr;
  }
}

.diagnostics-panel {
  display: flex;
  flex-direction: column;
}

.diagnostics-panel h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-secondary);
}

.diag-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-grow: 1;
  justify-content: center;
}

.diag-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.diag-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.diag-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.diag-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.diag-value.code-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diag-value.online {
  color: var(--neon-green);
}

.diag-value.connecting {
  color: var(--neon-yellow);
}

.diag-value.offline {
  color: var(--neon-red);
}

.chart-container h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-secondary);
}

/* Terminal logs panel */
.terminal-container {
  display: flex;
  flex-direction: column;
  height: 380px;
  padding: 0 !important;
}

.terminal-header {
  background: rgba(10, 11, 18, 0.8);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 16px 16px 0 0;
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.terminal-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.terminal-dots .dot.red { background: var(--neon-red); }
.terminal-dots .dot.yellow { background: var(--neon-yellow); }
.terminal-dots .dot.green { background: var(--neon-green); }

.terminal-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 1px;
}

.terminal-clear {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.terminal-clear:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.terminal-body {
  flex-grow: 1;
  background: rgba(5, 5, 8, 0.6);
  padding: 24px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  color: oklch(85% 0.01 240);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.terminal-line.system {
  color: var(--text-muted);
}

.terminal-line.match {
  color: var(--neon-pink);
  border-left: 2px solid var(--neon-pink);
  padding-left: 8px;
}

.terminal-line.pulse {
  color: var(--text-muted);
  opacity: 0.7;
}

/* Tab Management */
.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Universe layout */
.universe-sections {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.card-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 4px;
}

.label-count {
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 10px;
  border-radius: 20px;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

/* Grid of active authors */
.authors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.author-badge {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.3s ease;
}

.author-badge:hover {
  background: rgba(138, 92, 246, 0.05);
  border-color: rgba(138, 92, 246, 0.2);
}

.author-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.author-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.author-token {
  font-family: 'JetBrains Mono', monospace;
  color: var(--neon-purple);
}

/* Dual categories grid list */
.category-grids {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.categories-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 8px;
}

.tag-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

/* History tab and tables */
.history-controls {
  display: flex;
  align-items: center;
}

.search-input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  width: 280px;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--neon-purple);
  box-shadow: 0 0 10px rgba(138, 92, 246, 0.15);
}

.history-table-container {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.history-table th {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.history-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
  line-height: 1.5;
}

.history-table tr:hover {
  background: rgba(255, 255, 255, 0.01);
}

.history-time {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  white-space: nowrap;
}

.article-title-cell {
  font-weight: 600;
  font-size: 0.9rem;
  max-width: 250px;
}

.post-text-cell {
  max-width: 320px;
  color: var(--text-secondary);
}

.emitted-tags-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 200px;
}

.tag-emitted {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(138, 92, 246, 0.1);
  border: 1px solid rgba(138, 92, 246, 0.2);
  color: var(--neon-purple);
}

.tag-emitted.sub {
  background: rgba(236, 72, 153, 0.1);
  border-color: rgba(236, 72, 153, 0.2);
  color: var(--neon-pink);
}

.tag-emitted.author {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.2);
  color: var(--neon-blue);
}

.action-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: var(--neon-purple);
  color: white;
  border-color: var(--neon-purple);
  box-shadow: 0 0 10px rgba(138, 92, 246, 0.3);
}

.empty-state {
  text-align: center;
  padding: 40px !important;
  color: var(--text-muted);
}

/* Settings tab form styling */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.settings-card h3 {
  margin-bottom: 20px;
  color: var(--text-secondary);
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.glass-input {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  padding: 12px;
  font-size: 0.9rem;
  outline: none;
  font-family: 'JetBrains Mono', monospace;
}

.glass-input[readonly] {
  opacity: 0.6;
  cursor: not-allowed;
}

.db-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--neon-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  align-self: flex-start;
}

/* Animations */
@keyframes slideInDown {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Custom CSS Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s;
  border-radius: 24px;
  border: 1px solid var(--border-color);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: rgba(138, 92, 246, 0.25);
  border-color: rgba(138, 92, 246, 0.5);
}

input:checked + .slider:before {
  transform: translateX(20px);
  background-color: var(--neon-purple);
  box-shadow: 0 0 8px var(--neon-purple);
}

input:disabled + .slider {
  opacity: 0.5;
  cursor: not-allowed;
}
