/* ==========================================
   Stake Claimer Dashboard - Dark Theme
   ========================================== */

:root {
  --bg-primary: #0b0e14;
  --bg-secondary: #111520;
  --bg-card: #161b28;
  --bg-sidebar: #0d1018;
  --bg-input: #1a2030;
  --bg-hover: #1e2538;
  --text-primary: #e2e6f0;
  --text-secondary: #7a8299;
  --text-muted: #4a5068;
  --accent: #6c5ce7;
  --accent-hover: #7e70f0;
  --accent-glow: rgba(108, 92, 231, 0.15);
  --success: #00d68f;
  --success-bg: rgba(0, 214, 143, 0.1);
  --danger: #ff4757;
  --danger-bg: rgba(255, 71, 87, 0.1);
  --warning: #ffa726;
  --warning-bg: rgba(255, 167, 38, 0.1);
  --info: #54a0ff;
  --info-bg: rgba(84, 160, 255, 0.1);
  --border: #1e2538;
  --border-light: #2a3248;
  --sidebar-width: 240px;
  --header-height: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.mono { font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace; }
.text-sm { font-size: 12px; }
.mt-20 { margin-top: 20px; }

/* ==========================================
   Login Page
   ========================================== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0b0e14 0%, #161b28 50%, #0d1018 100%);
}

.login-container { width: 100%; max-width: 400px; padding: 20px; }

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow), 0 0 60px rgba(108, 92, 231, 0.05);
}

.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-icon { font-size: 48px; margin-bottom: 8px; }
.login-logo h1 { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.login-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text-secondary); font-size: 13px; }

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

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

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo .logo-icon { font-size: 24px; }
.sidebar-logo .logo-text { font-size: 16px; font-weight: 700; color: var(--text-primary); }

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
}

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}

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

.nav-item.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}

.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.sidebar-version { font-size: 11px; color: var(--text-muted); }

/* ==========================================
   Content Area
   ========================================== */
.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-content { padding: 24px; flex: 1; }

/* ==========================================
   Top Header
   ========================================== */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.page-title { font-size: 18px; font-weight: 600; }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text-secondary); border-radius: 2px; }

.status-indicator { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition);
}
.dot-green { background: var(--success); box-shadow: 0 0 8px var(--success); }
.dot-red { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.dot-yellow { background: var(--warning); box-shadow: 0 0 8px var(--warning); }

.status-text { color: var(--text-secondary); }

.header-user { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--text-secondary); font-size: 13px; }

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}

.card-header h3 { font-size: 15px; font-weight: 600; }
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 20px; }

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color var(--transition);
}

.stat-card:hover { border-color: var(--border-light); }
.stat-card.stat-success { border-left: 3px solid var(--success); }
.stat-card.stat-danger { border-left: 3px solid var(--danger); }
.stat-card.stat-warning { border-left: 3px solid var(--warning); }

.stat-icon { font-size: 28px; }
.stat-value { font-size: 20px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.stat-detail { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ==========================================
   Dashboard Grid
   ========================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
}

/* ==========================================
   Tables
   ========================================== */
.table-responsive { overflow-x: auto; }

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

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

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

.row-success td:first-child { box-shadow: inset 3px 0 0 var(--success); }
.row-danger td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.row-muted { opacity: 0.5; }

.info-table { width: 100%; border-collapse: collapse; }
.info-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.info-table td:first-child { color: var(--text-secondary); width: 180px; font-weight: 500; }

.actions-cell { display: flex; gap: 6px; align-items: center; }

/* ==========================================
   Badges
   ========================================== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }

.badge-btn {
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: opacity var(--transition);
}
.badge-btn:hover { opacity: 0.8; }

/* ==========================================
   Buttons
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3); }

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #00c080; box-shadow: 0 4px 12px rgba(0, 214, 143, 0.3); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #ff3040; box-shadow: 0 4px 12px rgba(255, 71, 87, 0.3); }

.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { background: #ffb840; box-shadow: 0 4px 12px rgba(255, 167, 38, 0.3); }

.btn-block { width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ==========================================
   Forms
   ========================================== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text-secondary); }

.form-control {
  width: 100%;
  padding: 9px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--transition);
}

.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-muted); }
.form-control-sm { padding: 5px 10px; font-size: 12px; }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 60px; }

.form-hint { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

.password-wrapper { position: relative; display: flex; }
.password-wrapper .form-control { padding-right: 40px; }

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  opacity: 0.6;
}
.password-toggle:hover { opacity: 1; }

.inline-form { display: inline; }

/* ==========================================
   Toggle Switch
   ========================================== */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input { display: none; }

.toggle-slider {
  width: 44px;
  height: 24px;
  background: var(--border-light);
  border-radius: 12px;
  position: relative;
  transition: background var(--transition);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: all var(--transition);
}

.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::after { left: 23px; background: #fff; }
.toggle-label { font-size: 13px; color: var(--text-secondary); }

/* ==========================================
   Settings
   ========================================== */
.settings-section { margin-bottom: 28px; }
.section-title { font-size: 14px; font-weight: 600; color: var(--accent); margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* ==========================================
   Alerts
   ========================================== */
.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin: 0 24px 0;
  animation: slideDown 0.3s ease;
}

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

.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(0, 214, 143, 0.2); }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(255, 71, 87, 0.2); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(255, 167, 38, 0.2); }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid rgba(84, 160, 255, 0.2); }

.alert-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 20px;
  cursor: pointer;
  opacity: 0.7;
  padding: 0 4px;
}
.alert-close:hover { opacity: 1; }

/* ==========================================
   Modals
   ========================================== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-backdrop {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease;
}

.modal-sm { max-width: 380px; padding: 24px; }

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

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

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ==========================================
   Service Control
   ========================================== */
.service-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

/* ==========================================
   Log Viewer
   ========================================== */
.logs-card { display: flex; flex-direction: column; height: calc(100vh - var(--header-height) - 72px); }
.logs-card .card-body { flex: 1; overflow: hidden; padding: 0; }

.log-body { display: flex; flex-direction: column; height: 100%; }

.log-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.7;
  background: #080a0f;
}

.log-line { padding: 1px 0; white-space: pre-wrap; word-break: break-all; }
.log-success { color: var(--success); }
.log-error { color: var(--danger); }
.log-warn { color: var(--warning); }
.log-info { color: var(--text-secondary); }

.log-empty { color: var(--text-muted); text-align: center; padding: 40px 0; }
.log-count { font-size: 12px; color: var(--text-muted); padding: 0 4px; }

/* ==========================================
   Quick Actions
   ========================================== */
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ==========================================
   Empty State
   ========================================== */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); font-size: 13px; margin-bottom: 16px; }

/* ==========================================
   Toasts
   ========================================== */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slideInRight 0.3s ease;
  max-width: 360px;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }

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

/* ==========================================
   Token Masked
   ========================================== */
.token-masked {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================
   Scrollbar
   ========================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==========================================
   Responsive
   ========================================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close { display: block; }
  .hamburger { display: flex; }

  .content { margin-left: 0; }

  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }

  .card-header { flex-direction: column; align-items: flex-start; }
  .card-actions { width: 100%; }

  .top-header { padding: 0 16px; }
  .page-content { padding: 16px; }

  .alert { margin: 0 16px; }

  .data-table th, .data-table td { padding: 8px 10px; }
}

@media (max-width: 480px) {
  .login-card { padding: 24px; }
  .stats-grid { grid-template-columns: 1fr; }
  .service-actions { flex-direction: column; }
  .service-actions .btn { width: 100%; }
}
