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

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.8);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-dim: #64748b;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --purple: #a855f7;
  --cyan: #06b6d4;
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Login Page ────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0a0e17 0%, #1a1040 50%, #0a0e17 100%);
}

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

.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 48px 36px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.login-header {
  text-align: center;
  margin-bottom: 36px;
}
.login-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
  animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%,
  100% {
    filter: drop-shadow(0 0 8px var(--accent-glow));
  }
  50% {
    filter: drop-shadow(0 0 20px var(--accent-glow));
  }
}
.login-header h1 {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-subtitle {
  color: var(--text-secondary);
  margin-top: 6px;
  font-size: 14px;
}

.error-alert {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 20px;
  text-align: center;
}

.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  transition:
    border var(--transition),
    box-shadow var(--transition);
  outline: none;
}
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group input::placeholder {
  color: var(--text-dim);
}

.btn-login {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
}
.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

/* ─── Header ────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: rgba(17, 24, 39, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-icon {
  font-size: 28px;
}
.header-left h1 {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-status {
  font-size: 13px;
  color: var(--text-secondary);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
}
.status-dot-active {
  background: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}
.status-dot-error {
  background: var(--error);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.btn-logout {
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}
.btn-logout:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* ─── Main ──────────────────────────────────── */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 32px 60px;
}

/* ─── Control Panel ─────────────────────────── */
.control-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 36px;
}

.control-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color var(--transition);
}
.control-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.control-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.control-header h2 {
  font-size: 16px;
  font-weight: 600;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 26px;
  transition: var(--transition);
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
}
input:checked + .toggle-slider {
  background: var(--accent);
}
input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

.scheduler-body,
.sync-all-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.interval-group label,
.datanumber-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.interval-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}
.interval-multi-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.interval-field {
  display: flex;
  align-items: center;
  gap: 4px;
}
.interval-unit {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.interval-multi-wrap .interval-input {
  width: 60px;
  text-align: center;
}
.interval-input,
.dn-input {
  width: 100px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border var(--transition);
}
.interval-input:focus,
.dn-input:focus {
  border-color: var(--accent);
}
.input-hint {
  font-size: 11px;
  color: var(--text-dim);
}

.btn-sm {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}
.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover {
  background: #5558e6;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.scheduler-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--glass);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.sched-active {
  color: var(--success);
}
.sched-disabled {
  color: var(--text-dim);
}
.scheduler-clock {
  font-variant-numeric: tabular-nums;
  color: var(--cyan);
  font-weight: 500;
  font-size: 12px;
}

.btn-sync-all {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-sync-all:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--accent-glow);
}
.btn-sync-all:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ─── Provider Grid ─────────────────────────── */
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.provider-count {
  background: var(--accent);
  color: white;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 600;
}

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

.provider-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
}
.provider-card:hover {
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.provider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.provider-name-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.provider-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.provider-header h3 {
  font-size: 15px;
  font-weight: 600;
  text-transform: capitalize;
}

.provider-status-badge {
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
}
.status-idle {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
}
.status-success {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
}
.status-error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--error);
}
.status-no_data {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}
.status-no_new {
  background: rgba(6, 182, 212, 0.12);
  color: var(--cyan);
}

.provider-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.5fr;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--glass);
  border-radius: var(--radius-sm);
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  font-weight: 500;
}
.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.stat-keys {
  color: var(--cyan);
}
.stat-time {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.provider-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.datanumber-inline {
  flex-shrink: 0;
}
.dn-input {
  width: 72px;
  padding: 8px 10px;
  font-size: 13px;
  text-align: center;
}
.dn-input::placeholder {
  color: var(--text-dim);
  font-size: 12px;
}

.btn-sync {
  flex: 1;
  padding: 10px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-sm);
  color: #a5b4fc;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-sync:hover {
  background: rgba(99, 102, 241, 0.25);
  color: white;
}
.btn-sync:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Spinner */
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ─── Logs ──────────────────────────────────── */
.provider-logs {
  margin-top: auto;
  border-top: 1px solid var(--glass-border);
  padding-top: 8px;
}
.logs-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 6px 4px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color var(--transition);
}
.logs-toggle:hover {
  color: var(--text-secondary);
}
.logs-chevron {
  font-size: 10px;
  transition: transform var(--transition);
}

.logs-content pre {
  max-height: 200px;
  overflow-y: auto;
  padding: 10px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
  font-family: "JetBrains Mono", "Fira Code", monospace;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 6px;
}
.logs-content pre::-webkit-scrollbar {
  width: 5px;
}
.logs-content pre::-webkit-scrollbar-track {
  background: transparent;
}
.logs-content pre::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* ─── Responsive ────────────────────────────── */
@media (max-width: 768px) {
  .header {
    padding: 12px 16px;
  }
  .main {
    padding: 16px;
  }
  .control-panel {
    grid-template-columns: 1fr;
  }
  .provider-grid {
    grid-template-columns: 1fr;
  }
  .provider-stats {
    grid-template-columns: 1fr 1fr;
  }
}
