:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22262f;
  --border: rgba(255,255,255,0.1);
  --text: #e4e4e7;
  --muted: #9ca3af;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 8px;
  --radius-lg: 12px;
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app { height: 100%; display: flex; flex-direction: column; }

#mainScreen {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Screens ─────────────────────────────── */
.screen { height: 100%; }
.screen--login {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 20%, rgba(99,102,241,0.15), transparent 60%),
              radial-gradient(ellipse at 80% 70%, rgba(139,92,246,0.1), transparent 50%),
              var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: min(380px, 90vw);
}
.login-card__title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-card__sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }

input[type="text"], input[type="password"], input[type="url"],
input[type="email"], input[type="number"], textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color 150ms;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}
select { cursor: pointer; }

.error-msg { color: var(--danger); font-size: 13px; }

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px; font-weight: 500;
  cursor: pointer; user-select: none;
  transition: background 120ms, border-color 120ms;
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover { background: var(--accent-hover); }
.btn--danger { border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: rgba(239,68,68,0.1); }
.btn--sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn--icon {
  width: 32px; height: 32px; padding: 0;
  font-size: 16px; border-radius: 50%;
}

/* ── Topbar ──────────────────────────────── */
.topbar {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  z-index: 10;
}
.brand { display: flex; flex-direction: column; gap: 1px; }
.brand__title { font-weight: 700; font-size: 16px; }
.brand__subtitle { font-size: 12px; color: var(--muted); }
.actions { display: flex; align-items: center; gap: 8px; }

/* ── Views ───────────────────────────────── */
.view { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.view__header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.view__header h2 { font-size: 18px; font-weight: 600; }

/* ── Asset grid ──────────────────────────── */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.asset-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: border-color 150ms, transform 120ms;
}
.asset-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.asset-card__title { font-weight: 600; margin-bottom: 4px; }
.asset-card__meta { font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.asset-card__desc { font-size: 13px; color: var(--muted); margin-top: 6px; }

.type-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.type-badge--panorama { background: rgba(59,130,246,0.15); color: #60a5fa; }
.type-badge--video { background: rgba(168,85,247,0.15); color: #c084fc; }
.type-badge--text { background: rgba(34,197,94,0.15); color: #4ade80; }
.type-badge--audio { background: rgba(251,146,60,0.15); color: #fb923c; }

.status-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.status-badge--pending { background: rgba(255,255,255,0.06); color: var(--muted); }
.status-badge--in_review { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-badge--reviewed { background: rgba(59,130,246,0.15); color: #60a5fa; }
.status-badge--approved { background: rgba(34,197,94,0.15); color: var(--success); }
.status-badge--rejected { background: rgba(239,68,68,0.15); color: var(--danger); }

/* ── Review layout ───────────────────────── */
.review-layout {
  display: flex;
  height: calc(100vh - 57px);
  gap: 0;
  margin: -16px;
}
.review-layout__viewer {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
  min-width: 0;
}
.review-layout__panel {
  width: 360px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.panel-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.panel-header h3 { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status-select {
  font-size: 12px; padding: 4px 8px; min-width: 120px;
}

.comment-list {
  flex: 1; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}

.comment-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 120ms;
}
.comment-item:hover { border-color: rgba(255,255,255,0.2); }
.comment-item__header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.comment-item__author { font-weight: 600; font-size: 12px; color: var(--accent); }
.comment-item__time { font-size: 11px; color: var(--muted); }
.comment-item__content { line-height: 1.4; }
.comment-item__region-info { font-size: 11px; color: var(--muted); margin-top: 4px; }
.comment-item__attachments { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.comment-item__attachments img {
  max-width: 100px; max-height: 70px; border-radius: 4px;
  border: 1px solid var(--border); cursor: pointer;
}
.comment-item__attachments a {
  color: var(--accent); font-size: 12px; text-decoration: none;
}
.comment-item__attachments a:hover { text-decoration: underline; }
.comment-item__delete {
  background: none; border: none; color: var(--danger); cursor: pointer;
  font-size: 14px; padding: 2px 4px; opacity: 0.6;
}
.comment-item__delete:hover { opacity: 1; }

/* ── Viewer toolbars ─────────────────────── */
.viewer-toolbar {
  position: absolute;
  bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 6px 10px;
  background: rgba(0,0,0,0.7);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.viewer-toolbar .btn { height: 32px; font-size: 12px; }

/* Annotation rectangle */
.annotation-rect {
  position: absolute;
  border: 2px solid #ef4444;
  background: rgba(239,68,68,0.08);
  pointer-events: none;
  z-index: 15;
}
.annotation-rect--active {
  pointer-events: auto;
  cursor: pointer;
}
.annotation-rect--highlight {
  border-color: #f59e0b;
  background: rgba(245,158,11,0.15);
  animation: pulse-rect 1s ease-in-out 3;
}

@keyframes pulse-rect {
  0%, 100% { border-color: #f59e0b; }
  50% { border-color: #fbbf24; box-shadow: 0 0 12px rgba(245,158,11,0.4); }
}

/* Panorama overlay */
.panorama-overlay {
  position: absolute; inset: 0;
  cursor: crosshair;
  z-index: 12;
}
.panorama-drawing-rect {
  position: absolute;
  border: 2px dashed #ef4444;
  background: rgba(239,68,68,0.1);
  pointer-events: none;
}

.panorama-loading {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 25% 20%, rgba(99,102,241,0.28), transparent 45%),
    radial-gradient(circle at 75% 80%, rgba(14,165,233,0.2), transparent 45%),
    rgba(3, 7, 18, 0.74);
  backdrop-filter: blur(2px);
}

.panorama-loading.hidden {
  display: none;
}

.panorama-loading__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.62);
}

.panorama-loading__spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.25);
  border-top-color: #60a5fa;
  border-right-color: #22d3ee;
  animation: panorama-spin 0.9s linear infinite;
}

.panorama-loading__title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.panorama-loading__text {
  font-size: 12px;
  color: var(--muted);
}

.panorama-loading__progress {
  width: min(320px, 70vw);
  height: 8px;
  border-radius: 999px;
  background: rgba(148,163,184,0.24);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}

.panorama-loading__progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #60a5fa, #22d3ee);
  transition: width 120ms ease;
}

.panorama-loading__progress--indeterminate .panorama-loading__progress-fill {
  width: 42%;
  animation: panorama-progress-indeterminate 1.1s ease-in-out infinite;
}

.panorama-loading__percent {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
  letter-spacing: 0.2px;
}

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

@keyframes panorama-progress-indeterminate {
  0% { transform: translateX(-120%); }
  50% { transform: translateX(25%); }
  100% { transform: translateX(260%); }
}

/* Transparency slider */
.transparency-control {
  position: absolute;
  top: 12px; left: 12px;
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.7);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  z-index: 20;
  font-size: 12px;
  color: var(--muted);
}
.transparency-control input[type="range"] {
  width: 120px;
  accent-color: var(--accent);
}

/* ── Text reviewer ───────────────────────── */
.text-viewer {
  padding: 24px;
  max-width: 800px;
  margin: 0 auto;
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
  height: 100%;
  overflow-y: auto;
  user-select: text;
}
.text-highlight {
  background: rgba(239,68,68,0.2);
  border-bottom: 2px solid var(--danger);
  cursor: pointer;
  transition: background 150ms;
}
.text-highlight:hover { background: rgba(239,68,68,0.35); }
.text-highlight--active { background: rgba(245,158,11,0.3); border-color: var(--warning); }

/* ── Audio reviewer ──────────────────────── */
.audio-viewer {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; padding: 24px; gap: 24px;
}
.audio-player-wrap {
  width: 100%; max-width: 700px;
}
.audio-player-wrap audio { width: 100%; }
.audio-timeline {
  position: relative;
  width: 100%; max-width: 700px;
  height: 60px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: crosshair;
  overflow: hidden;
}
.audio-timeline__progress {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  background: rgba(99,102,241,0.15);
  pointer-events: none;
}
.audio-timeline__selection {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(239,68,68,0.2);
  border-left: 2px solid var(--danger);
  border-right: 2px solid var(--danger);
  pointer-events: none;
}
.audio-timeline__marker {
  position: absolute;
  top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  pointer-events: none;
  z-index: 2;
}
.audio-marker-dot {
  position: absolute;
  top: 50%; transform: translate(-50%, -50%);
  width: 10px; height: 10px;
  background: var(--danger);
  border-radius: 50%;
  cursor: pointer;
  z-index: 5;
}

/* ── Video overlay ───────────────────────── */
.video-container {
  position: relative;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: #000;
}
.video-container video {
  max-width: 100%; max-height: 100%;
}
.video-overlay {
  position: absolute; inset: 0;
  cursor: crosshair;
  z-index: 12;
}

/* ── Modal ───────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
.modal__content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: min(460px, 90vw);
  max-height: 80vh;
  overflow-y: auto;
}
.modal__content h3 { margin-bottom: 14px; }
.modal__content form { display: flex; flex-direction: column; gap: 10px; }
.modal__actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* ── Admin ───────────────────────────────── */
.admin-section { margin-bottom: 32px; }
.admin-section h2 { margin-bottom: 12px; font-size: 18px; }
.admin-section h3 { margin: 16px 0 8px; font-size: 15px; }
.admin-form { display: flex; flex-direction: column; gap: 10px; max-width: 500px; }
.file-label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.file-label input[type="file"] { font-size: 13px; }

.user-list { display: flex; flex-direction: column; gap: 6px; max-width: 500px; }
.user-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px;
}
.user-item__info { display: flex; gap: 12px; align-items: center; }
.user-item__role { font-size: 11px; color: var(--muted); text-transform: uppercase; }

/* ── Utilities ───────────────────────────── */
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Responsive ──────────────────────────── */
@media (max-width: 768px) {
  .review-layout { flex-direction: column; }
  .review-layout__viewer { min-height: 45vh; }
  .review-layout__panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 45vh;
  }
  .asset-grid { grid-template-columns: 1fr; }
  .topbar { padding: 8px 12px; }
  .actions { gap: 4px; }
  .btn { font-size: 12px; padding: 0 8px; height: 32px; }
}

@media (max-width: 480px) {
  .login-card { padding: 20px; }
  .viewer-toolbar { bottom: 8px; padding: 4px 6px; gap: 4px; }
}
