/* Elara Validate — Dark Theme PWA
   Mobile-first, works on $30 phones.
   Minimal CSS, no frameworks. */

:root {
  --bg: #0a0a0f;
  --bg-card: #12121a;
  --bg-input: #1a1a25;
  --bg-hover: #1f1f2e;
  --text: #e0e0e8;
  --text-dim: #888898;
  --text-muted: #555566;
  --accent: #00d4ff;
  --accent-dim: #0099bb;
  --success: #00e676;
  --error: #ff5252;
  --warning: #ffab40;
  --border: #2a2a3a;
  --radius: 8px;
  --radius-lg: 12px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

.mono {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85em;
  word-break: break-all;
}

.truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}

.hidden { display: none !important; }

/* --- Loading Overlay --- */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --- Error Toast --- */

.error-toast {
  position: fixed;
  bottom: 80px;
  left: 16px;
  right: 16px;
  background: var(--error);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 900;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* --- Buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-appearance: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:active { background: var(--accent-dim); }

.btn-secondary {
  background: var(--bg-input);
  border-color: var(--border);
}

.btn-danger {
  background: transparent;
  border-color: var(--error);
  color: var(--error);
}

.btn-lg {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  margin-top: 8px;
}

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }

/* --- Forms --- */

input[type="text"], textarea, select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}

textarea { resize: vertical; font-family: inherit; }

label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
  margin-top: 16px;
}

.select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888898' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

/* --- Setup Screen --- */

.screen { min-height: 100vh; }

.setup-container {
  max-width: 400px;
  margin: 0 auto;
  padding: 24px 20px;
}

.logo {
  text-align: center;
  padding: 48px 0 32px;
}

.logo-icon { font-size: 48px; margin-bottom: 12px; }

.logo h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 8px;
}

.setup-form {
  margin: 24px 0;
}

.setup-info {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 32px;
  line-height: 1.6;
}

/* Seed phrase display */

.seed-phrase-box {
  background: var(--bg-input);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 20px 0;
}

#seed-phrase-display {
  font-size: 16px;
  line-height: 2;
  word-spacing: 8px;
  color: var(--accent);
}

.warning-text {
  color: var(--warning);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.identity-info {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--text-dim);
  margin: 12px 0;
}

.seed-confirm {
  margin-top: 24px;
}

.seed-confirm label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 16px;
  cursor: pointer;
}

.seed-confirm input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* --- App Header --- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-sm { font-size: 20px; }

.identity-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.badge-key { color: var(--accent); }
.badge-count { color: var(--text-muted); }

/* --- Bottom Nav --- */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s;
}

.nav-btn.active { color: var(--accent); }
.nav-btn:active { color: var(--text); }

.nav-icon { font-size: 20px; margin-bottom: 2px; }

/* --- Views --- */

.view {
  padding: 16px 16px 80px;
  max-width: 500px;
  margin: 0 auto;
}

.view-content h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.view-content > p {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 16px;
}

/* File drop zone */

.file-drop-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  margin: 12px 0;
  transition: border-color 0.15s;
}

.file-drop-zone:hover, .file-drop-zone:focus-within {
  border-color: var(--accent);
}

.file-drop-zone.sm { padding: 16px; }

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-drop-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 14px;
  pointer-events: none;
}

.drop-icon { font-size: 32px; }

.file-info {
  font-size: 13px;
  color: var(--accent);
  padding: 8px 0;
}

/* Progress */

.progress {
  margin: 16px 0;
}

.progress-bar {
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.2s;
  width: 0;
}

.progress-text {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  text-align: center;
}

/* Results */

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin: 16px 0;
}

.result-card.success { border-color: var(--success); }
.result-card.failure { border-color: var(--error); }

.result-header {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.result-card.success .result-header { color: var(--success); }
.result-card.failure .result-header { color: var(--error); }

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.result-row:last-of-type { border-bottom: none; }

.result-row .label {
  color: var(--text-dim);
  margin: 0;
  font-size: 13px;
  flex-shrink: 0;
}

.result-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

/* Verification checks */

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

.check-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}

.check-row.pass span:last-child { color: var(--success); font-weight: 600; }
.check-row.fail span:last-child { color: var(--error); font-weight: 600; }
.check-error { font-size: 12px; color: var(--error); padding: 2px 0 6px; }

.warnings {
  margin-top: 8px;
  padding: 8px;
  background: rgba(255, 171, 64, 0.1);
  border-radius: var(--radius);
}

.warning {
  font-size: 13px;
  color: var(--warning);
  padding: 4px 0;
}

/* History */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.proof-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.proof-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 4px;
}

.type-created { background: rgba(0, 212, 255, 0.15); color: var(--accent); }
.type-reviewed { background: rgba(0, 230, 118, 0.15); color: var(--success); }
.type-witnessed { background: rgba(255, 171, 64, 0.15); color: var(--warning); }
.type-approved { background: rgba(156, 39, 176, 0.15); color: #ce93d8; }

.proof-file {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.proof-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  width: 100%;
}

/* Identity */

.identity-details {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin: 12px 0;
}

.identity-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.identity-actions hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

/* Proof card actions */

.proof-actions {
  display: flex;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
}

/* QR sync bar */

.qr-sync-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

/* Modal overlay */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  width: 100%;
  max-width: 560px;
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  gap: 8px;
}

.qr-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background: #ffffff;
  border-radius: var(--radius);
}

.qr-container canvas {
  max-width: 100%;
  height: auto;
}

.qr-size {
  font-size: 12px;
  color: var(--text-muted);
}

.qr-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* QR Scanner */

.scanner-modal {
  max-width: 400px;
}

.scanner-video {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  aspect-ratio: 1;
  object-fit: cover;
}

.scan-status {
  text-align: center;
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 8px;
}

.scan-count {
  text-align: center;
  font-size: 14px;
  color: var(--success);
  font-weight: 600;
  margin-top: 4px;
}

/* Empty state */

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
  font-size: 14px;
}

/* PWA install prompt */
@media (display-mode: standalone) {
  .app-header { padding-top: env(safe-area-inset-top, 12px); }
}

/* Very small screens */
@media (max-width: 360px) {
  html { font-size: 13px; }
  .nav-label { font-size: 10px; }
}
