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

:root {
  --bg:        #f2f2f2;
  --surface:   #ffffff;
  --surface2:  #f7f7f7;
  --border:    #e2e2e2;
  --text:      #1a1a1a;
  --muted:     #777;
  --accent:    #b8892a;
  --accent-h:  #a07020;
  --danger:    #d94040;
  --success:   #3a9e6e;
  --radius:    8px;
  --shadow:    0 2px 16px rgba(0,0,0,.10);
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }
img { display: block; max-width: 100%; }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.container { max-width: 1300px; margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── Auth / centered card ────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--bg);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.auth-card .logo { margin: 0 auto 28px; max-height: 56px; width: auto; }
.auth-card h1 { font-size: 20px; font-weight: 600; margin-bottom: 6px; text-align: center; }
.auth-card .subtitle { color: var(--muted); text-align: center; margin-bottom: 28px; font-size: 14px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; letter-spacing: .02em; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  transition: border-color .2s;
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-control::placeholder { color: #bbb; }

select.form-control { cursor: pointer; background: var(--surface); }
textarea.form-control { resize: vertical; min-height: 90px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  letter-spacing: .03em;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .88; }
.btn-sm   { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; }

/* ── Alert ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
}
.alert-error   { background: rgba(217,64,64,.08); border: 1px solid rgba(217,64,64,.25); color: #c03030; }
.alert-success { background: rgba(58,158,110,.08); border: 1px solid rgba(58,158,110,.25); color: #2e7d55; }
.alert-info    { background: rgba(184,137,42,.08); border: 1px solid rgba(184,137,42,.25); color: var(--accent); }

/* ── Admin layout ─────────────────────────────────────────────────────────── */
.admin-wrap { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
}
.sidebar .logo-wrap {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
}
.sidebar .logo-wrap img { max-height: 44px; }
.sidebar nav { padding: 16px 0; flex: 1; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--muted);
  font-size: 14px;
  transition: color .15s, background .15s;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover  { color: var(--text); background: var(--bg); }
.sidebar nav a.active { color: var(--text); background: var(--bg); border-left-color: var(--accent); font-weight: 600; }
.sidebar .logout { padding: 0 20px 20px; margin-top: auto; }

.main-content { flex: 1; padding: 32px; overflow-x: hidden; background: var(--bg); }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; gap: 16px; }
.page-header h1 { font-size: 24px; font-weight: 700; }

/* ── Cards / tables ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.gallery-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.gallery-card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.gallery-card .thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--bg);
}
.gallery-card .thumb-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
}
.gallery-card .info { padding: 16px; }
.gallery-card .info h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.gallery-card .info .meta { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.gallery-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Btn-icon (lightbox) ──────────────────────────────────────────────────── */
.btn-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: background .15s, transform .1s;
  flex-shrink: 0;
}
.btn-icon:hover  { background: rgba(255,255,255,.25); transform: scale(1.1); }
.btn-icon.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Lightbox ─────────────────────────────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.93);
  z-index: 200;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox-img-wrap {
  overflow: hidden;
  cursor: grab;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-height: calc(100vh - 110px);
}
.lightbox img {
  max-width: 90vw;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 3px;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox-close {
  position: fixed;
  top: 20px; right: 24px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.lightbox-close:hover { background: rgba(255,255,255,.2); }
.lightbox-nav {
  position: fixed;
  top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.lightbox-nav:hover { background: rgba(255,255,255,.2); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

/* ── Comment modal ────────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 8px 40px rgba(0,0,0,.15);
}
.modal h3 { margin-bottom: 16px; font-size: 17px; }
.comment-list { max-height: 200px; overflow-y: auto; margin-bottom: 16px; }
.comment-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.comment-item:last-child { border-bottom: none; }
.comment-item .author { font-weight: 600; color: var(--accent); font-size: 13px; margin-bottom: 3px; }
.comment-item .time   { color: var(--muted); font-size: 12px; }

/* ── Admin image grid ─────────────────────────────────────────────────────── */
.admin-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.admin-photo-item { position: relative; border-radius: 6px; overflow: hidden; background: var(--bg); border: 1px solid var(--border); }
.admin-photo-item img { width: 100%; aspect-ratio: 3/2; object-fit: cover; display: block; }
.admin-photo-item .item-actions {
  position: absolute;
  top: 6px; right: 6px;
  display: flex;
  gap: 4px;
}
.admin-photo-item .item-num {
  position: absolute;
  bottom: 6px; left: 8px;
  font-size: 11px;
  color: rgba(255,255,255,.85);
  background: rgba(0,0,0,.45);
  padding: 2px 7px;
  border-radius: 10px;
}

/* ── Table ────────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; background: var(--bg); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green { background: rgba(58,158,110,.12); color: var(--success); }
.badge-gray  { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.badge-gold  { background: rgba(184,137,42,.12); color: var(--accent); }

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}
.empty .icon { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.empty p { font-size: 15px; }

/* ── Upload area ──────────────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 40px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .2s, color .2s;
  margin-bottom: 20px;
  background: var(--bg);
}
.upload-area:hover, .upload-area.dragover { border-color: var(--accent); color: var(--accent); background: rgba(184,137,42,.04); }
.upload-area .icon { font-size: 36px; margin-bottom: 12px; }
.upload-area p  { font-size: 14px; margin-bottom: 4px; }
.upload-area small { font-size: 12px; }

.progress-bar  { height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 16px; }
.progress-fill { height: 100%; background: var(--accent); width: 0; transition: width .2s; border-radius: 4px; }

/* ── Selection bar (legacy) ───────────────────────────────────────────────── */
.selection-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-wrap { flex-direction: column; }
  .sidebar { width: 100%; padding: 12px 0; }
  .sidebar nav { display: flex; overflow-x: auto; padding: 0; }
  .sidebar nav a { white-space: nowrap; padding: 10px 16px; }
  .main-content { padding: 16px; }
  .auth-card { padding: 28px 20px; }
}
