/* ============================================
   User-facing pages — Login, Register, Profile
   ============================================ */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e4e6ee;
  --text: #1a1d29;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --danger: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.12);
  --radius: 10px;
  --radius-lg: 14px;
  --transition: all .15s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: .9rem; }
.required { color: var(--danger); }
.optional { color: var(--text-muted); font-weight: 400; font-size: .8rem; }

code {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .85rem;
}

/* ============================================
   AUTH PAGES (login + register)
   ============================================ */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .4s ease;
}
.auth-card-wide { max-width: 520px; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-logo { text-align: center; margin-bottom: 16px; }

.logo-circle {
  width: 64px; height: 64px;
  margin: 0 auto;
  border-radius: 16px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700;
  box-shadow: 0 8px 16px rgba(99, 102, 241, .3);
}
.logo-circle.small {
  width: 36px; height: 36px;
  border-radius: 8px;
  font-size: 16px;
}

.auth-card h1 {
  text-align: center;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: .95rem;
}

.footer-text {
  text-align: center;
  margin-top: 22px;
  font-size: .9rem;
  color: var(--text-muted);
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: .85rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.auth-divider span { padding: 0 12px; }

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group { margin-bottom: 18px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-row .form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  background: var(--surface);
  transition: var(--transition);
  font-family: inherit;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
input.invalid {
  border-color: var(--danger);
}
input.invalid:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}

.password-wrapper { position: relative; }
.toggle-password {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer;
  padding: 6px 10px;
  font-size: 1.1rem;
  opacity: .6;
  border-radius: 6px;
}
.toggle-password:hover { opacity: 1; background: var(--bg); }

.password-strength {
  margin-top: 8px;
  display: flex; align-items: center; gap: 10px;
}
.strength-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.strength-fill {
  height: 100%;
  width: 0%;
  background: var(--danger);
  transition: width .2s ease, background .2s ease;
  border-radius: 2px;
}
.strength-fill.weak    { width: 25%; background: var(--danger);  }
.strength-fill.fair    { width: 50%; background: var(--warning); }
.strength-fill.good    { width: 75%; background: #3b82f6;        }
.strength-fill.strong  { width: 100%; background: var(--success); }
.strength-label { font-size: .75rem; min-width: 50px; }

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary, .btn-secondary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: .95rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 14px;
  font-size: .875rem;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-loader {
  width: 16px; height: 16px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   ALERTS
   ============================================ */
.error-message {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 14px;
}
.success-message {
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  color: #047857;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 14px;
}

/* ============================================
   PROFILE PAGE
   ============================================ */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.page {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 20px;
}

.profile-hero {
  text-align: center;
  margin-bottom: 28px;
}
.avatar-large {
  width: 96px; height: 96px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; font-weight: 700;
  box-shadow: 0 12px 28px rgba(99, 102, 241, .3);
}
.profile-hero h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
}
.card-body {
  padding: 8px 22px 22px;
}

.info-grid {
  display: flex;
  flex-direction: column;
}
.info-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.info-row:last-child { border-bottom: none; }
.info-row dt {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.info-row dd {
  font-size: .95rem;
  color: var(--text);
  word-break: break-word;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.badge-admin    { background: #ede9fe; color: #6d28d9; }
.badge-user     { background: #d1fae5; color: #047857; }
.badge-store    { background: #fed7aa; color: #c2410c; }
.badge-delivery { background: #fce7f3; color: #be185d; }
.badge-active   { background: #d1fae5; color: #047857; }
.badge-inactive { background: #fee2e2; color: #b91c1c; }

/* ============================================
   MAP MARKER (classic pin with logo)
   ============================================ */
.user-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateY(-4px);
}

.user-pin-label {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: .78rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.user-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.18));
}

.user-pin-head {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.user-pin-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-pin-logo-fallback {
  width: 100%;
  height: 100%;
  background: var(--primary-light);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.user-pin-tip {
  width: 16px;
  height: 16px;
  background: #fff;
  border-right: 3px solid var(--primary);
  border-bottom: 3px solid var(--primary);
  transform: rotate(45deg);
  margin-top: -6px;
  border-bottom-right-radius: 3px;
}

/* ============================================
   MAP MARKER (store pin for nearby page)
   ============================================ */
.store-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateY(-4px);
}

.store-pin-label {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: .78rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.store-pin-label-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.store-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 8px;
}

.store-status-dot.open {
  background: var(--success);
}

.store-status-dot.closed {
  background: var(--danger);
}

.store-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.18));
}

.store-pin-head {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.store-pin-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.store-pin-logo-fallback {
  width: 100%;
  height: 100%;
  background: var(--primary-light);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.store-pin-tip {
  width: 16px;
  height: 16px;
  background: #fff;
  border-right: 3px solid var(--primary);
  border-bottom: 3px solid var(--primary);
  transform: rotate(45deg);
  margin-top: -6px;
  border-bottom-right-radius: 3px;
}

/* ============================================
   NEARBY STORES EXPERIMENT
   ============================================ */
.nearby-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.nearby-item {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.nearby-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.nearby-item.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.nearby-item-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

/* ============================================
   TOAST
   ============================================ */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 14px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  z-index: 200;
  animation: slideIn .3s ease;
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.toast.success { background: var(--success); color: #fff; }
.toast.error   { background: var(--danger); color: #fff; }
.toast.info    { background: var(--primary); color: #fff; }

/* ============================================
   Rank card (profile)
   ============================================ */
.rank-card {
  border: 1px solid var(--border);
  overflow: hidden;
}
.rank-card .card-body {
  animation: rankFadeIn 0.5s ease;
}
@keyframes rankFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 600px) {
  .auth-card { padding: 28px 24px; }
  .form-row { grid-template-columns: 1fr; }
  .info-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 12px 0;
  }
  .info-row dt { font-size: .72rem; }
  .avatar-large { width: 80px; height: 80px; font-size: 2rem; }
  .profile-hero h1 { font-size: 1.5rem; }
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  position: fixed; z-index: 1000; inset: 0;
  background: rgba(0,0,0,.45); display: flex;
  align-items: center; justify-content: center;
}
.modal-box {
  background: var(--card-bg); border-radius: 14px;
  width: 100%; max-width: 420px; margin: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  animation: modalIn .25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 20px 0;
}
.modal-header h3 { margin: 0; font-size: 1.15rem; }
.modal-body {
  padding: 16px 20px 20px;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}

/* ============================================
   VERIFICATION
   ============================================ */
.verification-badge-verified {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 12px;
  font-size: .75rem; font-weight: 600;
  background: #d1fae5; color: #047857;
}
.verification-badge-unverified {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 12px;
  font-size: .75rem; font-weight: 600;
  background: #fee2e2; color: #b91c1c;
}
.error-text {
  color: #dc2626; font-size: .85rem; text-align: center;
}
.success-text {
  color: #059669; font-size: .85rem; text-align: center;
}
.btn-sm {
  font-size: .8rem; padding: 5px 14px; border-radius: 6px;
  border: none; cursor: pointer; font-weight: 500;
}
