/* CSS Variables */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a25;
  --bg-card: #15151f;
  --bg-hover: #1f1f2e;
  
  --text-primary: #f0f0f5;
  --text-secondary: #9090a0;
  --text-muted: #606070;
  
  --accent-bitcoin: #f7931a;
  --accent-bitcoin-dark: #c77815;
  --accent-ord: #8b5cf6;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-error: #ef4444;
  --accent-blue: #3b82f6;
  
  --border-color: #2a2a3a;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  --transition: all 0.2s ease;
}

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

html {
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Backgrounds */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(247, 147, 26, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-primary) 0%, #0d0d14 100%);
  pointer-events: none;
  z-index: -1;
}

/* Screen Management */
.screen { display: none !important; }
.screen.active { display: flex !important; }
.hidden { display: none !important; }

#login-screen.active + #dashboard-screen { display: none !important; }
#dashboard-screen.active { display: flex !important; }
#login-screen:not(.active) { display: none !important; }

/* Login Screen */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-container {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.logo {
  margin-bottom: 1rem;
  animation: pulse 2s ease-in-out infinite;
}

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

.login-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent-bitcoin);
  box-shadow: 0 0 0 3px rgba(247, 147, 26, 0.15);
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-bitcoin) 0%, var(--accent-bitcoin-dark) 100%);
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(247, 147, 26, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

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

.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.btn-danger {
  background: var(--accent-error);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.error-message {
  color: var(--accent-error);
  font-size: 0.875rem;
  margin-top: 1rem;
  text-align: center;
}

/* Dashboard Layout */
#dashboard-screen {
  display: flex;
  min-height: 100vh;
}

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

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 1.1rem;
}

.nav-menu {
  list-style: none;
  padding: 1rem 0;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.875rem 1.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-link.active {
  background: rgba(247, 147, 26, 0.1);
  color: var(--accent-bitcoin);
  border-left-color: var(--accent-bitcoin);
}

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

.sidebar-footer .btn {
  width: 100%;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 2rem;
  max-width: calc(100vw - 240px);
}

.section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.section.active {
  display: block;
}

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

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

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

.section-header .section-title {
  margin-bottom: 0;
}

/* Status Grid */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover {
  border-color: rgba(247, 147, 26, 0.3);
  box-shadow: var(--shadow-md);
}

.card-bitcoin { border-top: 3px solid var(--accent-bitcoin); }
.card-ord { border-top: 3px solid var(--accent-ord); }
.card-indexes { border-top: 3px solid #ec4899; }
.card-system { border-top: 3px solid var(--accent-success); }
.card-api { border-top: 3px solid var(--accent-blue); }

/* Index rows */
.index-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.index-row:last-of-type {
  border-bottom: none;
}

.index-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.index-name {
  font-weight: 500;
  color: var(--text-primary);
}

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

.index-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.index-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.index-badge.enabled {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-success);
}

.index-badge.disabled {
  background: rgba(96, 96, 112, 0.2);
  color: var(--text-muted);
}

.index-size {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.index-size.current {
  color: var(--accent-bitcoin);
}

.index-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0.75rem 0;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-body {
  padding: 1.25rem;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 0.5rem;
  background: currentColor;
}

.status-online {
  color: var(--accent-success);
  background: rgba(16, 185, 129, 0.1);
}

.status-syncing {
  color: var(--accent-bitcoin);
  background: rgba(247, 147, 26, 0.1);
}

.status-offline {
  color: var(--accent-error);
  background: rgba(239, 68, 68, 0.1);
}

/* Stats */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.stat-value {
  font-weight: 500;
}

.stat-value.mono {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

/* Progress Bars */
.progress-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  margin: 0.5rem 0 1rem 0;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
  background: linear-gradient(90deg, var(--accent-bitcoin) 0%, var(--accent-bitcoin-dark) 100%);
}

.progress-cpu { background: linear-gradient(90deg, var(--accent-blue) 0%, #2563eb 100%); }
.progress-mem { background: linear-gradient(90deg, var(--accent-ord) 0%, #7c3aed 100%); }
.progress-disk { background: linear-gradient(90deg, var(--accent-success) 0%, #059669 100%); }

/* Tables */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
}

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

.data-table th,
.data-table td {
  padding: 1rem 1.25rem;
  text-align: left;
}

.data-table th {
  background: var(--bg-tertiary);
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--bg-hover);
}

.data-table .loading {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

.key-cell {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.tier-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
}

.tier-admin { background: rgba(239, 68, 68, 0.2); color: var(--accent-error); }
.tier-pro { background: rgba(139, 92, 246, 0.2); color: var(--accent-ord); }
.tier-basic { background: rgba(59, 130, 246, 0.2); color: var(--accent-blue); }

.actions-cell {
  display: flex;
  gap: 0.5rem;
}

/* Stats Overview */
.stats-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  text-align: center;
}

.stat-card-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-bitcoin);
  margin-bottom: 0.25rem;
}

.stat-card-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Settings */
.settings-form {
  max-width: 400px;
}

.form-message {
  margin-top: 1rem;
  font-size: 0.875rem;
}

.form-message.success {
  color: var(--accent-success);
}

.form-message.error {
  color: var(--accent-error);
}

.code-block {
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  padding: 1rem;
  margin-top: 1rem;
  overflow-x: auto;
}

.code-block pre {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 450px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-content form,
.modal-body {
  padding: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
}

.modal-actions .btn {
  width: auto;
}

.warning-text {
  color: var(--accent-warning);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.key-display {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  padding: 1rem;
}

.key-display code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  word-break: break-all;
  color: var(--accent-success);
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .main-content {
    margin-left: 0;
    max-width: 100vw;
  }
  
  .status-grid {
    grid-template-columns: 1fr;
  }
  
  .data-table {
    font-size: 0.8rem;
  }
  
  .data-table th,
  .data-table td {
    padding: 0.75rem;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

