/* ============================================
   FECdesk - Public Gallery
   Modern, clean design inspired by Smash gallery
   ============================================ */

/* ---------- Reset & Variables ---------- */
:root {
  --bg: #0e0e10;
  --bg-surface: #18181b;
  --bg-card: #1e1e22;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --border: #27272a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  --transition: .25s cubic-bezier(.4,0,.2,1);
}

/* ---------- Light Theme ---------- */
body.theme-light {
  --bg: #f8f9fa;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --border: #e5e7eb;
  --shadow: 0 4px 24px rgba(0,0,0,.08);
}

body.theme-light .hero {
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
}

body.theme-light .hero-content h1 span {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

body.theme-light .toolbar {
  background: rgba(255,255,255,.9);
  border-bottom-color: var(--border);
}

body.theme-light .lightbox {
  background: rgba(255,255,255,.97);
}

body.theme-light .lightbox-close,
body.theme-light .lightbox-nav {
  background: rgba(0,0,0,.06);
  color: #1a1a2e;
}
body.theme-light .lightbox-close:hover,
body.theme-light .lightbox-nav:hover {
  background: rgba(0,0,0,.12);
}

body.theme-light .lightbox-counter {
  color: rgba(0,0,0,.5);
  background: rgba(255,255,255,.7);
}

body.theme-light .pin-card {
  background: #fff;
  border-color: var(--border);
}

body.theme-light .pin-inputs input {
  background: #f3f4f6;
  border-color: var(--border);
  color: var(--text);
}

body.theme-light .gallery-item {
  background: #f3f4f6;
}

body.theme-light .download-progress {
  background: #fff;
  border-color: var(--border);
}

body.theme-light .btn-logout {
  border-color: rgba(0,0,0,.15) !important;
  color: var(--text) !important;
}

body.theme-light ::-webkit-scrollbar-track { background: var(--bg); }
body.theme-light ::-webkit-scrollbar-thumb { background: #d1d5db; }
body.theme-light ::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

img, video { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }

/* ---------- PIN Screen ---------- */
.pin-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 1000;
  transition: opacity .4s ease, visibility .4s ease;
}
.pin-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.pin-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow);
}

.pin-card .logo {
  width: 80px; height: 80px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 800; color: #fff;
}

.pin-card h1 {
  font-size: 22px; font-weight: 700;
  margin-bottom: 8px;
}

.pin-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.pin-inputs {
  display: flex; gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}

.pin-inputs input {
  width: 56px; height: 64px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 28px; font-weight: 700;
  text-align: center;
  outline: none;
  transition: border-color var(--transition);
  -moz-appearance: textfield;
}
.pin-inputs input::-webkit-inner-spin-button,
.pin-inputs input::-webkit-outer-spin-button { -webkit-appearance: none; }

.pin-inputs input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.pin-inputs input.error { border-color: #ef4444; animation: shake .4s ease; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-6px); }
  40%,80% { transform: translateX(6px); }
}

.pin-error-msg {
  color: #ef4444;
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 16px;
}

.pin-submit {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 15px; font-weight: 600;
  transition: background var(--transition), transform .15s;
}
.pin-submit:hover { background: var(--accent-hover); }
.pin-submit:active { transform: scale(.97); }
.pin-submit:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Loading Screen ---------- */
.loading-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 900;
  transition: opacity .4s ease, visibility .4s ease;
}
.loading-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-screen p {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Error Screen ---------- */
.error-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 900;
  transition: opacity .4s ease, visibility .4s ease;
}
.error-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.error-card {
  text-align: center;
  padding: 40px;
}
.error-card .icon { font-size: 56px; margin-bottom: 16px; }
.error-card h2 { font-size: 20px; margin-bottom: 8px; }
.error-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.error-card button {
  padding: 12px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 14px; font-weight: 500;
  transition: background var(--transition);
}
.error-card button:hover { background: var(--bg-surface); }

/* ---------- Hero Banner ---------- */
.hero {
  position: relative;
  width: 100%;
  min-height: 280px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: #000;
}

.hero-media {
  width: 100%;
  display: block;
  object-fit: contain;
  opacity: 1;
}

/* When hero has a media child, let it define the height */
.hero.has-media {
  display: block;
}

.hero.has-media .hero-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(14,14,16,.3), rgba(14,14,16,.85));
}

.hero-content {
  position: relative; z-index: 2;
  text-align: center;
  padding: 40px 20px;
}

/* Brand logo in hero */
.hero-brand-logo {
  max-height: 80px;
  max-width: 200px;
  object-fit: contain;
  margin: 0 auto 16px;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.5));
}

.hero-content h1 {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -.02em;
}

.hero-content h1 span {
  background: linear-gradient(135deg, var(--accent), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-meta {
  display: flex; gap: 16px;
  justify-content: center; flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 14px;
}

.hero-meta .item {
  display: flex; align-items: center; gap: 6px;
}

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: rgba(14,14,16,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.toolbar-left {
  display: flex; align-items: center; gap: 12px;
}

.file-count {
  font-size: 14px;
  color: var(--text-muted);
}

.file-count strong {
  color: var(--text);
  font-weight: 600;
}

.toolbar-right {
  display: flex; align-items: center; gap: 10px;
}

.btn-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg-surface); color: var(--text); border-color: var(--accent); }

.btn-download-all {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 14px; font-weight: 600;
  transition: all var(--transition);
}
.btn-download-all:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-download-all:active { transform: translateY(0); }
.btn-download-all:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-download-all svg { width: 18px; height: 18px; }

/* ---------- Download Progress ---------- */
.download-progress {
  display: none;
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  min-width: 320px;
  box-shadow: var(--shadow);
}
.download-progress.active { display: block; animation: slideUp .3s ease; }

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.download-progress .label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.progress-bar-bg {
  width: 100%; height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width .3s ease;
  width: 0%;
}

.download-progress .percent {
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- Gallery Grid ---------- */
.gallery-container {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.gallery-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-card);
  aspect-ratio: 1;
  transition: transform var(--transition), box-shadow var(--transition);
}
.gallery-item:hover { transform: scale(1.02); box-shadow: 0 8px 32px rgba(0,0,0,.5); z-index: 2; }

.gallery-item img,
.gallery-item video {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: opacity .5s ease;
}

.gallery-item img.lazy { opacity: 0; }
.gallery-item img.loaded { opacity: 1; }

.gallery-item .video-badge {
  position: absolute; top: 10px; right: 10px;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px; font-weight: 600;
  color: #fff;
  display: flex; align-items: center; gap: 4px;
}

.gallery-item .play-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.2);
  opacity: 0;
  transition: opacity var(--transition);
}
.gallery-item:hover .play-overlay { opacity: 1; }

.play-overlay .play-btn {
  width: 56px; height: 56px;
  background: rgba(255,255,255,.9);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.play-overlay .play-btn svg { width: 24px; height: 24px; fill: #111; margin-left: 3px; }

/* Item overlay on hover */
.gallery-item .item-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 32px 12px 12px;
  background: linear-gradient(to top, rgba(0,0,0,.7), transparent);
  opacity: 0;
  transition: opacity var(--transition);
  display: flex; justify-content: flex-end;
}
.gallery-item:hover .item-overlay { opacity: 1; }

.item-overlay .dl-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 50%;
  color: #fff;
  font-size: 16px;
  transition: background var(--transition);
}
.item-overlay .dl-btn:hover { background: var(--accent); border-color: var(--accent); }

/* ---------- Watermark Overlay ---------- */
/* REMOVED: CSS watermark overlay - now using custom watermark system on download only */

/* Lightbox watermark - REMOVED */

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0;
  z-index: 500;
  background: rgba(0,0,0,.95);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
}
.lightbox.active { opacity: 1; visibility: visible; }

.lightbox-close {
  position: absolute; top: 16px; right: 16px;
  z-index: 510;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(4px);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 22px;
  transition: background var(--transition);
}
.lightbox-close:hover { background: rgba(255,255,255,.2); }

.lightbox-nav {
  position: absolute; top: 50%;
  transform: translateY(-50%);
  z-index: 510;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(4px);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 24px;
  transition: background var(--transition);
}
.lightbox-nav:hover { background: rgba(255,255,255,.2); }
.lightbox-nav.prev { left: 16px; }
.lightbox-nav.next { right: 16px; }

.lightbox-content {
  max-width: 90vw; max-height: 85vh;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  position: relative;
}

.lightbox-content img {
  max-width: 90vw; max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
  transition: transform .2s ease;
  cursor: zoom-in;
  will-change: transform;
}
.lightbox-content img.zoomed { cursor: grab; }

.lightbox-content video {
  max-width: 90vw; max-height: 85vh;
  border-radius: 4px;
  outline: none;
}

.lightbox-counter {
  position: absolute; bottom: 16px; left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: rgba(255,255,255,.5);
  background: rgba(0,0,0,.5);
  padding: 6px 14px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

.lightbox-download {
  position: absolute; bottom: 16px; right: 16px;
  z-index: 510;
  display: flex; align-items: center; gap: 6px;
  padding: 10px 18px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 13px; font-weight: 600;
  transition: background var(--transition);
}
.lightbox-download:hover { background: var(--accent-hover); }
.lightbox-download svg { width: 16px; height: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }
  .gallery-item { border-radius: 4px; }
  .hero { min-height: 200px; }
  .hero-brand-logo { max-height: 60px; max-width: 150px; }
  .hero-content h1 { font-size: 24px; }
  .toolbar { padding: 10px 12px; }
  .gallery-container { padding: 8px; }
  .lightbox-nav { width: 40px; height: 40px; font-size: 20px; }
  .lightbox-nav.prev { left: 8px; }
  .lightbox-nav.next { right: 8px; }
  .btn-download-all span.label-text { display: none; }
}

@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 3px;
  }
  .pin-card { padding: 32px 24px; }
  .pin-inputs input { width: 48px; height: 56px; font-size: 24px; }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3f3f46; }

/* ---------- Selection ---------- */
::selection { background: var(--accent); color: #fff; }
