/* ═══════════════════════════════════════════════════════════
   REJOG WEB CLIENT — CSS
   Dark theme, clean, functional. Not over-designed.
   ═══════════════════════════════════════════════════════════ */

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0a0a0f;
  --bg-raised:  #12121a;
  --bg-card:    #1a1a25;
  --bg-hover:   #22222f;
  --bg-input:   #15151f;
  --border:     #2a2a3a;
  --border-light: #333345;
  --text:       #e0e0e8;
  --text-dim:   #8888a0;
  --text-muted: #555568;
  --accent:     #6c8cff;
  --accent-dim: #4a6ad4;
  --green:      #4ade80;
  --green-dim:  #22633a;
  --red:        #f87171;
  --red-dim:    #7f1d1d;
  --yellow:     #fbbf24;
  --yellow-dim: #78631d;
  --orange:     #fb923c;
  --purple:     #a78bfa;
  --radius:     8px;
  --radius-sm:  4px;
  --radius-lg:  12px;
  --sidebar-w:  240px;
  --capture-h:  56px;
  --font:       -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono:       "SF Mono", "Fira Code", "Consolas", monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Screens ────────────────────────────────────────────── */
#app { height: 100%; }

.screen { display: none; height: 100%; }
.screen.active { display: flex; }

/* ── Login ──────────────────────────────────────────────── */
#screen-login {
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  text-align: center;
}

.logo {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.login-subtitle {
  color: var(--text-dim);
  margin-bottom: 2rem;
}

.login-form {
  text-align: left;
}

.login-form label {
  display: block;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.login-form textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  resize: none;
  margin-bottom: 1rem;
}

.login-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.login-help {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 1.5rem;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dim); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }

.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.78rem; }

.btn-approve { background: var(--green-dim); color: var(--green); border: 1px solid var(--green); }
.btn-approve:hover:not(:disabled) { background: var(--green); color: #000; }

.btn-reject { background: var(--red-dim); color: var(--red); border: 1px solid var(--red); }
.btn-reject:hover:not(:disabled) { background: var(--red); color: #fff; }

.btn-done { background: var(--green-dim); color: var(--green); }

.btn-defer { background: var(--yellow-dim); color: var(--yellow); }

.btn-capture {
  background: var(--accent);
  color: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  line-height: 1;
}

/* ── Layout: Sidebar + Content ──────────────────────────── */
#screen-app {
  flex-direction: row;
}

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
}

.sidebar-header {
  padding: 0 1rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.logo-sm {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.user-badge {
  display: block;
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.nav-list {
  list-style: none;
  flex: 1;
  padding: 0.5rem 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  transition: all 0.1s;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  background: var(--bg-card);
  color: var(--text);
  border-right: 2px solid var(--accent);
}

.nav-icon { font-size: 1rem; }

.badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.badge.hidden { display: none; }

.sidebar-footer {
  padding: 0.75rem 1rem 0;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ── Sync indicator ─────────────────────────────────────── */
.sync-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

.sync-dot.connected { background: var(--green); }
.sync-dot.error { background: var(--red); }

/* ── Content Area ───────────────────────────────────────── */
#content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Capture Bar ────────────────────────────────────────── */
#capture-bar {
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  position: relative;
}

#capture-form {
  display: flex;
  gap: 0.5rem;
}

#capture-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.85rem;
}

#capture-input:focus {
  outline: none;
  border-color: var(--accent);
}

#capture-input::placeholder { color: var(--text-muted); }

.toast {
  position: absolute;
  bottom: -36px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
  font-size: 0.78rem;
  z-index: 10;
  transition: opacity 0.3s;
}

.toast.hidden { opacity: 0; pointer-events: none; }

/* ── Views ──────────────────────────────────────────────── */
.view {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.view.active { display: block; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.view-header h2 {
  font-size: 1.3rem;
  font-weight: 600;
}

.date-label {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.view-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.search-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  width: 200px;
}

.search-input:focus { outline: none; border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

/* ── Item Sections ──────────────────────────────────────── */
.item-section { margin-bottom: 1.5rem; }

.section-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.4rem 0;
  margin-bottom: 0.5rem;
}

.section-clarify { color: var(--orange); }
.section-pending { color: var(--yellow); }
.section-approved { color: var(--green); }
.section-completed { color: var(--text-muted); }

/* ── Item Cards ─────────────────────────────────────────── */
.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.1s;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.item-card:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.item-card.completed {
  opacity: 0.5;
}

.item-checkbox {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid var(--border-light);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  background: transparent;
  color: transparent;
  font-size: 0.7rem;
}

.item-checkbox:hover {
  border-color: var(--green);
}

.item-checkbox.checked {
  background: var(--green);
  border-color: var(--green);
  color: #000;
}

.item-body { flex: 1; min-width: 0; }

.item-content {
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}

.item-meta {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.item-type {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.type-icon {
  font-size: 0.7rem;
}

.urgency-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.urgency-critical { background: var(--red-dim); color: var(--red); }
.urgency-high { background: var(--yellow-dim); color: var(--yellow); }
.urgency-normal { color: var(--text-dim); }
.urgency-low { color: var(--text-muted); }
.urgency-none { color: var(--text-muted); }

.item-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.item-actions .btn { padding: 0.25rem 0.55rem; font-size: 0.72rem; }

/* ── Entity Cards ───────────────────────────────────────── */
.entity-group {
  margin-bottom: 1.5rem;
}

.entity-group-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 0.4rem 0;
  margin-bottom: 0.5rem;
}

.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
}

.entity-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: all 0.1s;
}

.entity-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.entity-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.entity-context {
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Emergency Session Cards ────────────────────────────── */
.emergency-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: all 0.1s;
}

.emergency-card:hover {
  border-color: var(--red);
}

.emergency-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.emergency-status {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
}

.emergency-status.active { background: var(--red-dim); color: var(--red); }
.emergency-status.completed { background: var(--green-dim); color: var(--green); }

.emergency-stats {
  display: flex;
  gap: 1.5rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ── Emergency Detail ───────────────────────────────────── */
.evidence-list {
  margin-top: 1rem;
}

.evidence-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
}

.evidence-type-icon {
  font-size: 1.1rem;
  min-width: 24px;
  text-align: center;
}

.evidence-info { flex: 1; }
.evidence-size { color: var(--text-muted); font-size: 0.72rem; }

/* ── Profile ────────────────────────────────────────────── */
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 600px;
}

.profile-field {
  margin-bottom: 1rem;
}

.profile-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}

.profile-value {
  font-size: 0.9rem;
}

.profile-json {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  margin-top: 0.25rem;
}

.sync-device {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.sync-device:last-child { border-bottom: none; }

/* ── Modals ─────────────────────────────────────────────── */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
}

.modal-content {
  position: relative;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 1;
}

.modal-content.modal-sm { max-width: 400px; }
.modal-content.modal-lg { max-width: 800px; }

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

.modal-close:hover { color: var(--text); }

/* ── Forms ──────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.optional { font-weight: 400; color: var(--text-muted); }

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.85rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* ── Item Detail (in modal) ─────────────────────────────── */
.detail-header {
  margin-bottom: 1rem;
}

.detail-content {
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.detail-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.detail-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.detail-section h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.connection-item, .annotation-item {
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
}

.annotation-item .annotation-date {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.detail-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.annotate-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.annotate-form input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.annotate-form input:focus { outline: none; border-color: var(--accent); }

/* ── Entity Detail (in modal) ───────────────────────────── */
.entity-detail-header {
  margin-bottom: 1rem;
}

.entity-detail-name {
  font-size: 1.2rem;
  font-weight: 600;
}

.entity-detail-type {
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.alias-list {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.alias-tag {
  background: var(--bg);
  color: var(--text-dim);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.75rem;
}

.add-alias-form {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.add-alias-form input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}

.add-alias-form input:focus { outline: none; border-color: var(--accent); }

.association-item {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
}

.association-relationship {
  color: var(--text-dim);
  font-size: 0.75rem;
}

/* ── Empty States ───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}

.empty-state.hidden { display: none; }

/* ── Keyboard shortcut hints ────────────────────────────── */
.kbd {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  #sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 50;
    transition: left 0.2s;
  }

  #sidebar.open { left: 0; }

  .view { padding: 1rem; }
  .entity-grid { grid-template-columns: 1fr; }

  .view-header { flex-direction: column; align-items: flex-start; }
}

/* ── Loading spinner ────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Skeleton loading ───────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  height: 1em;
}

@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ── GPS Trail (simple) ─────────────────────────────────── */
.gps-trail {
  max-height: 200px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  padding: 0.5rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.gps-point {
  padding: 0.15rem 0;
}
