/* MyGate prototype — shared styles */
:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1b2330;
  --muted: #677084;
  --border: #e4e8f0;
  --primary: #2b59ff;
  --primary-dark: #1f44d6;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --pending: #fef3c7;
  --pending-text: #92400e;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 100px;
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
header.topbar .brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
}
header.topbar .brand .logo {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #6c8cff);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700;
}
header.topbar .who { color: var(--muted); font-size: 14px; }
header.topbar .who strong { color: var(--text); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.card h2 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.card h3 { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); font-size: 13px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 6px; font-weight: 500; }
input, select, textarea, button {
  font: inherit;
}
input[type="text"], input[type="tel"], input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #cfd8ff; border-color: var(--primary); }
textarea { min-height: 60px; resize: vertical; }

button {
  cursor: pointer;
  border: none;
  padding: 11px 16px;
  border-radius: 10px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s;
}
button:hover { background: var(--primary-dark); }
button.secondary { background: #eef1fa; color: var(--text); }
button.secondary:hover { background: #e2e7f5; }
button.danger { background: var(--danger); }
button.danger:hover { background: #b91c1c; }
button.success { background: var(--success); }
button.success:hover { background: #15803d; }
button.ghost { background: transparent; color: var(--primary); padding: 8px 10px; }
button.full { width: 100%; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.tabs { display: flex; gap: 4px; background: #eef1fa; padding: 4px; border-radius: 12px; margin-bottom: 16px; }
.tabs button { background: transparent; color: var(--muted); flex: 1; padding: 10px; font-size: 14px; }
.tabs button.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }

.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge.active { background: #dcfce7; color: #166534; }
.badge.used { background: #e0e7ff; color: #3730a3; }
.badge.expired { background: #f3f4f6; color: #6b7280; }
.badge.cancelled { background: #fee2e2; color: #991b1b; }
.badge.pending { background: var(--pending); color: var(--pending-text); }
.badge.approved { background: #dcfce7; color: #166534; }
.badge.rejected { background: #fee2e2; color: #991b1b; }

.list-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  background: #fff;
}
.list-item .title { font-weight: 600; }
.list-item .meta { font-size: 13px; color: var(--muted); margin-top: 4px; }

.empty { color: var(--muted); padding: 24px; text-align: center; font-size: 14px; }

.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; }
.qr-wrap img { width: 240px; height: 240px; border-radius: 12px; }
.qr-info { text-align: center; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 12px 18px;
  border-radius: 10px; font-size: 14px; z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
  max-width: 90%;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.banner {
  background: var(--pending); color: var(--pending-text);
  padding: 12px 16px; border-radius: 12px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-weight: 600;
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 50;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; padding: 20px;
  max-width: 440px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal h2 { margin-top: 0; }
.modal .photo-preview { width: 100%; max-height: 240px; object-fit: contain; border-radius: 10px; background: #f6f7fb; margin-bottom: 12px; }

#scanner { width: 100%; max-width: 360px; margin: 0 auto; }
#scanner > div { border-radius: 12px; overflow: hidden; }

video { width: 100%; border-radius: 10px; background: #000; }

.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.role-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  cursor: pointer; background: #fff; text-align: left;
  transition: border-color 0.15s, transform 0.05s;
}
.role-card:hover { border-color: var(--primary); }
.role-card:active { transform: scale(0.98); }
.role-card .name { font-weight: 600; }
.role-card .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.section-title {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin: 16px 0 8px;
}

@media (max-width: 480px) {
  .role-grid { grid-template-columns: 1fr; }
}
