/* =============================================
   Northern Wolves AC — Shared Design System
   Inspired by BuildingConnected
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ---------- Design Tokens ---------- */
:root {
  --nw-primary: #0696D7;
  --nw-success: #5D822C;
  --nw-danger: #A61A1A;
  --nw-text: #3C3C3C;
  --nw-muted: #999999;
  --nw-border: #CCCCCC;
  --nw-bg: #F5F5F5;
  --nw-card: #FFFFFF;
  --nw-accent: #f59e0b;
  --nw-dark: #1a2332;
  --nw-section: #f8f8f8;
  --nw-radius-btn: 2px;
  --nw-radius-card: 4px;
  --nw-radius-pill: 9999px;
  --nw-border-width: 1.25px;
  --nw-font-base: 14px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--nw-font-base);
  background: var(--nw-bg);
  color: var(--nw-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  line-height: 1.5;
}

/* ---------- Header ---------- */
.header {
  background: var(--nw-card);
  border-bottom: var(--nw-border-width) solid var(--nw-border);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-btn {
  color: var(--nw-primary);
  text-decoration: none;
  font-size: 22px;
  padding: 4px 8px;
  flex-shrink: 0;
  line-height: 1;
}

.back-btn:hover {
  opacity: 0.7;
}

.header img {
  height: 36px;
  width: auto;
  flex-shrink: 0;
}

.header-content {
  flex: 1;
  min-width: 0;
}

.header h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--nw-text);
  line-height: 1.2;
}

.header .subtitle {
  font-size: 11px;
  color: var(--nw-primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

.header .report-id {
  font-size: 11px;
  color: var(--nw-muted);
  margin-top: 2px;
}

/* ---------- Card ---------- */
.card {
  background: var(--nw-card);
  border: var(--nw-border-width) solid var(--nw-border);
  border-radius: var(--nw-radius-card);
  padding: 16px;
  transition: border-color 0.15s ease;
  cursor: pointer;
  text-decoration: none;
  color: var(--nw-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.card:hover,
.card:active {
  border-color: var(--nw-primary);
}

/* ---------- Grid ---------- */
.grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
}

/* ---------- Section ---------- */
.section {
  background: var(--nw-card);
  margin: 12px;
  border-radius: var(--nw-radius-card);
  overflow: hidden;
  border: var(--nw-border-width) solid var(--nw-border);
}

.section-header {
  background: var(--nw-card);
  color: var(--nw-text);
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  border-left: 3px solid var(--nw-primary);
}

.section-header .icon {
  font-size: 16px;
}

.section-header .collapse-arrow {
  margin-left: auto;
  transition: transform 0.2s;
  font-size: 10px;
  color: var(--nw-muted);
}

.section-header.collapsed .collapse-arrow {
  transform: rotate(-90deg);
}

.section-body {
  padding: 16px;
}

.section-body.collapsed {
  display: none;
}

/* ---------- Form Fields ---------- */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--nw-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: var(--nw-border-width) solid var(--nw-border);
  border-radius: var(--nw-radius-btn);
  font-size: var(--nw-font-base);
  font-family: inherit;
  color: var(--nw-text);
  background: var(--nw-card);
  transition: border-color 0.15s ease;
  -webkit-appearance: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--nw-primary);
}

.field textarea {
  min-height: 80px;
  resize: vertical;
}

.field select {
  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='%23999999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ---------- Row Layout ---------- */
.row {
  display: flex;
  gap: 10px;
}

.row .field {
  flex: 1;
}

/* ---------- Check Groups ---------- */
.check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--nw-section);
  padding: 8px 12px;
  border-radius: var(--nw-radius-btn);
  border: var(--nw-border-width) solid var(--nw-border);
  cursor: pointer;
  font-size: var(--nw-font-base);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.check-item.selected {
  border-color: var(--nw-primary);
  background: #e8f4fd;
}

.check-item input {
  display: none;
}

/* ---------- Readings Table ---------- */
.readings-table {
  width: 100%;
  border-collapse: collapse;
}

.readings-table th {
  background: var(--nw-primary);
  color: #ffffff;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
}

.readings-table td {
  padding: 6px 8px;
  border-bottom: var(--nw-border-width) solid var(--nw-border);
}

.readings-table td:first-child {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.readings-table input {
  width: 100%;
  padding: 8px;
  border: var(--nw-border-width) solid var(--nw-border);
  border-radius: var(--nw-radius-btn);
  font-size: var(--nw-font-base);
  font-family: inherit;
  text-align: center;
  background: var(--nw-section);
}

.readings-table input:focus {
  border-color: var(--nw-primary);
  background: var(--nw-card);
  outline: none;
}

/* ---------- Offline Banner ---------- */
.offline-banner {
  display: none;
  background: #fef3c7;
  color: #92400e;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid #fcd34d;
}
.offline-banner.show { display: block; }

/* ---------- Photo Capture ---------- */
.photo-area {
  border: 2px dashed var(--nw-border);
  border-radius: var(--nw-radius-card);
  padding: 20px;
  text-align: center;
  background: var(--nw-section);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.photo-area:hover {
  border-color: var(--nw-primary);
}

.photo-area .icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.photo-area p {
  font-size: 13px;
  color: var(--nw-muted);
}

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.photo-thumb {
  position: relative;
  display: inline-block;
}

.photo-preview img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--nw-radius-card);
  border: var(--nw-border-width) solid var(--nw-border);
}

.remove-photo {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--nw-danger);
  color: #ffffff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  border: 2px solid #ffffff;
  line-height: 1;
}

/* ---------- Signature ---------- */
.sig-container {
  position: relative;
}

.sig-canvas {
  width: 100%;
  height: 150px;
  border: var(--nw-border-width) solid var(--nw-border);
  border-radius: var(--nw-radius-card);
  background: #ffffff;
  touch-action: none;
  cursor: crosshair;
}

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

.sig-label {
  font-size: 11px;
  color: var(--nw-muted);
  text-align: center;
  margin-top: 4px;
}

/* ---------- Buttons ---------- */
.btn {
  padding: 12px 20px;
  border: none;
  border-radius: var(--nw-radius-btn);
  font-size: var(--nw-font-base);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  text-decoration: none;
  line-height: 1.2;
}

.btn:hover {
  opacity: 0.85;
}

.btn-primary {
  background: var(--nw-primary);
  color: #ffffff;
}

.btn-secondary {
  background: var(--nw-section);
  color: var(--nw-text);
  border: var(--nw-border-width) solid var(--nw-border);
}

.btn-outline {
  background: transparent;
  border: var(--nw-border-width) solid var(--nw-border);
  color: var(--nw-muted);
}

.btn-success {
  background: var(--nw-success);
  color: #ffffff;
}

.btn-danger {
  background: var(--nw-danger);
  color: #ffffff;
}

/* ---------- Bottom Bar ---------- */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--nw-card);
  padding: 12px 16px;
  border-top: var(--nw-border-width) solid var(--nw-border);
  display: flex;
  gap: 10px;
  z-index: 100;
}

.bottom-bar .btn {
  flex: 1;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--nw-dark);
  color: #ffffff;
  padding: 10px 24px;
  border-radius: var(--nw-radius-card);
  font-size: var(--nw-font-base);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* ---------- Autosave Indicator ---------- */
.autosave-indicator {
  position: fixed;
  top: 56px;
  right: 12px;
  font-size: 11px;
  color: var(--nw-success);
  font-weight: 600;
  z-index: 101;
  opacity: 0;
  transition: opacity 0.3s;
}

.autosave-indicator.show {
  opacity: 1;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--nw-radius-pill);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.4;
}

.badge-draft {
  background: #fef3c7;
  color: #92400e;
}

.badge-completed {
  background: #e8f5e0;
  color: #3d6b1a;
}

.badge-submitted {
  background: #dbeafe;
  color: #1e40af;
}

.badge-reviewed {
  background: #ede9fe;
  color: #6d28d9;
}

.badge-rejected {
  background: #fee2e2;
  color: #991b1b;
}

/* ---------- Stats Bar ---------- */
.stats-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--nw-border);
  border: var(--nw-border-width) solid var(--nw-border);
  border-radius: var(--nw-radius-card);
  overflow: hidden;
}

.stat {
  background: var(--nw-card);
  padding: 14px 12px;
  text-align: center;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--nw-text);
  line-height: 1.2;
}

.stat-label {
  font-size: 11px;
  color: var(--nw-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ---------- Activity Item ---------- */
.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: var(--nw-border-width) solid var(--nw-border);
}

.activity-item:last-child {
  border-bottom: none;
}

/* ---------- Clean Table ---------- */
.table-clean {
  width: 100%;
  border-collapse: collapse;
}

.table-clean th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--nw-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: var(--nw-border-width) solid var(--nw-border);
}

.table-clean td {
  padding: 10px 12px;
  font-size: var(--nw-font-base);
  border-bottom: var(--nw-border-width) solid var(--nw-border);
}

.table-clean tr:hover {
  background: var(--nw-section);
}

/* ---------- Status Tabs ---------- */
.status-tabs {
  display: flex;
  border-bottom: var(--nw-border-width) solid var(--nw-border);
  background: var(--nw-card);
  padding: 0 16px;
}

.status-tabs .tab {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--nw-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  user-select: none;
}

.status-tabs .tab:hover {
  color: var(--nw-text);
}

.status-tabs .tab.active {
  color: var(--nw-primary);
  border-bottom-color: var(--nw-primary);
}

.status-tabs .tab .count {
  display: inline-block;
  background: var(--nw-section);
  color: var(--nw-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--nw-radius-pill);
  margin-left: 4px;
}

.status-tabs .tab.active .count {
  background: #e8f4fd;
  color: var(--nw-primary);
}

/* ---------- Search Bar ---------- */
.search-bar {
  padding: 12px 16px;
  background: var(--nw-card);
  border-bottom: var(--nw-border-width) solid var(--nw-border);
}

.search-bar input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: var(--nw-border-width) solid var(--nw-border);
  border-radius: var(--nw-radius-btn);
  font-size: var(--nw-font-base);
  font-family: inherit;
  color: var(--nw-text);
  background: var(--nw-section) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999999' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 12px center;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--nw-primary);
  background-color: var(--nw-card);
}

.search-bar input::placeholder {
  color: var(--nw-muted);
}

/* ---------- Install Banner ---------- */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--nw-card);
  border-top: var(--nw-border-width) solid var(--nw-border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

/* ---------- Profile Circle ---------- */
.profile-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--nw-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--nw-card);
  border-radius: var(--nw-radius-card);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--nw-muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state p {
  font-size: var(--nw-font-base);
  line-height: 1.5;
}

/* ---------- Responsive: 600px ---------- */
@media (max-width: 600px) {
  .grid {
    grid-template-columns: 1fr 1fr;
    padding: 12px;
    gap: 10px;
  }

  .stats-bar {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .table-clean th,
  .table-clean td {
    padding: 8px 10px;
    font-size: 13px;
  }

  .status-tabs .tab {
    padding: 10px 12px;
    font-size: 12px;
  }

  .modal {
    margin: 16px;
    padding: 20px;
  }
}

/* ---------- Responsive: 400px ---------- */
@media (max-width: 400px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .row {
    flex-direction: column;
    gap: 0;
  }

  .section {
    margin: 8px;
  }

  .header h1 {
    font-size: 14px;
  }

  .stat-value {
    font-size: 18px;
  }
}
