/* ---- CCR Job Photos — Netflix-style dark theme ---- */
:root {
  --bg: #0b0b0f;
  --bg-2: #14141b;
  --card: #1c1c26;
  --card-hi: #262633;
  --text: #f3f3f5;
  --muted: #9a9aa6;
  --accent: #e50914;       /* Netflix red */
  --accent-hi: #ff2330;
  --row-gap: 34px;
  --radius: 8px;
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.55);
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
img { display: block; }

/* ---------- Login ---------- */
.login {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1f1f2b 0%, var(--bg) 60%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: rgba(20, 20, 27, 0.92);
  border: 1px solid #2a2a36;
  border-radius: 12px;
  padding: 34px 28px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.login-brand { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.login-brand span, .brand span { color: var(--accent); }
.login-sub { color: var(--muted); margin: -6px 0 4px; font-size: 14px; }
.login-error { color: #ff6b6b; font-size: 13px; min-height: 16px; text-align: center; }

/* PIN pad */
.pin-dots {
  display: flex; justify-content: center; gap: 12px; min-height: 18px; margin: 4px 0 2px;
}
.pin-dots .dot {
  width: 13px; height: 13px; border-radius: 50%;
  background: #2c2c38; border: 1px solid #3a3a48; transition: all .12s;
}
.pin-dots .dot.filled { background: var(--accent); border-color: var(--accent); transform: scale(1.05); }
.keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 6px;
}
.key {
  background: #15151d; color: var(--text); border: 1px solid #2c2c38;
  border-radius: 12px; padding: 18px 0; font-size: 22px; font-weight: 600;
  transition: background .12s, transform .05s; user-select: none;
}
.key:hover { background: #20202b; }
.key:active { transform: scale(0.95); background: #2a2a38; }
.key-action { color: var(--muted); font-size: 20px; }
.key-enter { background: var(--accent); border-color: var(--accent); color: #fff; }
.key-enter:hover { background: var(--accent-hi); }

/* ---------- Top bar ---------- */
.app { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 clamp(14px, 4vw, 48px);
  background: linear-gradient(180deg, rgba(11,11,15,0.98) 0%, rgba(11,11,15,0.85) 100%);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #1d1d27;
}
.brand { font-size: 20px; font-weight: 800; letter-spacing: -0.4px; white-space: nowrap; cursor: pointer; }
.topbar-search { flex: 1; display: flex; justify-content: center; }
.topbar-search input {
  width: min(520px, 100%);
  background: #15151d; border: 1px solid #2c2c38; color: var(--text);
  border-radius: 999px; padding: 9px 16px; font-size: 14px; outline: none;
}
.topbar-search input:focus { border-color: #4a4a5a; background: #181820; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.ghost-btn {
  background: transparent; color: var(--muted); border: 1px solid #2c2c38;
  border-radius: 6px; padding: 8px 12px; font-size: 13px; transition: all .15s;
}
.ghost-btn:hover { color: var(--text); border-color: #44444f; }
#refresh-btn { font-size: 16px; padding: 7px 11px; }

/* ---------- Board / rows ---------- */
.board { padding: 22px 0 70px; }
.board-loading { text-align: center; color: var(--muted); padding: 60px; font-size: 15px; }

.row { margin-bottom: var(--row-gap); }
.row-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 0 clamp(14px, 4vw, 48px); margin-bottom: 12px;
}
.row-title { font-size: 19px; font-weight: 700; letter-spacing: -0.2px; }
.row-count {
  font-size: 12px; color: var(--muted);
  background: #1d1d28; border-radius: 999px; padding: 2px 9px;
}
.row-scroll {
  display: flex; gap: 12px; overflow-x: auto; overflow-y: hidden;
  padding: 4px clamp(14px, 4vw, 48px) 10px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin; scrollbar-color: #33333f transparent;
}
.row-scroll::-webkit-scrollbar { height: 8px; }
.row-scroll::-webkit-scrollbar-thumb { background: #2c2c38; border-radius: 8px; }
.row-scroll::-webkit-scrollbar-track { background: transparent; }

.row-empty { color: var(--muted); font-size: 14px; padding: 18px 0 22px; font-style: italic; }

/* ---------- Cards ---------- */
.card {
  flex: 0 0 auto; width: 230px;
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; scroll-snap-align: start;
  border: 1px solid transparent;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.card:hover {
  transform: translateY(-4px); border-color: #3a3a48; box-shadow: var(--shadow);
}
.card-thumb {
  position: relative; width: 100%; aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #20202b 0%, #16161e 100%);
  display: flex; align-items: center; justify-content: center;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-thumb.placeholder::after {
  content: "🏗"; font-size: 34px; opacity: 0.35;
}
.card-photocount {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.66); color: #fff; font-size: 11px;
  padding: 2px 7px; border-radius: 999px; backdrop-filter: blur(2px);
}
.card-body { padding: 11px 12px 13px; }
.card-name {
  font-size: 14px; font-weight: 650; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 36px;
}
.card-city { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.card-dates { font-size: 11.5px; color: #707080; margin-top: 6px; }

/* ---------- Detail overlay ---------- */
.detail {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(6,6,9,0.96); backdrop-filter: blur(6px);
  overflow-y: auto;
}
.detail-inner {
  max-width: 1180px; margin: 0 auto; padding: 26px clamp(14px, 4vw, 40px) 60px;
  position: relative;
}
.detail-close {
  position: sticky; float: right; top: 8px;
  background: #1c1c26; color: var(--text); border: 1px solid #33333f;
  width: 38px; height: 38px; border-radius: 50%; font-size: 16px; z-index: 2;
}
.detail-close:hover { background: var(--accent); border-color: var(--accent); }
.detail-head { padding: 12px 0 18px; }
.detail-head h2 { margin: 0 0 8px; font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.detail-meta { color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.detail-meta a { color: #8ab4ff; text-decoration: none; }

.tabs {
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid #23232e; margin-bottom: 20px;
}
.tab {
  background: transparent; border: none; color: var(--muted);
  font-size: 15px; font-weight: 600; padding: 12px 6px; position: relative;
}
.tab.active { color: var(--text); }
.tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px;
  background: var(--accent); border-radius: 3px;
}
.tabs-spacer { flex: 1; }
.download-all {
  background: #fff; color: #111; border: none; border-radius: 6px;
  padding: 9px 16px; font-size: 13.5px; font-weight: 700; transition: opacity .15s;
}
.download-all:hover { opacity: 0.85; }
.download-all:disabled { opacity: 0.5; cursor: default; }

/* ---------- Photo grid ---------- */
.grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.tile {
  position: relative; aspect-ratio: 1 / 1; border-radius: 6px; overflow: hidden;
  background: #16161e; cursor: pointer; border: 1px solid #20202a;
}
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.tile:hover img { transform: scale(1.06); }
.tile.pinned::before {
  content: "★"; position: absolute; top: 6px; left: 6px; z-index: 2;
  font-size: 12px; color: #ffd34d; text-shadow: 0 1px 3px rgba(0,0,0,.8);
}
.grid-empty { text-align: center; color: var(--muted); padding: 70px 20px; font-size: 15px; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,0.94);
  display: flex; flex-direction: column;
}
.lb-stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 50px 20px 10px; min-height: 0; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.lb-close {
  position: absolute; top: 16px; right: 18px; z-index: 3;
  background: rgba(28,28,38,0.8); color: #fff; border: 1px solid #3a3a48;
  width: 42px; height: 42px; border-radius: 50%; font-size: 17px;
}
.lb-close:hover { background: var(--accent); }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  background: rgba(28,28,38,0.55); color: #fff; border: none;
  width: 52px; height: 80px; font-size: 38px; line-height: 1;
}
.lb-nav:hover { background: rgba(229,9,20,0.7); }
.lb-prev { left: 0; border-radius: 0 8px 8px 0; }
.lb-next { right: 0; border-radius: 8px 0 0 8px; }
.lb-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 5vw, 60px) calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0,0,0,0.85), transparent);
}
.lb-photographer { font-size: 15px; font-weight: 650; }
.lb-date { font-size: 13px; color: var(--muted); margin-top: 2px; }
.lb-download {
  background: #fff; color: #111; text-decoration: none;
  padding: 10px 18px; border-radius: 6px; font-size: 14px; font-weight: 700; white-space: nowrap;
}
.lb-download:hover { opacity: 0.85; }

/* ---------- Access panel ---------- */
.access {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(6,6,9,0.96); backdrop-filter: blur(6px); overflow-y: auto;
}
.access-inner {
  max-width: 640px; margin: 0 auto; padding: 30px clamp(16px, 5vw, 40px) 60px; position: relative;
}
.access-inner h2 { margin: 6px 0 6px; font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.access-sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; line-height: 1.5; }
.access-form {
  display: grid; grid-template-columns: 1fr 96px auto auto; gap: 10px;
}
.access-form input {
  background: #0e0e14; border: 1px solid #33333f; color: var(--text);
  border-radius: 6px; padding: 12px 13px; font-size: 14px; outline: none;
}
.access-form input#access-pin { letter-spacing: 2px; }
.access-form input:focus { border-color: var(--accent); }
.access-form button[type="submit"] {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 0 18px; font-size: 14px; font-weight: 700; white-space: nowrap;
}
.access-form button[type="submit"]:hover { background: var(--accent-hi); }
.access-generate {
  background: transparent; color: var(--muted); border: 1px solid #33333f;
  border-radius: 6px; padding: 0 14px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.access-generate:hover { color: var(--text); border-color: #4a4a5a; }
.access-error { color: #ff6b6b; font-size: 13px; min-height: 18px; margin-top: 8px; }
.access-list { list-style: none; padding: 0; margin: 10px 0 0; }
.access-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; background: var(--card); border: 1px solid #23232e;
  border-radius: 8px; margin-bottom: 8px;
}
.access-row .a-name { font-weight: 650; font-size: 15px; }
.access-row .a-pin {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 14px;
  color: var(--text); background: #0e0e14; border: 1px solid #2c2c38;
  border-radius: 5px; padding: 3px 9px; letter-spacing: 2px;
}
.access-row .a-meta { color: #707080; font-size: 12px; }
.access-row .a-spacer { flex: 1; }
.access-row .a-revoke {
  background: transparent; color: #ff6b6b; border: 1px solid #4a2630;
  border-radius: 6px; padding: 7px 12px; font-size: 13px; font-weight: 600;
}
.access-row .a-revoke:hover { background: #ff6b6b; color: #fff; border-color: #ff6b6b; }
.access-empty { color: var(--muted); font-style: italic; padding: 18px 2px; font-size: 14px; }

@media (max-width: 560px) {
  .access-form { grid-template-columns: 1fr 1fr; }
  .access-form input#access-name { grid-column: 1 / -1; }
  .access-generate { padding: 11px 0; }
  .access-form button[type="submit"] { grid-column: 1 / -1; padding: 11px; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #1c1c26; color: var(--text); border: 1px solid #33333f;
  padding: 12px 18px; border-radius: 8px; font-size: 14px; z-index: 100;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .topbar-search { order: 3; flex-basis: 100%; }
  .topbar-search input { width: 100%; }
  .brand { font-size: 18px; }
  .card { width: 168px; }
  .row-title { font-size: 17px; }
  .detail-head h2 { font-size: 21px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  .lb-nav { width: 42px; height: 64px; font-size: 30px; }
}
