/* === Sformiruy Dashboard — Design System === */

:root {
  --bg: #0D1117;
  --surface: #161B22;
  --surface-hover: #1C2128;
  --border: #21262D;
  --border-hover: #30363D;
  --text-primary: #E6EDF3;
  --text-secondary: #8B949E;
  --text-muted: #484F58;
  --yellow: #F5C518;
  --yellow-hover: #FFD43B;
  --blue: #58A6FF;
  --green: #34D399;
  --red: #F85149;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(245, 197, 24, 0.3);
}

/* === Sidebar === */

.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--yellow);
  color: var(--bg);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
}

.logo-text {
  font-weight: 700;
  font-size: 16px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

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

.nav-item.active {
  background: rgba(245, 197, 24, 0.08);
  color: var(--yellow);
}

.nav-item .external-icon {
  margin-left: auto;
  opacity: 0.5;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

/* === Main Content === */

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 32px 40px;
  max-width: 1000px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
}

/* === Cards === */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
}

/* === Connect Grid === */

.connect-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  align-items: start;
}

/* === Form === */

.form-group {
  margin-bottom: 16px;
}

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

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

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

.form-group input:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.1);
}

.form-group input.error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.1);
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* === Buttons === */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 32px;
  background: var(--yellow);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  margin-top: 8px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--yellow-hover);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-spinner {
  animation: spin 1s linear infinite;
}

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* === Status Panel === */

.status-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 0;
  gap: 12px;
}

.status-empty p {
  font-size: 14px;
  color: var(--text-secondary);
}

.text-muted {
  color: var(--text-muted) !important;
  font-size: 13px !important;
}

.status-connected {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

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

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

.status-badge.connected {
  background: rgba(52, 211, 153, 0.1);
  color: var(--green);
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.status-badge.discovering {
  background: rgba(245, 197, 24, 0.1);
  color: var(--yellow);
  border: 1px solid rgba(245, 197, 24, 0.2);
}

.status-badge.error {
  background: rgba(248, 81, 73, 0.1);
  color: var(--red);
  border: 1px solid rgba(248, 81, 73, 0.2);
}

.status-badge.pending {
  background: rgba(139, 148, 158, 0.1);
  color: var(--text-secondary);
  border: 1px solid rgba(139, 148, 158, 0.2);
}

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

.status-badge.connected .status-dot,
.status-badge.discovering .status-dot {
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* === Progress === */

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: var(--yellow);
  border-radius: 3px;
  transition: width 0.5s ease;
  width: 0%;
}

.progress-fill.indeterminate {
  width: 30%;
  animation: indeterminate 1.5s ease-in-out infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
}

/* === Results === */

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.results-header .card-title {
  margin-bottom: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
}

.stat-card-accent {
  border-color: rgba(245, 197, 24, 0.2);
  background: rgba(245, 197, 24, 0.04);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card-accent .stat-value {
  color: var(--yellow);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.results-meta {
  font-size: 13px;
  color: var(--text-muted);
}

/* === Error message === */

.error-message {
  background: rgba(248, 81, 73, 0.08);
  border: 1px solid rgba(248, 81, 73, 0.2);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
}

/* === Responsive === */

@media (max-width: 1024px) {
  .connect-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-logo {
    border-bottom: none;
    padding: 12px 16px;
  }
  .sidebar-nav {
    flex-direction: row;
    padding: 8px;
  }
  .sidebar-footer {
    display: none;
  }
  .main-content {
    margin-left: 0;
    padding: 24px 16px;
  }
  body {
    flex-direction: column;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}
