/* JARVIS Status & Settings Dashboard v1.1 — Dark Theme */

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-card: #1c2128;
  --border: #30363d;
  --border-active: #58a6ff;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --purple: #bc8cff;
  --sidebar-width: 260px;
  --header-height: 60px;
  --radius: 8px;
  --radius-sm: 4px;
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.sidebar-header .subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Pulse Dot — auto-refresh indicator */
.pulse-dot {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  opacity: 0.6;
  transition: opacity 0.3s;
}

.pulse-dot.pulsing {
  animation: pulse-ring 1s ease-out;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.5); opacity: 1; }
  100% { box-shadow: 0 0 0 12px rgba(63, 185, 80, 0); opacity: 0.6; }
}

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

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 12px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  user-select: none;
}

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

.nav-item.active {
  background: rgba(88, 166, 255, 0.08);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

.nav-item .nav-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.nav-item.active .nav-badge {
  background: rgba(88, 166, 255, 0.15);
  color: var(--accent);
}

.nav-item .live-badge {
  background: rgba(63, 185, 80, 0.15);
  color: var(--success);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-header {
  height: var(--header-height);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.main-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Connection Badge */
.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  letter-spacing: 0.5px;
}

.connection-badge.online {
  background: rgba(63, 185, 80, 0.12);
  color: var(--success);
}

.connection-badge.offline {
  background: rgba(248, 81, 73, 0.12);
  color: var(--danger);
}

.main-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

.main-body::-webkit-scrollbar {
  width: 6px;
}

.main-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ===== SYSTEM CLOCK BAR ===== */
.system-clock-bar {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.clock-time {
  font-size: 28px;
  font-weight: 700;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  color: var(--accent);
  letter-spacing: 1px;
}

.clock-date {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 500;
}

.clock-tz {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

/* ===== STATUS HERO (Landing Page) ===== */
.status-hero {
  max-width: 1200px;
}

.hero-section {
  margin-bottom: 24px;
}

.hero-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-left: 2px;
}

/* ===== SERVICE HEALTH GRID ===== */
.service-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.service-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}

.service-chip.up {
  border-color: rgba(63, 185, 80, 0.3);
}

.service-chip.degraded {
  border-color: rgba(210, 153, 34, 0.3);
}

.service-chip.down {
  border-color: rgba(248, 81, 73, 0.3);
  background: rgba(248, 81, 73, 0.06);
}

.service-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.service-chip.up .service-dot { background: var(--success); }
.service-chip.degraded .service-dot { background: var(--warning); }
.service-chip.down .service-dot { background: var(--danger); }

.service-name {
  color: var(--text-primary);
}

.service-error {
  font-size: 10px;
  color: var(--danger);
  opacity: 0.8;
}

/* ===== CONTEXT BAR ===== */
.context-bar {
  height: 4px;
  background: var(--bg-primary);
  border-radius: 2px;
  margin: 6px 0 4px;
  overflow: hidden;
}

.context-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ===== OAUTH BARS ===== */
.oauth-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 4px 0 2px;
}

.oauth-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.oauth-status {
  color: var(--text-muted);
  font-family: 'SF Mono', monospace;
  font-size: 11px;
}

.oauth-bar {
  height: 3px;
  background: var(--bg-primary);
  border-radius: 2px;
  margin-bottom: 8px;
  overflow: hidden;
}

.oauth-fill {
  height: 100%;
  background: var(--success);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.oauth-fill.expired {
  background: var(--danger);
}

/* ===== TODOIST STATS ===== */
.todoist-stats {
  display: flex;
  gap: 12px;
  padding: 8px 0;
}

.stat-block {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.stat-block .stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'SF Mono', monospace;
}

.stat-block .stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.stat-block.overdue .stat-value {
  color: var(--danger);
}

.stat-block.completed .stat-value {
  color: var(--success);
}

.todoist-tasks {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.task-row {
  font-size: 12px;
  padding: 4px 0;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(48, 54, 61, 0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-row:last-child {
  border-bottom: none;
}

/* ===== ACTIVITY LOG ===== */
.activity-log {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 0;
  max-height: 280px;
  overflow-y: auto;
}

.activity-entry {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 14px;
  font-size: 12px;
  border-bottom: 1px solid rgba(48, 54, 61, 0.3);
  transition: background var(--transition);
}

.activity-entry:last-child {
  border-bottom: none;
}

.activity-entry:hover {
  background: var(--bg-tertiary);
}

.activity-entry.hive {
  border-left: 2px solid var(--purple);
}

.activity-time {
  color: var(--text-muted);
  font-family: 'SF Mono', monospace;
  font-size: 10px;
  flex-shrink: 0;
  min-width: 70px;
}

.activity-from {
  color: var(--accent);
  font-weight: 600;
  font-size: 11px;
  flex-shrink: 0;
  min-width: 60px;
}

.activity-msg {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== REFRESH NOTE ===== */
.refresh-note {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 16px;
  padding: 8px;
}

/* ===== STATUS GRID ===== */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.status-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* ===== STATUS CARDS ===== */
.status-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.status-card.stale {
  border-color: rgba(210, 153, 34, 0.4);
}

.status-card.down-card {
  border-color: rgba(248, 81, 73, 0.4);
  background: rgba(248, 81, 73, 0.04);
}

.status-card .status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.status-card .status-title {
  font-size: 14px;
  font-weight: 600;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
}

.status-indicator.up {
  background: rgba(63, 185, 80, 0.12);
  color: var(--success);
}

.status-indicator.down {
  background: rgba(248, 81, 73, 0.12);
  color: var(--danger);
}

.status-indicator.unknown {
  background: rgba(210, 153, 34, 0.12);
  color: var(--warning);
}

.status-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-detail {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}

.status-detail:last-child {
  border-bottom: none;
}

.status-detail .label {
  color: var(--text-muted);
}

.status-detail .value {
  color: var(--text-primary);
  font-family: 'SF Mono', monospace;
  font-size: 12px;
}

/* ===== UTILITY CLASSES ===== */
.text-danger {
  color: var(--danger) !important;
}

.task-text {
  font-size: 11px;
  color: var(--text-secondary);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.btn-success:hover {
  opacity: 0.9;
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

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

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

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

.card-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.card-body {
  padding: 18px;
}

/* ===== SETTINGS GRID ===== */
.settings-grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr 300px;
  background: var(--bg-card);
  min-height: 52px;
  transition: background var(--transition);
}

.setting-row:hover {
  background: var(--bg-tertiary);
}

.setting-info {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.setting-key {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
}

.setting-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.setting-meta {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.setting-meta .tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.setting-meta .tag.type-boolean { color: var(--success); border-color: rgba(63,185,80,0.3); }
.setting-meta .tag.type-number { color: var(--accent); border-color: rgba(88,166,255,0.3); }
.setting-meta .tag.type-string { color: var(--purple); border-color: rgba(188,140,255,0.3); }
.setting-meta .tag.type-json { color: var(--warning); border-color: rgba(210,153,34,0.3); }

.setting-control {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== FORM CONTROLS ===== */
input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--transition);
  width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

textarea {
  resize: vertical;
  min-height: 60px;
}

/* Toggle Switch */
.toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 11px;
  transition: all var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  top: 2px;
  left: 2px;
  transition: all var(--transition);
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: #fff;
}

.toggle-label {
  font-size: 12px;
  color: var(--text-secondary);
  user-select: none;
}

/* ===== SEARCH ===== */
.search-bar {
  position: relative;
}

.search-bar input {
  padding-left: 34px;
  width: 260px;
}

.search-bar .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.3s ease;
  max-width: 400px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

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

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* ===== LOADING ===== */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== SAVE INDICATOR ===== */
.save-indicator {
  font-size: 11px;
  color: var(--success);
  opacity: 0;
  transition: opacity 0.3s;
}

.save-indicator.visible {
  opacity: 1;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
}

/* ===== SECTION DESCRIPTION ===== */
.section-description {
  margin-bottom: 20px;
  padding: 14px 18px;
  background: rgba(88, 166, 255, 0.06);
  border: 1px solid rgba(88, 166, 255, 0.15);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ===== JSON EDITOR ===== */
.json-preview {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 12px;
  color: var(--warning);
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  padding: 4px 8px;
  background: rgba(210, 153, 34, 0.08);
  border-radius: var(--radius-sm);
}

.json-preview:hover {
  background: rgba(210, 153, 34, 0.15);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 560px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.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;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

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

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

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

/* Form group in modal */
.form-group {
  margin-bottom: 16px;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .status-grid.cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .sidebar {
    width: 200px;
  }

  .setting-row {
    grid-template-columns: 1fr 200px;
  }

  .status-grid.cols-3 {
    grid-template-columns: 1fr;
  }

  .system-clock-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .clock-tz {
    margin-left: 0;
  }
}

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

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

  .setting-control {
    justify-content: flex-start;
    padding-top: 0;
  }

  .system-clock-bar {
    flex-direction: column;
    text-align: center;
  }

  .clock-tz {
    align-self: center;
  }
}
