/* Walkthrough Capture System — Mobile-first styles */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 600px; margin: 0 auto; padding: 1rem; }

/* Header */
.header {
  background: var(--primary);
  color: #fff;
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1 { font-size: 1.25rem; font-weight: 600; }
.header .subtitle { font-size: .85rem; opacity: .85; margin-top: .25rem; }

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.card h2 { font-size: 1.1rem; margin-bottom: .5rem; }
.card h3 { font-size: 1rem; margin-bottom: .5rem; color: var(--text-muted); }

/* Buttons */
button, .btn {
  position: relative;
  z-index: 1;
  pointer-events: auto;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  font-family: inherit;
  color: inherit;
}
a.btn { display: inline-flex; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
select, input[type="text"], input[type="password"], input[type="number"], input[type="email"] {
  display: block;
  width: 100%;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: .75rem;
  background: #fff;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  cursor: text;
  position: relative;
  z-index: 1;
}
select {
  cursor: pointer;
  -webkit-appearance: menulist;
  appearance: menulist;
}
textarea {
  display: block;
  width: 100%;
  padding: .5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .9rem;
  font-family: inherit;
  resize: vertical;
  background: #fff;
  color: var(--text);
}

/* Room list */
.room-list { list-style: none; }
.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem;
  border-bottom: 1px solid var(--border);
}
.room-item:last-child { border-bottom: none; }
.room-status {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
}
.room-status.pending { background: var(--border); }
.room-status.processing { background: var(--warning); }
.room-status.passed { background: var(--success); }
.room-status.failed { background: var(--danger); }
.room-status.needs_coverage { background: var(--warning); }

/* Image grid */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: .5rem;
  margin: .75rem 0;
}
.image-grid img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid transparent;
}
.image-grid img.quality-passed { border-color: var(--success); }
.image-grid img.quality-failed { border-color: var(--danger); }
.image-grid img.quality-pending { border-color: var(--border); }
.image-grid img.quality-warning { border-color: var(--warning); }
.thumb-wrapper img.quality-passed { border-color: var(--success); }
.thumb-wrapper img.quality-failed { border-color: var(--danger); }
.thumb-wrapper img.quality-pending { border-color: var(--border); }
.thumb-wrapper img.quality-warning { border-color: var(--warning); }
.thumb-wrapper {
  position: relative;
}
.thumb-wrapper img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid transparent;
}
.delete-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

/* Camera viewfinder */
.viewfinder {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}
.viewfinder video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.viewfinder canvas { display: none; }
.viewfinder .guide-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}

/* Ghost reference overlay */
#ghost-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.15;
  pointer-events: none;
  z-index: 5;
  transition: opacity .2s ease;
}
#ghost-toggle {
  position: absolute;
  top: .5rem;
  right: .5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.5);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
#ghost-toggle:hover { background: rgba(0,0,0,.7); }
.ghost-toggle-off { opacity: .4; }

/* Guide position indicator */
.guide-label {
  position: absolute;
  bottom: .5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.7);
  color: #fff;
  padding: .25rem .75rem;
  border-radius: 4px;
  font-size: .85rem;
  white-space: nowrap;
}

/* Status badge */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fce4ec; color: #b71c1c; }
.badge-info { background: #e0e7ff; color: #3730a3; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-ai-success { background: #d1fae5; color: #065f46; }

/* Quality rejection reasons */
.quality-reasons {
  margin-top: .5rem;
  padding: .5rem .75rem;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
}
.quality-reason {
  padding: .35rem 0;
  font-size: .85rem;
  line-height: 1.4;
}
.quality-reason + .quality-reason {
  border-top: 1px solid #fecaca;
}
.quality-tip {
  margin-top: .25rem;
  padding: .3rem .5rem;
  background: #eff6ff;
  border-radius: 4px;
  font-size: .8rem;
  color: #1e40af;
}

/* Coverage bar */
.coverage-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin: .5rem 0;
}
.coverage-bar .fill {
  height: 100%;
  background: var(--success);
  transition: width .3s ease;
  border-radius: 4px;
}

/* Comparison */
.comparison-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin: .75rem 0;
}
.comparison-pair img {
  width: 100%;
  border-radius: 4px;
}
.comparison-pair .label {
  font-size: .75rem;
  color: var(--text-muted);
  text-align: center;
}

/* Loading spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Spotlight overlay for comparison */
.spotlight-container {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  margin: .5rem 0;
}
.spotlight-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
}
.spotlight-ring {
  pointer-events: none;
  z-index: 2;
}

/* Context box */
.context-box {
  margin-top: .5rem;
}
.context-box textarea {
  width: 100%;
  padding: .5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .9rem;
  resize: vertical;
  font-family: inherit;
}

/* Close-up prompt */
.closeup-prompt {
  animation: fadeIn .3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Report review */
.report-room-header {
  font-size: 1.1rem;
  font-weight: 600;
  padding: .75rem 0 .25rem;
  border-bottom: 2px solid var(--primary);
  margin-bottom: .75rem;
}
.position-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
}
.position-item:last-child { border-bottom: none; }
.check-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.check-icon.pass { background: #dcfce7; color: #166534; }
.check-icon.fail { background: #fce4ec; color: #b71c1c; }

.discrepancy-card {
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: .75rem;
  margin: .5rem 0;
  background: #fffbeb;
}
.discrepancy-card.accepted {
  border-color: var(--danger);
  background: #fef2f2;
}
.discrepancy-card.deleted {
  border-color: var(--border);
  background: var(--bg);
  opacity: .5;
}

.cost-input {
  width: 120px;
  padding: .4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .9rem;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  margin: .75rem 0;
}
.summary-table td {
  padding: .5rem;
  border-bottom: 1px solid var(--border);
}
.summary-table td:last-child {
  text-align: right;
  font-weight: 600;
}
.summary-table tr:last-child td {
  border-bottom: 2px solid var(--text);
  font-size: 1.1rem;
}

/* Utilities */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: .5rem; }
.hidden { display: none !important; }
