/* Lead Collector — premium dark UI for iPad Safari (IAPA trade fair booth tool) */

:root {
  --bg: #0a0f18;
  --bg-glow: #121a2b;
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-bg-strong: rgba(255, 255, 255, 0.07);
  --text: #f2f4f8;
  --text-dim: rgba(242, 244, 248, 0.62);
  --text-faint: rgba(242, 244, 248, 0.38);
  --accent: #5fd0a3;
  --accent-strong: #45c393;
  --danger: #ff6b6b;
  --warn: #f5b942;
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --status-new: #4c8dff;
  --status-contacted: #f0a93b;
  --status-replied: #4fd07a;
  --status-meeting: #b18bff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 900px 700px at 50% -10%, rgba(95, 208, 163, 0.10), transparent 60%),
    radial-gradient(ellipse 800px 600px at 100% 100%, rgba(120, 140, 255, 0.08), transparent 55%),
    var(--bg);
  overflow: hidden;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

a { color: inherit; text-decoration: none; }

#app {
  position: relative;
  width: 100%;
  height: 100dvh;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding-top: calc(var(--safe-top) + 16px);
  padding-bottom: calc(var(--safe-bottom) + 16px);
  padding-left: calc(var(--safe-left) + 20px);
  padding-right: calc(var(--safe-right) + 20px);
}

.view.active { display: flex; }

/* ---------- HOME ---------- */

#view-home {
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    linear-gradient(rgba(10, 15, 24, 0.82), rgba(10, 15, 24, 0.66)),
    url("assets/background.jpg") center / cover no-repeat,
    #0A0F18;
}

.home-stack {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.logo-card {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 34px 24px;
  min-height: 120px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.logo-card:active { transform: scale(0.98); background: var(--glass-bg-strong); }

.logo-card img {
  width: 60%;
  max-height: 64px;
  object-fit: contain;
  display: block;
}

.handshake-btn {
  position: fixed;
  top: calc(var(--safe-top) + 14px);
  right: calc(var(--safe-right) + 14px);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.32;
  z-index: 5;
}

.handshake-btn:active { opacity: 0.6; }
.handshake-btn svg { width: 24px; height: 24px; }

.home-footer {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 12px);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.home-footer img {
  height: 30px;
  width: auto;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  padding: 5px 10px;
  box-sizing: content-box;
  opacity: 0.85;
}

/* ---------- SHARED: back button, headers ---------- */

.back-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 12px;
}

.back-btn svg { width: 20px; height: 20px; }
.back-btn:active { background: var(--glass-bg-strong); }

.view-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  margin: 0 0 14px 0;
}

/* ---------- LOGIN ---------- */

#view-login {
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 32px 26px;
  position: absolute;
}

.login-card h1 {
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 20px 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

input:focus, textarea:focus, select:focus {
  border-color: rgba(95, 208, 163, 0.5);
  background: rgba(255, 255, 255, 0.07);
}

textarea { resize: none; min-height: unset; }

.primary-btn {
  width: 100%;
  min-height: 52px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(95, 208, 163, 0.4);
  background: linear-gradient(180deg, rgba(95, 208, 163, 0.22), rgba(95, 208, 163, 0.12));
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  margin-top: 6px;
}

.primary-btn:active { background: rgba(95, 208, 163, 0.28); }

.error-text {
  color: var(--danger);
  font-size: 13px;
  min-height: 16px;
  margin: 8px 0 0 0;
}

/* ---------- CAPTURE ---------- */

#view-capture { overflow-y: auto; align-items: stretch; }

.capture-scroll {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding-bottom: 20px;
}

#capture-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.photo-btn {
  width: 100%;
  min-height: 130px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--glass-border);
  background: var(--glass-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
  position: relative;
}

.photo-btn svg { width: 30px; height: 30px; opacity: 0.7; }

.photo-btn span { font-size: 13px; color: var(--text-dim); }

.photo-btn img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.retake-link {
  align-self: center;
  font-size: 13px;
  color: var(--accent);
  padding: 6px 10px;
  margin-top: -8px;
}

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.chip-row { display: flex; gap: 10px; flex-wrap: wrap; }

.chip {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  font-size: 14px;
  color: var(--text-dim);
}

.chip.selected {
  border-color: rgba(95, 208, 163, 0.55);
  background: rgba(95, 208, 163, 0.18);
  color: var(--text);
}

.stars-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 6px 0;
}

.star {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  font-size: 28px;
  color: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}

.star.filled { color: #f5c94c; }

.save-btn { margin-top: 4px; }

.leads-link-row {
  text-align: center;
  padding: 16px 0 4px 0;
}

.leads-link-row a {
  font-size: 14px;
  color: var(--text-dim);
  padding: 10px;
}

/* ---------- LEADS ---------- */

#view-leads { overflow: hidden; }

.leads-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 10px;
  flex-shrink: 0;
}

.leads-toprow {
  display: flex;
  align-items: center;
  gap: 10px;
}

.leads-toprow input[type="search"] { flex: 1; min-height: 44px; }

.export-btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}

.pill-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.pill {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.pill.active {
  background: rgba(95, 208, 163, 0.18);
  border-color: rgba(95, 208, 163, 0.5);
  color: var(--text);
}

.leads-count {
  font-size: 12px;
  color: var(--text-faint);
}

.leads-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 20px;
}

.lead-card {
  display: flex;
  gap: 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.lead-thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lead-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lead-thumb svg { width: 22px; height: 22px; opacity: 0.3; }

.lead-body { flex: 1; min-width: 0; }

.lead-top-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.lead-name { font-size: 15px; font-weight: 600; }
.lead-time { font-size: 11px; color: var(--text-faint); white-space: nowrap; }

.lead-company { font-size: 13px; color: var(--text-dim); margin-top: 1px; }

.lead-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.lead-stars { font-size: 13px; color: #f5c94c; letter-spacing: 1px; }

.status-badge {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-badge.new { background: rgba(76, 141, 255, 0.18); color: var(--status-new); }
.status-badge.contacted { background: rgba(240, 169, 59, 0.18); color: var(--status-contacted); }
.status-badge.replied { background: rgba(79, 208, 122, 0.18); color: var(--status-replied); }
.status-badge.meeting { background: rgba(177, 139, 255, 0.18); color: var(--status-meeting); }

.interest-tag {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
}

.lead-details {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lead-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.lead-action-btn {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  color: var(--text-dim);
}

.lead-action-btn.danger { color: var(--danger); }

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

.empty-state {
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  padding: 40px 20px;
}

/* ---------- Overlays ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 15, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}

.modal-overlay[hidden] { display: none; }

.modal-card {
  width: 100%;
  max-width: 340px;
  background: rgba(20, 26, 38, 0.92);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 26px 22px;
  text-align: center;
}

.modal-card p { font-size: 15px; line-height: 1.5; margin: 0 0 18px 0; }

.modal-actions { display: flex; gap: 10px; }

.modal-actions button {
  flex: 1;
  min-height: 46px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  font-size: 14px;
  font-weight: 600;
}

.modal-actions button.confirm-affirm {
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.14);
  color: var(--danger);
}

.modal-actions button.confirm-primary {
  border-color: rgba(95, 208, 163, 0.45);
  background: rgba(95, 208, 163, 0.16);
}

/* PIN overlay */

#pin-overlay { background: rgba(6, 9, 15, 0.97); flex-direction: column; }

.pin-card {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.pin-title { font-size: 15px; color: var(--text-dim); }

.pin-dots { display: flex; gap: 16px; }

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: transparent;
}

.pin-dot.filled { background: var(--accent); border-color: var(--accent); }
.pin-dot.error { background: var(--danger); border-color: var(--danger); }

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 68px);
  gap: 14px;
}

.pin-key {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  font-size: 22px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pin-key:active { background: var(--glass-bg-strong); }
.pin-key.pin-key-ghost { border: none; background: transparent; }

.pin-cancel-btn {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-faint);
  padding: 10px 16px;
  background: transparent;
  border: none;
}

/* Photo viewer */

#photo-viewer { background: rgba(4, 6, 10, 0.95); flex-direction: column; gap: 16px; }
#photo-viewer img { max-width: 100%; max-height: 78vh; border-radius: var(--radius-md); object-fit: contain; }
.viewer-close-btn {
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  font-size: 14px;
}

/* Edit bottom sheet */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 15, 0.6);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-overlay[hidden] { display: none; }

.sheet-card {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  background: rgba(16, 21, 31, 0.98);
  border: 1px solid var(--glass-border);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding: 22px 22px calc(24px + var(--safe-bottom)) 22px;
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--glass-border);
  margin: 0 auto 18px auto;
}

.sheet-title { font-size: 16px; font-weight: 600; margin: 0 0 16px 0; }

.sheet-actions { display: flex; gap: 10px; margin-top: 8px; }
.sheet-actions button { flex: 1; }

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 24px);
  transform: translateX(-50%);
  background: rgba(20, 26, 38, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text);
  z-index: 100;
  max-width: 88vw;
  text-align: center;
}

.toast[hidden] { display: none; }

@media (max-width: 380px) {
  .pin-keypad { grid-template-columns: repeat(3, 60px); }
  .pin-key { width: 60px; height: 60px; }
}
