/* Glyphh Runtime Dashboard — Dark Theme */

:root {
  --g-bg: #0a0a0a;
  --g-fg: #e0e0e0;
  --g-primary: #9333ea;
  --g-primary-light: #a855f7;
  --g-primary-dim: rgba(147, 51, 234, 0.15);
  --g-surface: #18181b;
  --g-surface-hover: #1e1e22;
  --g-border: #27272a;
  --g-muted: #9ca3af;
  --g-success: #22c55e;
  --g-warning: #eab308;
  --g-error: #ef4444;
  --g-info: #06b6d4;
  --g-radius: 10px;
  --g-radius-sm: 6px;
  --g-shadow: 0 1px 3px rgba(0,0,0,0.4);
  --g-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --g-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;
}

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

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

a { color: var(--g-primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

[hidden] { display: none !important; }

/* ── Buttons ─────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--g-border);
  border-radius: var(--g-radius-sm);
  background: var(--g-surface);
  color: var(--g-fg);
  font-size: 13px;
  font-family: var(--g-font);
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { background: var(--g-surface-hover); border-color: var(--g-muted); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--g-primary);
  border-color: var(--g-primary);
  color: #fff;
  font-weight: 500;
}
.btn-primary:hover { background: var(--g-primary-light); border-color: var(--g-primary-light); }

.btn-danger {
  color: var(--g-error);
  border-color: rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.1); border-color: var(--g-error); }

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

/* ── Header ──────────────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--g-border);
  background: var(--g-surface);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-brand img { height: 28px; }
.header-brand span {
  font-size: 16px;
  font-weight: 600;
  color: var(--g-fg);
}

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

.header-org {
  font-size: 12px;
  color: var(--g-muted);
  padding: 4px 10px;
  background: var(--g-primary-dim);
  border-radius: var(--g-radius-sm);
}

/* ── Login Screen ────────────────────────────────────────────────── */

.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 32px;
}

.login-logo img { height: 48px; }

.login-card {
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  border-radius: var(--g-radius);
  padding: 40px;
  text-align: center;
  max-width: 380px;
  width: 100%;
}

.login-card h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.login-card p {
  font-size: 13px;
  color: var(--g-muted);
  margin-bottom: 24px;
}

.device-code {
  font-family: var(--g-mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--g-primary-light);
  margin: 20px 0;
}

.login-status {
  font-size: 13px;
  color: var(--g-muted);
  margin-top: 16px;
}

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

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--g-border);
  border-top-color: var(--g-primary-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* ── Content Area ────────────────────────────────────────────────── */

.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px;
}

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

.content-header h1 {
  font-size: 20px;
  font-weight: 600;
}

/* ── Model Cards ─────────────────────────────────────────────────── */

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

.model-card {
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  border-radius: var(--g-radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.15s;
}
.model-card:hover {
  border-color: var(--g-primary);
  box-shadow: 0 0 0 1px var(--g-primary);
}

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

.model-card-name {
  font-size: 15px;
  font-weight: 600;
}

.model-card-version {
  font-size: 11px;
  color: var(--g-muted);
  padding: 2px 8px;
  background: var(--g-primary-dim);
  border-radius: 99px;
}

.model-card-id {
  font-size: 12px;
  color: var(--g-muted);
  font-family: var(--g-mono);
  margin-bottom: 12px;
}

.model-card-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--g-muted);
}

.model-card-stat b {
  color: var(--g-fg);
  font-weight: 500;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.status-dot.active { background: var(--g-success); }
.status-dot.inactive { background: var(--g-muted); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--g-muted);
}
.empty-state p { margin-bottom: 16px; }

/* ── Model Detail ────────────────────────────────────────────────── */

.detail-back {
  font-size: 13px;
  color: var(--g-muted);
  cursor: pointer;
  margin-bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.detail-back:hover { color: var(--g-fg); }

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.detail-title h1 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 4px;
}

.detail-meta {
  font-size: 13px;
  color: var(--g-muted);
  font-family: var(--g-mono);
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  border-radius: var(--g-radius-sm);
  padding: 16px 24px;
  min-width: 140px;
}

.stat-card label {
  font-size: 11px;
  color: var(--g-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--g-fg);
  margin-top: 4px;
}

/* ── Drop Zone ───────────────────────────────────────────────────── */

.drop-zone {
  border: 2px dashed var(--g-border);
  border-radius: var(--g-radius);
  padding: 40px;
  text-align: center;
  color: var(--g-muted);
  transition: all 0.2s;
  margin-bottom: 24px;
  cursor: pointer;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--g-primary);
  background: var(--g-primary-dim);
  color: var(--g-fg);
}

.drop-zone-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.drop-zone p {
  font-size: 14px;
  margin-bottom: 4px;
}

.drop-zone small {
  font-size: 12px;
  color: var(--g-muted);
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--g-border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--g-primary);
  transition: width 0.3s;
  border-radius: 2px;
}

.load-status {
  font-size: 13px;
  color: var(--g-muted);
  margin-top: 8px;
}

/* ── Data Table ──────────────────────────────────────────────────── */

.data-table-wrap {
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  border-radius: var(--g-radius);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  color: var(--g-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--g-border);
  font-weight: 500;
}

.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--g-border);
  color: var(--g-fg);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--g-surface-hover); }

.data-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--g-muted);
  border-top: 1px solid var(--g-border);
}

/* ── Toast Notifications ─────────────────────────────────────────── */

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

.toast {
  padding: 12px 20px;
  border-radius: var(--g-radius-sm);
  font-size: 13px;
  box-shadow: var(--g-shadow);
  animation: toast-in 0.2s ease-out;
  max-width: 360px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast-success { background: rgba(34,197,94,0.15); color: var(--g-success); border: 1px solid rgba(34,197,94,0.3); }
.toast-error { background: rgba(239,68,68,0.15); color: var(--g-error); border: 1px solid rgba(239,68,68,0.3); }
.toast-info { background: rgba(6,182,212,0.15); color: var(--g-info); border: 1px solid rgba(6,182,212,0.3); }

/* ── Confirm Dialog ──────────────────────────────────────────────── */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.dialog {
  background: var(--g-surface);
  border: 1px solid var(--g-border);
  border-radius: var(--g-radius);
  padding: 24px;
  max-width: 400px;
  width: 90%;
}

.dialog h3 { font-size: 16px; margin-bottom: 8px; }
.dialog p { font-size: 13px; color: var(--g-muted); margin-bottom: 20px; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── File Upload ─────────────────────────────────────────────────── */

.file-input { display: none; }

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .header { padding: 12px 16px; }
  .content { padding: 16px; }
  .model-grid { grid-template-columns: 1fr; }
  .detail-header { flex-direction: column; gap: 16px; }
  .detail-stats { flex-wrap: wrap; }
}
