/* ==================================================
   PinMe — Modern UI v2.0
   ================================================== */

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

/* ---------- Design Tokens ---------- */
:root {
  /* Brand palette */
  --accent-50:  #eff6ff;
  --accent-100: #dbeafe;
  --accent-200: #bfdbfe;
  --accent-400: #60a5fa;
  --accent-500: #3b82f6;
  --accent-600: #2563eb;
  --accent-700: #1d4ed8;

  /* Neutrals */
  --text:         #0f172a;
  --body:         #334155;
  --muted:        #64748b;
  --muted-2:      #94a3b8;
  --border:       #e2e8f0;
  --border-strong:#cbd5e1;
  --surface:      #ffffff;
  --surface-2:    #f1f5f9;
  --surface-3:    #f8fafc;

  /* Semantics */
  --success-bg:  #f0fdf4; --success-text: #15803d; --success-border: #bbf7d0;
  --error-bg:    #fff1f2; --error-text:   #be123c;  --error-border:   #fecdd3;
  --warning-bg:  #fffbeb; --warning-text: #92400e;  --warning-border: #fde68a;

  /* Shape */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl:24px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15,23,42,.05);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 16px rgba(15,23,42,.08), 0 1px 4px rgba(15,23,42,.05);
  --shadow-lg: 0 12px 40px rgba(15,23,42,.12), 0 4px 12px rgba(15,23,42,.06);
  --shadow-btn: 0 2px 8px rgba(37,99,235,.25);

  /* Focus ring */
  --ring: 0 0 0 3px rgba(37,99,235,.22);

  /* Typography */
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Spacing scale */
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px;
  --sp-5:20px; --sp-6:24px; --sp-7:32px; --sp-8:40px;

  /* Transitions */
  --ease: cubic-bezier(.4,0,.2,1);
  --fast: .12s;
  --base: .18s;
}

/* ---------- Base ---------- */
html { scroll-behavior: smooth; }

html, body {
  min-height: 100vh;
  background: linear-gradient(135deg, #f0f4ff 0%, #f8faff 40%, #fff0fa 100%);
  background-attachment: fixed;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--body);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 40px);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Main Container ---------- */
.card-container,
.login-container,
.punch-container {
  width: min(600px, 100%);
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid rgba(255,255,255,.9);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(37,99,235,.04);
  padding: clamp(24px, 5vw, 44px);
}

/* ---------- Typography ---------- */
h1 {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.4px;
  margin-bottom: var(--sp-5);
  line-height: 1.25;
}
h1::after {
  content: "";
  display: block;
  width: 40px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-600), var(--accent-400));
  border-radius: 999px;
  margin-top: 10px;
}

h2 {
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 700;
  color: var(--text);
  margin: var(--sp-5) 0 var(--sp-3);
  letter-spacing: -.2px;
}

.sub {
  color: var(--muted);
  text-align: center;
  margin-bottom: var(--sp-4);
  font-size: 14px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.copyright {
  text-align: center;
  margin-top: var(--sp-5);
  color: var(--muted-2);
  font-size: 12px;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: var(--sp-5); }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
  letter-spacing: .1px;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  font-family: var(--font);
  font-size: 15px;
  padding: 11px 14px;
  background: var(--surface-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  transition: border-color var(--base) var(--ease),
              box-shadow var(--base) var(--ease),
              background var(--base) var(--ease);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
input:hover, select:hover, textarea:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-500);
  box-shadow: var(--ring);
  background: var(--surface);
}
input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}
textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

.help-text  { font-size: 12px; color: var(--muted);      margin-top: 5px; }
.error-text { font-size: 12px; color: var(--error-text);  margin-top: 5px; }
.is-invalid { border-color: var(--error-text) !important; box-shadow: 0 0 0 3px rgba(190,18,60,.15) !important; }

/* ---------- Buttons ---------- */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .1px;
  cursor: pointer;
  transition: transform var(--fast) var(--ease),
              box-shadow var(--base) var(--ease),
              background var(--base) var(--ease),
              border-color var(--base) var(--ease),
              opacity var(--base) var(--ease);
  white-space: nowrap;
  user-select: none;

  /* Default: slate */
  background: #1e293b;
  color: #fff;
  box-shadow: 0 1px 3px rgba(15,23,42,.18), 0 1px 2px rgba(15,23,42,.12);
}
button:hover, .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15,23,42,.22);
}
button:active, .btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(15,23,42,.12);
}
button:focus-visible, .btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
button:disabled, .btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

/* Variants */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-600) 0%, var(--accent-500) 100%);
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-700) 0%, var(--accent-600) 100%);
  box-shadow: 0 4px 16px rgba(37,99,235,.35);
}

.btn-secondary { background: #475569; }
.btn-secondary:hover { background: #334155; }

.btn-outline {
  background: transparent;
  color: var(--accent-700);
  border-color: var(--accent-300, #93c5fd);
  box-shadow: none;
}
.btn-outline:hover { background: var(--accent-50); border-color: var(--accent-500); }

.btn-ghost {
  background: transparent;
  color: var(--body);
  border-color: transparent;
  box-shadow: none;
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  box-shadow: 0 2px 8px rgba(220,38,38,.25);
}
.btn-danger:hover {
  background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
  box-shadow: 0 4px 14px rgba(220,38,38,.35);
}

.btn-success {
  background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
  box-shadow: 0 2px 8px rgba(22,163,74,.25);
}
.btn-success:hover { background: linear-gradient(135deg, #15803d 0%, #16a34a 100%); }

/* Pulse animation for Punch Out */
.pulse {
  background: linear-gradient(135deg, var(--accent-600) 0%, var(--accent-500) 100%);
  box-shadow: var(--shadow-btn);
  animation: pulse-ring 2.4s ease-in-out infinite;
}
@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 2px 8px rgba(37,99,235,.3); }
  50%       { box-shadow: 0 2px 8px rgba(37,99,235,.3), 0 0 0 6px rgba(37,99,235,.12); }
}

.btn-block { width: 100%; }
.buttons, .btn-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- Customer Cards ---------- */
.list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 2px;
}
.list::-webkit-scrollbar { width: 6px; }
.list::-webkit-scrollbar-track { background: transparent; }
.list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }

.card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--base) var(--ease),
              border-color var(--base) var(--ease),
              transform var(--fast) var(--ease);
}
.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent-200);
  transform: translateY(-1px);
}

.info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card .actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.card .actions .btn { min-width: 110px; font-size: 13px; padding: 9px 14px; }

/* Directions link as button */
a.btn.link {
  text-decoration: none;
  background: var(--surface-2);
  color: var(--accent-700);
  border-color: var(--border);
  box-shadow: none;
}
a.btn.link:hover {
  background: var(--accent-50);
  border-color: var(--accent-300, #93c5fd);
}

@media (max-width: 480px) {
  .card { flex-wrap: wrap; }
  .card .actions { width: 100%; justify-content: flex-end; }
  .card .actions .btn { flex: 1 1 auto; min-width: 0; }
}

/* ---------- Status ---------- */
.status {
  border-radius: var(--radius-md);
  padding: 11px 15px;
  font-size: 14px;
  font-weight: 500;
  min-height: 42px;
  display: flex;
  align-items: center;
  transition: background var(--base) var(--ease), border-color var(--base) var(--ease);
  border: 1.5px solid var(--border);
  background: var(--surface-3);
  color: var(--muted);
}
.status:empty { display: none; }
.status.loading { background: #f0f9ff; border-color: #bae6fd; color: #0369a1; }
.status.error   { background: var(--error-bg);   border-color: var(--error-border);   color: var(--error-text); }
.status.success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }

/* ---------- Toolbar & Search ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 6px 0 14px;
  flex-wrap: wrap;
}
.search { flex: 1; min-width: 160px; }
.search input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: var(--surface-3);
}
.search input:focus { border-color: var(--accent-500); box-shadow: var(--ring); outline: none; background: var(--surface); }

/* ---------- Dropdown ---------- */
.dropdown-wrap { position: relative; }

.dropdown-arrow {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid var(--muted-2);
  transform: translateY(-50%);
  transition: transform var(--base) var(--ease), border-top-color var(--base) var(--ease);
  pointer-events: none;
}
.dropdown-wrap.dropdown-open .dropdown-arrow {
  border-top-color: var(--accent-600);
  transform: translateY(-50%) rotate(180deg);
}

.dropdown-list {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  width: 100%;
  max-height: 280px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(.98);
  transform-origin: top center;
  transition: opacity var(--base) var(--ease), transform var(--base) var(--ease);
  z-index: 999;
}
.dropdown-list.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.dropdown-list .dropdown-item {
  padding: 11px 14px;
  cursor: pointer;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  transition: background var(--fast) var(--ease);
  user-select: none;
}
.dropdown-list .dropdown-item:last-child { border-bottom: none; }
.dropdown-list .dropdown-item:hover,
.dropdown-list .dropdown-item.highlighted {
  background: var(--accent-50);
  color: var(--accent-700);
}
.dropdown-list .no-results {
  padding: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Map ---------- */
#map {
  display: block;
  width: 100%;
  height: clamp(240px, 38vh, 480px);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: var(--sp-5);
}
#map iframe, #map > * {
  width: 100%; height: 100%;
  border: 0; display: block;
}

/* ---------- Login ---------- */
.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  user-select: none;
}
.remember-row input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent-600);
  cursor: pointer;
}
.remember-row label { margin: 0; font-size: 14px; cursor: pointer; }

.powered-by { text-align: center; margin-top: 12px; font-size: 12px; color: var(--muted); }
.powered-by a { color: var(--accent-700); text-decoration: none; font-weight: 600; }
.powered-by a:hover { text-decoration: underline; }

/* ---------- Assign-To row ---------- */
.assign-row { display: flex; flex-direction: column; gap: 2px; }
.assign-name { font-weight: 600; font-size: 14px; color: var(--text); }
.assign-email { font-size: 12px; color: var(--muted); }
.mini-status { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* ---------- Energy / Footer earn list ---------- */
.footer-earn { margin-top: 20px; }
.footer-earn .earn-list {
  list-style: none;
  padding: 0; margin: 6px 0 0;
}
.footer-earn .earn-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.footer-earn .earn-list li:last-child { border-bottom: 0; }
.footer-earn .earn-list li .label {
  position: relative;
  padding-left: 16px;
}
.footer-earn .earn-list li .label::before {
  content: "•";
  position: absolute; left: 0; top: 0;
  color: var(--muted-2);
}
.footer-earn .earn-pts { font-weight: 700; }

/* ---------- Helpers ---------- */
.top-right { position: absolute; top: 16px; right: 16px; }
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ---------- Mobile ---------- */
@media (max-width: 540px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .search { width: 100%; }
  .buttons, .btn-row { flex-direction: column; align-items: stretch; }
  .buttons .btn, .btn-row .btn, .toolbar .btn,
  button:not(.remove-entry), a.btn { width: 100%; min-width: 0; }
  .card .actions { width: 100%; }
  .card .actions .btn { flex: 1 1 auto; min-width: 0; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- Dark mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --text:         #f1f5f9;
    --body:         #cbd5e1;
    --muted:        #94a3b8;
    --muted-2:      #64748b;
    --border:       #1e2a3a;
    --border-strong:#273548;
    --surface:      #0f172a;
    --surface-2:    #0a1120;
    --surface-3:    #111827;
  }

  html, body {
    background: linear-gradient(135deg, #070d1a 0%, #0a0f1e 50%, #0e0717 100%);
  }

  .card-container,
  .login-container,
  .punch-container {
    background: rgba(15,23,42,.82);
    border-color: rgba(255,255,255,.06);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.03);
  }

  input[type="text"],
  input[type="password"],
  select, textarea, .search input {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
  }
  input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
  input[readonly] { background: #0a1120; color: var(--muted); }

  .card {
    background: #0f172a;
    border-color: var(--border);
  }
  .card:hover { border-color: rgba(96,165,250,.3); }

  .dropdown-list {
    background: #0f172a;
    border-color: var(--border);
  }
  .dropdown-list .dropdown-item { border-color: var(--border); }
  .dropdown-list .dropdown-item:hover,
  .dropdown-list .dropdown-item.highlighted {
    background: rgba(37,99,235,.15);
    color: var(--accent-200);
  }

  .status { background: var(--surface-2); border-color: var(--border); }
  .status.loading { background: #0c1e30; border-color: #1e4a6e; color: #7dd3fc; }

  a.btn.link {
    background: var(--surface-2);
    color: var(--accent-200);
    border-color: var(--border);
  }
  a.btn.link:hover { background: rgba(37,99,235,.12); border-color: var(--accent-500); }

  button, .btn { background: #1e293b; color: var(--text); }
}
