/* ============================================
   LOMA — Dark Minimalist Dashboard
   Inspired by Linear, Vercel, Raycast
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-hover: #1a1a1a;
  --surface-active: #1e1e1e;
  --border: #222;
  --border-subtle: #1a1a1a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-muted: rgba(99, 102, 241, 0.12);
  --accent-glow: rgba(99, 102, 241, 0.08);
  --success: #22c55e;
  --success-muted: rgba(34, 197, 94, 0.12);
  --error: #ef4444;
  --error-muted: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-muted: rgba(245, 158, 11, 0.12);
  --text: #e5e5e5;
  --text-secondary: #737373;
  --text-tertiary: #525252;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --sidebar-collapsed: 56px;
  --sidebar-expanded: 200px;
  --transition: 0.15s ease;
  --transition-slow: 0.25s ease;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'SF Mono', 'Cascadia Code', 'Fira Code', ui-monospace, monospace;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

/* --- Layout --- */
.layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-collapsed);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition-slow);
  overflow: hidden;
}
.sidebar:hover {
  width: var(--sidebar-expanded);
}

.sidebar-header {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.sidebar-logo .logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  margin-right: 10px;
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  opacity: 0;
  transition: opacity var(--transition-slow);
}
.sidebar:hover .logo-text {
  opacity: 1;
}

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

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
  gap: 10px;
}
.sidebar-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.sidebar-link.active {
  background: var(--accent-muted);
  color: var(--accent-hover);
}

.sidebar-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}
.sidebar-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-label {
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity var(--transition-slow);
}
.sidebar:hover .sidebar-label {
  opacity: 1;
}

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

/* --- Main Content --- */
.main {
  margin-left: var(--sidebar-collapsed);
  flex: 1;
  min-height: 100vh;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 40px;
}

/* --- Page Header --- */
.page-header {
  margin-bottom: 32px;
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition);
}
.card:hover {
  border-color: #2a2a2a;
}

/* --- Stat Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
}
.stat-card:hover {
  border-color: #2a2a2a;
}
.stat-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}
.stat-card--accent::before { background: var(--accent); }
.stat-card--success::before { background: var(--success); }
.stat-card--warning::before { background: var(--warning); }
.stat-card--error::before { background: var(--error); }

.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 6px;
}
.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

/* --- Tables --- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.table-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  text-align: left;
  padding: 10px 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.01);
}
tbody td {
  padding: 10px 20px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: none;
}
tbody tr {
  transition: background var(--transition);
}
tbody tr:hover {
  background: var(--surface-hover);
}

.cell-mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
}
.cell-truncate {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-link {
  color: var(--accent);
  text-decoration: none;
}
.cell-link:hover {
  text-decoration: underline;
}
.cell-number {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  font-size: 12px;
}

/* --- Status Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 18px;
}
.badge--ready,
.badge--success,
.badge--published {
  background: var(--success-muted);
  color: var(--success);
}
.badge--error,
.badge--failed {
  background: var(--error-muted);
  color: var(--error);
}
.badge--unchecked,
.badge--pending,
.badge--warning {
  background: var(--warning-muted);
  color: var(--warning);
}
.badge--done,
.badge--running {
  background: var(--accent-muted);
  color: var(--accent-hover);
}
.badge--draft {
  background: rgba(115,115,115,0.12);
  color: var(--text-secondary);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
}
.badge--ready .badge-dot,
.badge--success .badge-dot,
.badge--published .badge-dot { background: var(--success); }
.badge--error .badge-dot,
.badge--failed .badge-dot { background: var(--error); }
.badge--unchecked .badge-dot,
.badge--pending .badge-dot,
.badge--warning .badge-dot { background: var(--warning); }
.badge--done .badge-dot,
.badge--running .badge-dot { background: var(--accent); }
.badge--draft .badge-dot { background: var(--text-tertiary); }

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

.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: #333;
}

.btn--danger {
  background: var(--error-muted);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn--danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.35);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}
.btn--ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

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

.btn-icon {
  display: inline-flex;
  font-size: 14px;
  flex-shrink: 0;
}

/* --- Filter Pills --- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  width: fit-content;
}

.filter-pill {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.filter-pill:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.filter-pill.active {
  color: var(--text);
  background: var(--surface-active);
}

/* --- Drop Zones --- */
.drop-zones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.drop-zone {
  border: 1px dashed #333;
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  background: var(--surface);
}
.drop-zone:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-muted);
}
.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.drop-zone-icon {
  font-size: 24px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  display: block;
}
.drop-zone-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}
.drop-zone-hint {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* --- Action Cards --- */
.actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition);
}
.action-card:hover {
  border-color: #2a2a2a;
}
.action-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-bottom: 16px;
}
.action-card-icon--accent {
  background: var(--accent-muted);
  color: var(--accent);
}
.action-card-icon--success {
  background: var(--success-muted);
  color: var(--success);
}
.action-card-icon--warning {
  background: var(--warning-muted);
  color: var(--warning);
}

.action-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}
.action-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
  flex: 1;
}
.action-card .btn {
  width: 100%;
}

/* --- Progress --- */
.progress-section {
  margin-bottom: 24px;
}
.progress-section.hidden {
  display: none;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.progress-title {
  font-size: 14px;
  font-weight: 600;
}
.progress-meta {
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
  position: relative;
}
.progress-fill.animating::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  animation: shimmer 1.5s infinite;
}

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

.progress-counters {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
}
.progress-counter {
  font-size: 12px;
  color: var(--text-secondary);
}
.progress-counter strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* --- Terminal / Log --- */
.log-box {
  background: #0c0c0c;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 360px;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.log-box::-webkit-scrollbar {
  width: 6px;
}
.log-box::-webkit-scrollbar-track {
  background: transparent;
}
.log-box::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}
.log-line {
  padding: 1px 0;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-line--error {
  color: var(--error);
}
.log-line--success {
  color: var(--success);
}
.log-line--info {
  color: var(--accent-hover);
}

/* --- Export Page --- */
.export-hero {
  text-align: center;
  padding: 48px 20px;
  margin-bottom: 32px;
}
.export-hero-number {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.export-hero-label {
  font-size: 15px;
  color: var(--text-secondary);
}

.export-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 40px;
}

/* --- Domain Detail Header --- */
.detail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.detail-title {
  font-size: 16px;
  font-weight: 600;
  font-family: var(--mono);
  margin-bottom: 16px;
  color: var(--text);
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.detail-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.detail-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  font-weight: 500;
}
.detail-value {
  font-size: 13px;
  color: var(--text);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-tertiary);
}
.empty-state-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.empty-state-desc {
  font-size: 12px;
}

/* --- Forms --- */
form .form-row {
  margin-bottom: 16px;
}
form label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  transition: border-color var(--transition);
  outline: none;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

/* --- Flash Messages --- */
.flash {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.flash--success {
  background: var(--success-muted);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.15);
}
.flash--error {
  background: var(--error-muted);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.15);
}
.flash--warning {
  background: var(--warning-muted);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.15);
}

/* --- Utility --- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-secondary { color: var(--text-secondary); }
.text-mono { font-family: var(--mono); font-size: 12px; }
.text-sm { font-size: 12px; }
.text-center { text-align: center; }
.w-full { width: 100%; }

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in {
  animation: fadeIn 0.2s ease forwards;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .actions-grid {
    grid-template-columns: 1fr;
  }
  .drop-zones {
    grid-template-columns: 1fr;
  }
  .page {
    padding: 24px 20px;
  }
}
