/* ===================================================================
   devenv.tools Dashboard — Dark theme, developer-focused
   Tailwind-inspired utility CSS with custom properties for theming
   =================================================================== */

/* --- Theme Variables --- */
:root {
  --color-bg-primary: #0f1117;
  --color-bg-secondary: #161822;
  --color-bg-tertiary: #1e2030;
  --color-bg-hover: #252840;
  --color-bg-input: #1a1c2e;

  --color-border: #2a2d42;
  --color-border-focus: #6366f1;

  --color-text-primary: #e2e4f0;
  --color-text-secondary: #8b8fa8;
  --color-text-muted: #5c6078;

  --color-accent: #6366f1;
  --color-accent-hover: #818cf8;
  --color-accent-muted: rgba(99, 102, 241, 0.15);

  --color-success: #22c55e;
  --color-warning: #eab308;
  --color-danger: #ef4444;
  --color-info: #3b82f6;

  --color-success-bg: rgba(34, 197, 94, 0.1);
  --color-warning-bg: rgba(234, 179, 8, 0.1);
  --color-danger-bg: rgba(239, 68, 68, 0.1);

  --sidebar-width: 240px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text-primary);
  background: var(--color-bg-primary);
  -webkit-font-smoothing: antialiased;
}

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

/* --- Layout --- */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar.hidden {
  display: none;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--color-border);
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
}

.logo-accent {
  color: var(--color-accent);
}

.nav-links {
  list-style: none;
  padding: 8px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

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

.nav-link.active {
  background: var(--color-accent-muted);
  color: var(--color-accent);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

.user-info {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.main-content.full-width {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Page header --- */
.page-header {
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}

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

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* --- Cards --- */
.card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

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

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

/* --- Stat cards grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text-primary);
}

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

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

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
  color: var(--color-text-secondary);
}

tbody tr:hover {
  background: var(--color-bg-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* --- Status indicators --- */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.status-dot.green {
  background: var(--color-success);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}

.status-dot.yellow {
  background: var(--color-warning);
  box-shadow: 0 0 6px rgba(234, 179, 8, 0.4);
}

.status-dot.red {
  background: var(--color-danger);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

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

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

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

.badge-neutral {
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

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

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

.btn-secondary {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--color-bg-hover);
}

.btn-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
}

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

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

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

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  transition: border-color 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-accent-muted);
}

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

.form-input.mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

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

/* --- Login page --- */
.login-container {
  width: 100%;
  max-width: 380px;
  padding: 20px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 700;
}

.login-card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.login-card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.login-card p {
  color: var(--color-text-secondary);
  font-size: 13px;
  margin-bottom: 20px;
}

.login-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  color: var(--color-text-muted);
  font-size: 13px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.login-divider span {
  padding: 0 12px;
}

.btn-github {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #24292f;
  color: #fff;
  border: 1px solid #444;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-github:hover:not(:disabled) {
  background: #32383f;
}

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

.login-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}

.login-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.login-tab:hover {
  color: var(--color-text-secondary);
}

.login-tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* --- Alerts / toasts --- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-error {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-info);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* --- Monospace / code --- */
.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--color-bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--color-accent-hover);
}

/* --- Empty states --- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-text-muted);
}

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

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

/* --- Filter bar --- */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-bar .form-input {
  max-width: 260px;
}

/* --- Modal / dialog --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s;
}

.modal {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s;
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* --- Domain CNAME instructions --- */
.cname-box {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-secondary);
  margin: 12px 0;
  word-break: break-all;
}

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

/* --- Keyframes --- */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    display: flex;
  }
  .main-content {
    padding: 16px;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .mobile-menu-btn {
    display: block !important;
  }
}

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  padding: 8px;
  cursor: pointer;
}

/* --- Section spacer --- */
.section {
  margin-bottom: 32px;
}

/* --- API key display --- */
.api-key-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.api-key-display .form-input {
  flex: 1;
}

/* --- Tag list for filters --- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--color-bg-tertiary);
  border-radius: 9999px;
  font-size: 12px;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s;
}

.tag:hover, .tag.active {
  background: var(--color-accent-muted);
  color: var(--color-accent);
}

/* --- Billing: Plan badges --- */
.badge-plan-free {
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
}

.badge-plan-pro {
  background: var(--color-accent-muted);
  color: var(--color-accent);
}

.badge-plan-team {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
}

/* --- Billing: Usage meters --- */
.usage-meter {
  margin-bottom: 16px;
}

.usage-meter-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.usage-meter-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.usage-meter-value {
  font-size: 12px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

.usage-bar {
  width: 100%;
  height: 6px;
  background: var(--color-bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--color-accent);
  transition: width 0.4s ease;
}

.usage-bar-fill.usage-high {
  background: var(--color-warning);
}

.usage-bar-fill.usage-full {
  background: var(--color-danger);
}

/* --- Billing: Action buttons row --- */
.billing-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

/* --- Billing: Plan comparison table --- */
.plan-table {
  width: 100%;
  border-collapse: collapse;
}

.plan-table th,
.plan-table td {
  padding: 10px 16px;
  text-align: center;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border);
}

.plan-table th:first-child,
.plan-table td:first-child {
  text-align: left;
}

.plan-table thead th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.plan-table .plan-col-current {
  background: var(--color-accent-muted);
}

/* (Toast styles moved to general Toast notifications section) */

/* --- Billing: Warning alert --- */
.alert-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid rgba(234, 179, 8, 0.2);
}

/* --- Toast notifications --- */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 3.7s;
  animation-fill-mode: forwards;
  max-width: 360px;
}

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

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

/* --- Onboarding modal --- */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  animation: fadeIn 0.15s;
}

.onboarding-modal {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s;
}

.onboarding-modal h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.onboarding-modal .onboarding-subtitle {
  color: var(--color-text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

.onboarding-step {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.onboarding-step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-accent-muted);
  color: var(--color-accent);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding-step-body {
  flex: 1;
}

.onboarding-step-body p {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.onboarding-step-body code {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  word-break: break-all;
}

/* --- Plan badge in sidebar --- */
.sidebar-plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: 6px;
  vertical-align: middle;
}

/* --- Loading state --- */
.loading-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-text-muted);
}

.loading-state .spinner {
  margin: 0 auto 12px;
  width: 24px;
  height: 24px;
}

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

/* --- Member table --- */
.member-table td,
.member-table th {
  vertical-align: middle;
}

/* --- Responsive sidebar overlay --- */
.sidebar-overlay {
  display: none;
}

@media (max-width: 768px) {
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 45;
    animation: fadeIn 0.15s;
  }

  .sidebar.hidden + .sidebar-overlay {
    display: none;
  }

  .table-wrapper {
    -webkit-overflow-scrolling: touch;
  }
}

/* --- Utility --- */
.hidden { display: none !important; }
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
