:root {
  --bg: #0b0c10;
  --surface: #14161e;
  --surface-2: #1c1f2b;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f4f5f7;
  --muted: #9aa0ae;
  --accent: #e5b869;
  --accent-dark: #c9963e;
  --heart: #ff3b5c;
  --heart-bg: rgba(255, 59, 92, 0.16);
  --success: #2ecc71;
  --danger: #ff5c5c;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}

.hidden { display: none !important; }

/* Loading */
.loading-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 12, 16, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-mark {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.6px;
  color: var(--accent);
  text-transform: uppercase;
}

.album-title {
  font-size: 18px;
  font-weight: 700;
  margin: 2px 0 0;
  color: var(--text);
}

.album-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #111;
  border-color: transparent;
}

.btn-heart {
  background: var(--heart);
  color: #fff;
  border-color: transparent;
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  background: rgba(255, 92, 92, 0.14);
  color: #ff8585;
  border-color: rgba(255, 92, 92, 0.3);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Filter bar inside Gallery */
.gallery-controls {
  max-width: 1280px;
  margin: 12px auto 0;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.pill-group {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 4px;
}

.pill-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-btn.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

.pill-btn.active.heart-tab {
  background: var(--heart);
  color: #fff;
}

.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  min-width: 170px;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
}

.note-banner {
  max-width: 1280px;
  margin: 10px auto 0;
  padding: 0 12px;
}

.note-banner-inner {
  background: rgba(229, 184, 105, 0.1);
  border: 1px solid rgba(229, 184, 105, 0.28);
  color: #f4d89e;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
}

/* Photo Grid — Tối ưu cho điện thoại (2 cột gọn đẹp, vuốt mượt) */
.photo-grid {
  max-width: 1280px;
  margin: 12px auto;
  padding: 0 10px calc(96px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

@media (min-width: 640px) {
  .photo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (min-width: 1024px) {
  .photo-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
  }
}

.photo-card {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  border: 2px solid transparent;
  aspect-ratio: 4 / 5;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.12s ease;
}

.photo-card.selected {
  border-color: var(--heart);
  box-shadow: 0 0 0 1px rgba(255, 59, 92, 0.45);
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #181b24;
}

.photo-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 26px 8px 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
}

.photo-code {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.card-heart-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 17, 23, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s cubic-bezier(0.2, 1.4, 0.4, 1), background 0.15s ease;
}

.photo-card.selected .card-heart-btn {
  background: var(--heart);
  transform: scale(1.06);
}

.card-heart-btn:active {
  transform: scale(0.86);
}

/* Sticky Bottom Bar cho khách */
.bottom-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  background: rgba(16, 18, 26, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 10px 14px calc(10px + var(--safe-bottom));
}

.bottom-dock-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dock-count {
  display: flex;
  flex-direction: column;
}

.dock-count strong {
  font-size: 15px;
  color: var(--text);
}

.dock-count span {
  font-size: 12px;
  color: var(--muted);
}

/* Lightbox toàn màn hình */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: flex;
  flex-direction: column;
}

.lb-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.7);
  z-index: 5;
}

.lb-info {
  display: flex;
  flex-direction: column;
}

.lb-code {
  font-size: 15px;
  font-weight: 700;
}

.lb-counter {
  font-size: 12px;
  color: var(--muted);
}

.lb-top-actions {
  display: flex;
  gap: 8px;
}

.lb-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

.lb-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: pan-y;
}

.lb-img-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.lb-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.lb-img-wrap.zoomed img {
  transform: scale(1.9);
  cursor: zoom-out;
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 64px;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  z-index: 4;
  border-radius: 10px;
}

.lb-prev { left: 8px; }
.lb-next { right: 8px; }

.lb-bottombar {
  padding: 12px 16px calc(14px + var(--safe-bottom));
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  justify-content: center;
}

.lb-heart-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 230px;
  padding: 13px 24px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.lb-heart-btn.active {
  background: var(--heart);
  border-color: var(--heart);
}

/* Modal / Bottom Sheet */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 640px) {
  .modal { align-items: center; }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.modal-sheet {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 500px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(20px + var(--safe-bottom));
  max-height: 90vh;
  overflow-y: auto;
}

@media (min-width: 640px) {
  .modal-sheet { border-radius: 18px; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-header h3 { margin: 0; font-size: 17px; }

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
}

/* Admin Dashboard */
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card h2, .card h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .form-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: #d6dae3;
}

.field input, .field textarea, .field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
}

.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
}

.field small {
  font-size: 12px;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab-btn {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--accent);
  color: #111;
  border-color: transparent;
}

.result-box {
  background: rgba(46, 204, 113, 0.08);
  border: 1px solid rgba(46, 204, 113, 0.35);
  border-radius: 12px;
  padding: 14px;
  margin-top: 14px;
}

.short-link-display {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  word-break: break-all;
  margin: 6px 0 10px;
}

.codes-box {
  background: #0a0b0f;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #f3e0b5;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.selection-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.selection-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--heart-bg);
  color: #ff7a92;
}

.badge-gold {
  background: rgba(229, 184, 105, 0.16);
  color: var(--accent);
}

.demo-banner {
  background: rgba(229, 184, 105, 0.12);
  border: 1px solid rgba(229, 184, 105, 0.35);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #f4d89e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

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

.pin-box {
  max-width: 400px;
  margin: 60px auto;
  text-align: center;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: #222634;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.16);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
