*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  background: #f5f6f8;
  color: #1a1a1a;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: #0ab39c; text-decoration: none; }
button { font: inherit; cursor: pointer; }

:root {
  --accent: #0ab39c;
  --accent-dark: #079b85;
  --line: #e5e7eb;
  --muted: #6b7280;
  --bg-card: #fff;
  --danger: #dc2626;
}

/* ---------- Auth ---------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  width: 360px;
  background: var(--bg-card);
  padding: 32px 28px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-card h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 6px;
  text-align: center;
}
.auth-card label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  gap: 4px;
}
.auth-card input,
.field input, .field textarea, .field select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  width: 100%;
}
.auth-card button,
.btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  font-weight: 500;
  font-size: 13px;
}
.btn:hover, .auth-card button:hover { background: var(--accent-dark); }
.btn.secondary {
  background: #fff;
  border: 1px solid var(--line);
  color: #1a1a1a;
}
.btn.secondary:hover { background: #f8f9fa; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.error { color: var(--danger); font-size: 12px; margin: 0; text-align: center; }

/* ---------- Admin layout ---------- */
.admin-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.admin-sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  /* Stick to the top so the nav stays in view while the main column
     scrolls. align-self:start keeps the grid item from stretching the
     full content height (which would defeat sticky). */
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}
.admin-sidebar .brand {
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 13px;
  margin-bottom: 24px;
}
.admin-sidebar nav a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: #374151;
  font-size: 13px;
  margin-bottom: 2px;
}
.admin-sidebar nav a.active,
.admin-sidebar nav a:hover {
  background: #f1f5f4;
  color: var(--accent-dark);
}
.admin-sidebar .footer {
  margin-top: auto;
  font-size: 12px;
  color: var(--muted);
}
.admin-sidebar .footer a { display: block; margin-top: 8px; }

.admin-main {
  padding: 32px 36px 60px;
  max-width: 1280px;
  width: 100%;
}
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.admin-header h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
}
.admin-header .crumbs a { color: var(--muted); }
.admin-header .crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px;
}
.card + .card { margin-top: 18px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.field textarea { min-height: 90px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }

/* ---------- Gallery list ---------- */
.gallery-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.gallery-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: grab;
  transition: opacity 0.15s ease, box-shadow 0.15s ease;
}
.gallery-card:active { cursor: grabbing; }
.gallery-card.dragging {
  opacity: 0.4;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}
.gallery-card .btn { cursor: pointer; }
.gallery-card .cover {
  aspect-ratio: 350 / 576;
  background: #f1f5f4;
  position: relative;
  overflow: hidden;
}
.gallery-card .cover img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%; 
  height: 100%; 
  object-fit: cover;
}
.gallery-card .info {
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.gallery-card .title {
  font-weight: 500;
  margin: 0 0 4px;
  font-size: 14px;
}
.gallery-card .meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
.badge {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f4;
  color: #0a6e63;
  margin-right: 6px;
}
.badge.draft { background: #fef3c7; color: #92400e; }
.gallery-card .actions {
  margin-top: auto;
  display: flex;
  gap: 8px;
}

/* ---------- Editor: photo grid ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
}
.toolbar .spacer { flex: 1; }

.dropzone {
  display: block;
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  margin-bottom: 18px;
}
.dropzone.hover { border-color: var(--accent); background: #f1fbf9; color: var(--accent-dark); }
.dropzone input[type=file] { display: none; }
.dropzone .upload-btn {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  font-weight: 500;
}

.upload-list {
  margin: 0 0 18px;
  font-size: 12px;
  color: var(--muted);
}
.upload-list li { padding: 4px 0; }
.upload-list .ok { color: #047857; }
.upload-list .err { color: var(--danger); }

.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  /* Keep each tile at its own (image-driven) height instead of stretching
     to the row — so the real aspect ratio of every photo is visible. */
  align-items: start;
}
.photo-tile {
  position: relative;
  /* No forced square — the tile takes the photo's native aspect ratio. */
  background: #f1f5f4;
  border-radius: 6px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;   /* no iOS long-press callout while picking up */
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
/* Picked-up tile while reordering (touch long-press or mouse drag). */
.photo-tile.dragging {
  opacity: 0.95;
  transform: scale(1.06);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
  z-index: 5;
  cursor: grabbing;
}
.photo-tile img {
  width: 100%;
  height: auto;       /* native ratio (was 100% + cover → square crop) */
  display: block;
  -webkit-user-drag: none;   /* no image drag-and-drop ghost on desktop */
  user-select: none;
  -webkit-user-select: none;
}
.tile-video-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  padding-left: 2px;            /* optically centre the ▶ glyph */
  pointer-events: none;
}
.photo-tile .tile-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}
.photo-tile:hover .tile-actions { opacity: 1; }
.tile-actions button {
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile-actions button:hover { background: rgba(0,0,0,0.85); }
.photo-tile.is-cover::before {
  content: 'COVER';
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 1;
}

.empty {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

/* ---------- Dropzone hint (inline, replaces full dropzone label) ---------- */
.dropzone-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border: 1.5px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 18px;
  background: #fafafa;
  flex-wrap: wrap;
}
.dropzone-hint svg { flex-shrink: 0; color: var(--accent); }
.upload-link {
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}
.upload-link input[type=file] { display: none; }
.upload-link:hover { text-decoration: underline; }

/* ---------- Page-wide drop overlay ---------- */
#page-drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 179, 156, 0.1);
  border: 3px dashed var(--accent);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#page-drop-overlay.visible { display: flex; }
.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: rgba(255,255,255,0.95);
  border-radius: 16px;
  padding: 40px 56px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.12);
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 500;
}
.drop-overlay-inner svg { stroke: var(--accent); }

/* ---------- Trash ---------- */
.trash-card { margin-top: 18px; }
.trash-card .photo-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(220, 38, 38, 0.08);
  pointer-events: none;
}
.tile-restore {
  background: rgba(10, 179, 156, 0.85) !important;
}
.tile-perm-del {
  background: rgba(220, 38, 38, 0.75) !important;
}

/* ---------- Hero image focal point ---------- */
.hero-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1120 / 480;
  overflow: hidden;
  background: #f1f5f4;
  border-radius: 6px;
}
/* Gallery-editor hero preview crops EXACTLY like the public gallery hero.
   The public .g-hero now has a FIXED aspect-ratio (1140/425), so we just
   reuse the same value here — identical crop on any window. The home-page
   hero preview (settings.html) keeps the default 1120/480 frame. */
.hero-preview--gallery {
  aspect-ratio: 1140 / 425;
  height: auto;
}
/* The public .g-hero <img> rests at transform: scale(1.1) (the parallax
   reserve, even with no mouse movement), which crops ~10% more than an
   un-scaled image. Replicate it here so the preview crop matches exactly. */
.hero-preview--gallery img {
  transform: scale(1.1);
}
.hero-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero-preview-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(10, 179, 156, 0.9);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.6);
  pointer-events: none;
  transform: translateY(-50%);
  top: 50%;
}
#hero-pos-slider { width: 100%; }

/* ---------- Home hero: whole-image canvas + web/mobile crop zones ----------
   The frame wraps the image at its NATURAL aspect (not forced square), so a
   non-square upload is shown in full and the crop zones map to the real
   pixels. Zones are computed for any aspect via the cover formula in JS. */
.hero-sq {
  position: relative;
  width: 100%;          /* fill the card width so the image is big & legible */
  margin: 0 auto;
  overflow: hidden;
  border-radius: 6px;
  background: #f1f5f4;
  line-height: 0;
}
.hero-sq img {
  display: block;
  width: 100%;          /* image spans the block width; height follows aspect */
  height: auto;
}
/* Crop-zone outlines (positioned inline by admin-settings.js). */
.hero-zone {
  position: absolute;
  box-sizing: border-box;
  pointer-events: none;
}
.hero-zone-web { border: 2px solid #0ab39c; box-shadow: 0 0 0 100vmax rgba(0,0,0,0); }
.hero-zone-mob { border: 2px dashed #f59e0b; }
.hero-zone span {
  position: absolute;
  top: 0;
  left: 0;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  color: #fff;
}
.hero-zone-web span { background: #0ab39c; }
.hero-zone-mob span { background: #f59e0b; right: 0; left: auto; }
.hero-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}
.hero-legend .hl-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: -1px;
}
.hero-legend .hl-web { background: #0ab39c; }
.hero-legend .hl-mob { background: #f59e0b; }
.hero-res-info {
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  border-top: 1px solid var(--line, #eee);
  padding-top: 12px;
}
.hero-res-info strong { color: var(--text, #111); font-weight: 600; }
#hero-card.drag-over {
  outline: 2px dashed var(--accent, #0ab39c);
  outline-offset: 4px;
}

/* ---------- Google Photos import ---------- */
.gp-import {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 18px;
  background: #fafafa;
}
.gp-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 10px;
}
.gp-row {
  display: flex;
  gap: 8px;
}
.gp-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  background: #fff;
}
.gp-row input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.gp-status {
  margin-top: 8px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
}
.gp-status.loading { background: #f1f5f4; color: var(--muted); }
.gp-status.ok      { background: #f0fdf4; color: #166534; }
.gp-status.err     { background: #fef2f2; color: var(--danger); }
.gp-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
/* Google Photos import progress bar (polled while a background import runs). */
.gp-progress {
  margin-top: 8px;
}
.gp-progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #e5e7eb;
  overflow: hidden;
}
.gp-progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent, #0ab39c);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ---------- Translations Manager ---------- */
.tabs {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.tab-btn {
  background: transparent;
  border: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  padding: 8px 12px;
  position: relative;
  transition: color 0.2s;
}
.tab-btn:hover { color: var(--accent); }
.tab-btn.active { color: #1a1a1a; }
.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -9px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}

.trans-item {
  background: var(--bg-card);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.trans-item h4 {
  margin: 0 0 16px 0;
  font-size: 15px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.trans-status {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
}
.trans-status.missing {
  background: #fee2e2;
  color: #dc2626;
}
.trans-status.ok {
  background: #dcfce7;
  color: #16a34a;
}
.trans-lang-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.trans-input-group {
  display: flex;
  align-items: center;
  gap: 12px;
}
.trans-input-group label {
  width: 30px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}
.trans-input-group .g-input {
  flex: 1;
}
.trans-input-group .g-btn {
  padding: 8px 12px;
}

/* ---------- Flash toast ---------- */
.admin-flash {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 14px;
  z-index: 300;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.admin-flash.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.admin-flash.is-err {
  background: var(--danger);
}

/* ---------- Confirm modal ---------- */
.admin-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  animation: admin-fade-in 0.15s ease;
}
.admin-confirm-box {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 24px 24px 20px;
  width: 420px;
  max-width: 92vw;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.admin-confirm-box p {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.45;
  color: #1a1a1a;
}
.admin-confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
@keyframes admin-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
