/* BauCheck — Mobile-first CSS */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --primary: #1a1a2e;
  --accent: #e94560;
  --accent2: #0f3460;
  --text: #1a1a2e;
  --text-light: #666;
  --border: #e0e0e0;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

/* Header */
.header {
  background: var(--primary);
  color: #fff;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1 { font-size: 20px; font-weight: 700; flex: 1; }
.header .back-btn {
  background: none; border: none; color: #fff;
  font-size: 28px; padding: 0 8px; cursor: pointer;
  line-height: 1;
}
.header .subtitle { font-size: 13px; opacity: 0.7; font-weight: 400; }

/* Content area */
.content {
  padding: 16px;
  padding-bottom: calc(100px + var(--safe-bottom));
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.card:active { transform: scale(0.98); }
.card-title { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.card-sub { font-size: 14px; color: var(--text-light); }
.card-badge {
  display: inline-block;
  background: var(--accent2);
  color: #fff;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
}
.card-count {
  float: right;
  background: var(--bg);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
}

/* Empty state */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty p { font-size: 15px; }

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: #c73350; }
.btn-secondary { background: var(--accent2); color: #fff; }
.btn-secondary:active { background: #0a2a4d; }
.btn-outline {
  background: none;
  border: 2px solid var(--border);
  color: var(--text);
}

/* Capture Toolbar (fixed bottom) */
.capture-bar {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 10px 8px;
  padding-bottom: calc(10px + var(--safe-bottom));
  gap: 6px;
  z-index: 100;
}
.capture-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 4px;
  border: none;
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.capture-btn:active { background: #ddd; }
.capture-btn .icon { font-size: 26px; }
.capture-btn.recording {
  background: var(--accent);
  color: #fff;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Form */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-light);
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 17px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent2);
}
.form-group textarea { min-height: 100px; resize: vertical; }

/* Trade select chips */
.trade-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.trade-chip {
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--card);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.trade-chip.active {
  background: var(--accent2);
  color: #fff;
  border-color: var(--accent2);
}

/* Media grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 12px;
}
.media-grid img,
.media-grid video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  background: #eee;
}
.media-thumb {
  position: relative;
}
.media-thumb .play-icon {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  pointer-events: none;
}

/* Finding card */
.finding-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.finding-card .trade-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
}
.finding-card .note { font-size: 15px; margin-top: 4px; }
.finding-card .voice { font-size: 14px; color: var(--text-light); font-style: italic; margin-top: 4px; }
.finding-card .meta { font-size: 12px; color: #999; margin-top: 6px; }

/* Trade colors */
.trade-elektro { background: #f39c12; }
.trade-bau { background: #e74c3c; }
.trade-sanitaer { background: #3498db; }
.trade-maler { background: #2ecc71; }
.trade-boden { background: #9b59b6; }
.trade-tischler { background: #e67e22; }
.trade-heizung { background: #e74c3c; }
.trade-allgemein { background: #95a5a6; }

/* Login */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  background: var(--primary);
  color: #fff;
}
.login-screen h1 { font-size: 32px; margin-bottom: 8px; }
.login-screen p { opacity: 0.7; margin-bottom: 40px; }
.pin-input {
  width: 200px;
  text-align: center;
  font-size: 32px;
  letter-spacing: 12px;
  padding: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 12px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  margin-bottom: 24px;
}
.pin-input:focus { outline: none; border-color: var(--accent); }
.login-error { color: var(--accent); margin-top: 12px; font-size: 15px; }

/* Add button (FAB) */
.fab {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(233,69,96,0.4);
  cursor: pointer;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Loading */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
}
.modal {
  background: var(--card);
  width: 100%;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px;
  padding-bottom: calc(24px + var(--safe-bottom));
  max-height: 85vh;
  overflow-y: auto;
}
.modal h2 { font-size: 20px; margin-bottom: 20px; }

/* Toast */
.toast {
  position: fixed;
  top: max(60px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* Fullscreen media view */
.fullscreen-media {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #000;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fullscreen-media img,
.fullscreen-media video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.fullscreen-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  z-index: 1;
}
