/* === PunchList Pro - shared styles === */

/* === Demo banner === */
.demo-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fef3c7;
  color: #78350f;
  border-bottom: 1px solid #fcd34d;
  padding: 9px 16px;
  font-size: 13px;
  line-height: 1.35;
}
.demo-banner svg { flex: 0 0 auto; color: #b45309; }
.demo-banner-text { flex: 1; }
.demo-banner-text strong { color: #78350f; font-weight: 700; }
.demo-banner-close {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: #78350f;
  font-size: 20px;
  line-height: 1;
  width: 28px; height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.demo-banner-close:hover { background: rgba(120, 53, 15, 0.12); }
@media (max-width: 480px) {
  .demo-banner { font-size: 12px; padding: 8px 12px; }
}


:root {
  --navy: #1a1a2e;
  --navy-soft: #2a2a4a;
  --coral: #e94560;
  --coral-dark: #c93350;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --critical: #dc2626;
  --major: #d97706;
  --minor: #ca8a04;
  --resolved: #16a34a;
  --in-progress: #2563eb;
  --bg: #f7f7fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --grey-pill: #e5e7eb;
  --grey-pill-text: #374151;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.45;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* === App header === */
.app-header {
  background: var(--navy);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-md);
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.3px;
}
.app-header .brand svg { width: 26px; height: 26px; }
.app-header .spacer { flex: 1; }
.app-header .back-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 8px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.app-header .back-btn:hover { background: rgba(255,255,255,0.16); }

/* === Container === */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: #f3f4f6; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--coral);
  color: #fff;
  border-color: var(--coral);
}
.btn-primary:hover { background: var(--coral-dark); border-color: var(--coral-dark); }
.btn-blue {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-blue:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
}
.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  border-radius: 8px;
}
.btn-danger {
  background: #fff;
  color: var(--critical);
  border: 1px solid var(--border);
}
.btn-danger:hover { background: #fee2e2; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* === Page-level title row === */
.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-title-row h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
.page-title-row .subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

/* === Project cards (dashboard) === */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.project-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  position: relative;
  transition: transform 0.08s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.project-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.project-card .card-name {
  font-weight: 700;
  font-size: 17px;
  line-height: 1.25;
  padding-right: 36px;
}
.project-card .card-meta {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.project-card .card-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
}
.project-card .delete-btn {
  position: absolute;
  top: 10px; right: 10px;
  background: transparent;
  border: none;
  color: var(--muted);
  width: 30px; height: 30px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.project-card .delete-btn:hover { background: #fee2e2; color: var(--critical); }

/* === Stat pills === */
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #f3f4f6;
  color: #374151;
}
.stat-pill.red { background: #fee2e2; color: #991b1b; }
.stat-pill.green { background: #dcfce7; color: #166534; }
.stat-pill.grey { background: #f3f4f6; color: #374151; }

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state svg {
  width: 80px; height: 80px;
  margin-bottom: 14px;
  opacity: 0.55;
}
.empty-state h3 { margin: 0 0 6px; color: var(--text); font-weight: 700; }
.empty-state p { margin: 0 0 18px; }

/* === Modal === */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 15, 30, 0.55);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  animation: modal-pop 0.18s ease;
}
@keyframes modal-pop {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 22px;
  width: 32px; height: 32px;
  border-radius: 6px;
  line-height: 1;
}
.modal-close:hover { background: #f3f4f6; }
.modal-body { padding: 18px; }
.modal-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  position: sticky; bottom: 0; background: #fff;
}

/* === Forms === */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-row input[type=text],
.form-row input[type=date],
.form-row textarea,
.form-row select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--text);
}
.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.form-row textarea { min-height: 80px; resize: vertical; }
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 480px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}
.required-mark { color: var(--coral); }

/* === Photo upload area === */
.photo-drop {
  width: 100%;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: #fafafa;
  padding: 22px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.photo-drop:hover { border-color: var(--blue); background: #f0f5ff; }
.photo-drop svg {
  width: 40px; height: 40px;
  margin-bottom: 8px;
  opacity: 0.7;
}
.photo-drop strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px; }
.photo-drop small { display: block; font-size: 12px; }
.photo-drop input[type=file] { display: none; }
.photo-preview {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
}
.photo-preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.photo-preview .change-photo {
  position: absolute;
  bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
}

/* === Project page header === */
.project-bar {
  background: var(--navy);
  color: #fff;
  padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-md);
}
.project-bar .info { flex: 1; min-width: 0; }
.project-bar .info .name {
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-bar .info .sub {
  font-size: 12px;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === Summary bar === */
.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.summary-cell {
  flex: 1 1 110px;
  text-align: center;
  padding: 6px 8px;
  border-right: 1px solid var(--border);
}
.summary-cell:last-child { border-right: none; }
.summary-cell .num {
  display: block;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
}
.summary-cell .label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 2px;
}
.summary-cell.critical .num { color: var(--critical); }
.summary-cell.major    .num { color: var(--major); }
.summary-cell.minor    .num { color: var(--minor); }
.summary-cell.resolved .num { color: var(--resolved); }
@media (max-width: 600px) {
  .summary-cell { flex: 1 1 30%; border-right: none; }
}

/* === Room accordion === */
.room {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}
.room-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}
.room-header:hover { background: #f9fafb; }
.room-header .chevron {
  transition: transform 0.2s;
  width: 18px; height: 18px;
  color: var(--muted);
}
.room.open .room-header .chevron { transform: rotate(90deg); }
.room-header .room-name {
  font-weight: 700;
  font-size: 15px;
  flex: 1;
  min-width: 0;
}
.room-header .room-floor {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.room-header .count {
  background: #f3f4f6;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--grey-pill-text);
}
.room-actions {
  display: flex;
  gap: 6px;
}
.room-body {
  padding: 0 14px 14px;
  display: none;
}
.room.open .room-body { display: block; }

/* === Defect grid === */
.defect-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 640px) {
  .defect-grid { grid-template-columns: 1fr; }
}
.defect-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.defect-photo {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #f3f4f6;
  cursor: zoom-in;
  overflow: hidden;
}
.defect-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.defect-photo .no-photo {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-size: 12px;
}
.defect-num {
  position: absolute;
  top: 8px; left: 8px;
  background: var(--navy);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}
.severity-badge {
  position: absolute;
  top: 8px; right: 8px;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.severity-badge.critical { background: var(--critical); }
.severity-badge.major    { background: var(--major); }
.severity-badge.minor    { background: var(--minor); }
.defect-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.defect-desc {
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}
.defect-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.trade-pill {
  background: var(--grey-pill);
  color: var(--grey-pill-text);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
.status-select {
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  background: #fff;
}
.status-select.open        { color: var(--open); border-color: #fecaca; background: #fef2f2; }
.status-select.in-progress { color: var(--in-progress); border-color: #bfdbfe; background: #eff6ff; }
.status-select.resolved    { color: var(--resolved); border-color: #bbf7d0; background: #f0fdf4; }
.defect-actions {
  margin-top: auto;
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.defect-actions .icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.defect-actions .icon-btn:hover { background: #f3f4f6; color: var(--text); }
.defect-actions .icon-btn.danger:hover { background: #fee2e2; color: var(--critical); }

/* === Toast === */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  animation: toast-in 0.2s ease;
  min-width: 180px;
  max-width: 90vw;
  text-align: center;
}
.toast.error { background: var(--critical); }
.toast.success { background: var(--resolved); }
@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* === Spinner overlay === */
.overlay {
  position: fixed; inset: 0;
  background: rgba(15, 15, 30, 0.55);
  display: none;
  align-items: center; justify-content: center;
  flex-direction: column;
  gap: 16px;
  z-index: 300;
  color: #fff;
}
.overlay.open { display: flex; }
.spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-sm {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Lightbox === */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 24px;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  border-radius: 6px;
}
.lightbox .close-btn {
  position: absolute;
  top: 16px; right: 16px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  font-size: 20px;
  display: inline-flex; align-items: center; justify-content: center;
}
.lightbox .close-btn:hover { background: rgba(255,255,255,0.25); }

/* === Confirm dialog === */
.confirm-text { color: var(--muted); margin: 0 0 8px; font-size: 14px; }

/* === Utilities === */
.flex { display: flex; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--muted); }
.hidden { display: none !important; }
