@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;700&display=swap');

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

:root {
  --bg: #f7f7f7;
  --surface: #fff;
  --border: #e0e0e0;
  --text: #111;
  --muted: #888;
  --accent: #000;
  --danger: #c0392b;
  --success: #1a7f37;
  --font: 'Manrope', sans-serif;
  --radius: 6px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.admin-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--accent);
  color: #fff;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar .brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  margin-bottom: 24px;
  line-height: 1.3;
}

.sidebar a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  transition: background .15s;
  color: rgba(255,255,255,.8);
}
.sidebar a:hover, .sidebar a.active { background: rgba(255,255,255,.12); color: #fff; }

.sidebar .divider {
  height: 1px;
  background: rgba(255,255,255,.15);
  margin: 12px 0;
}

.main-content {
  padding: 36px 40px;
  max-width: 1000px;
}

/* ── Typography ─────────────────────────────────────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem; }
h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

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

.thumb-cell img {
  width: 56px;
  height: 40px;
  object-fit: cover;
  border-radius: 3px;
  display: block;
}
.thumb-cell .no-thumb {
  width: 56px;
  height: 40px;
  background: #eee;
  border-radius: 3px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.badge-pub  { background: #e6f4ea; color: #1a7f37; }
.badge-draft{ background: #f0f0f0; color: #888; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: .4rem; }
input[type="text"], input[type="email"], input[type="url"], input[type="password"], textarea, select {
  width: 100%;
  padding: .6rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  transition: border-color .15s;
  background: var(--surface);
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 140px; }

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

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #333; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: #999; }
.btn-danger  { background: transparent; border-color: #fcc; color: var(--danger); }
.btn-danger:hover  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: .3rem .7rem; font-size: 12px; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); font-size: 13px; margin-bottom: 1.25rem; }
.alert-ok  { background: #e6f4ea; color: var(--success); }
.alert-err { background: #fdecea; color: var(--danger); }

/* ── Image upload area ───────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: #fafafa;
}
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-zone p { font-size: 13px; color: var(--muted); pointer-events: none; }
.upload-zone strong { color: var(--text); }

/* ── Image grid (in project edit) ───────────────────────────────────────── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.image-tile {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #f5f5f5;
  cursor: grab;
  touch-action: none;
}
.image-tile.is-cover { outline: 3px solid var(--accent); }
.image-tile img {
  width: 100%;
  aspect-ratio: 3/2;
  object-fit: cover;
  display: block;
}
.image-tile-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 6px;
  background: var(--surface);
  font-size: 11px;
}
.image-tile-actions .set-cover {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  padding: 0;
  font-family: var(--font);
}
.image-tile.is-cover .set-cover { color: var(--accent); font-weight: 600; }
.image-tile-actions .del-img {
  background: none;
  border: none;
  cursor: pointer;
  color: #ccc;
  font-size: 15px;
  line-height: 1;
  padding: 0;
  transition: color .2s;
}
.image-tile-actions .del-img:hover { color: var(--danger); }

/* Upload progress */
.upload-queue { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.upload-item .bar-wrap {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.upload-item .bar { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.upload-item .status { min-width: 36px; text-align: right; color: var(--muted); }

/* Drag handle */
.drag-handle {
  position: absolute;
  top: 5px;
  left: 5px;
  cursor: grab;
  color: rgba(255,255,255,.8);
  font-size: 14px;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
  user-select: none;
}

/* ── Project order drag ─────────────────────────────────────────────────── */
.project-row { cursor: grab; }
.project-row.dragging { opacity: .4; }

@media (max-width: 768px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; padding: 16px; gap: 4px; }
  .sidebar .brand { width: 100%; margin-bottom: 8px; }
  .main-content { padding: 24px 20px; }
  .form-row { grid-template-columns: 1fr; }
}

/* ── CMS Image Lightbox ────────────────────────────────────────────────── */
.cms-lb {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0,0,0,.88);
  align-items: center;
  justify-content: center;
  gap: 20px;
}
.cms-lb.open { display: flex; }

.cms-lb-close {
  position: absolute; top: 20px; right: 20px;
  background: none; border: none; color: #fff;
  font-size: 32px; cursor: pointer; line-height: 1;
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: background .2s;
}
.cms-lb-close:hover { background: rgba(255,255,255,.15); }

.cms-lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #fff;
  font-size: 36px; cursor: pointer;
  width: 52px; height: 52px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: background .2s;
}
.cms-lb-nav:hover { background: rgba(255,255,255,.15); }
.cms-lb-prev { left: 20px; }
.cms-lb-next { right: 20px; }

.cms-lb-img-wrap img {
  max-width: 88vw; max-height: 82vh;
  object-fit: contain; display: block;
  border-radius: 4px;
}

.cms-lb-info {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.7); font-size: 13px; font-weight: 500;
  letter-spacing: .04em; white-space: nowrap;
}

.cms-lb-delete {
  position: absolute; bottom: 20px; right: 24px;
  background: none; border: 1px solid rgba(255,255,255,.25);
  color: #fff; font-size: 12px; font-weight: 500;
  padding: 6px 14px; border-radius: 4px; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: background .2s, border-color .2s;
}
.cms-lb-delete:hover { background: rgba(192,57,43,.8); border-color: transparent; }
