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

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'Inter', sans-serif;
  background: #fff;
  color: #111;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

:root {
  --red:      #C0392B;
  --red-dark: #a93226;
  --black:    #111;
  --mid:      #555;
  --muted:    #999;
  --light:    #f5f5f5;
  --white:    #fff;
  --radius:   6px;
  --font:     'Inter', sans-serif;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.admin-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   TOP BAR
   ============================================================ */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: #fff;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 0;
}

.admin-topbar__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-right: 32px;
  flex-shrink: 0;
}

.admin-topbar__dots { color: var(--red); flex-shrink: 0; }

.admin-topbar__logo {
  font-size: 0.92rem;
  font-weight: 900;
  color: var(--black);
  letter-spacing: -0.3px;
}

.admin-topbar__sub {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--light);
  padding: 3px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.admin-topbar__nav {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
}

.admin-topbar__link {
  font-size: 0.73rem;
  font-weight: 500;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.admin-topbar__link:hover  { color: var(--black); background: var(--light); }
.admin-topbar__link.active { color: var(--black); font-weight: 600; background: var(--light); }

.admin-topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.admin-topbar__user {
  font-size: 0.68rem;
  color: var(--muted);
}

/* ============================================================
   PAGE HEAD
   ============================================================ */
.admin-pagehead {
  padding: 20px 32px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-pagehead__title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--black);
  letter-spacing: -0.3px;
}

.admin-pagehead__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.admin-main {
  flex: 1;
  padding: 16px 32px 80px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
  white-space: nowrap;
  line-height: 1;
  text-decoration: none;
}
.btn:hover { opacity: 0.85; }

.btn--primary   { background: var(--red); color: #fff; }
.btn--secondary { background: var(--light); color: var(--black); }
.btn--danger    { background: #fef0ef; color: var(--red); }
.btn--ghost     { background: transparent; color: var(--muted); }
.btn--sm        { padding: 6px 12px; font-size: 0.7rem; }
.btn--lg        { padding: 12px 24px; font-size: 0.82rem; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--mid);
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle__track {
  width: 36px;
  height: 20px;
  background: #ddd;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle input:checked + .toggle__track {
  background: var(--red);
}

.toggle input:checked + .toggle__track::after {
  transform: translateX(16px);
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--light);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-card__icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card__icon svg { width: 18px; height: 18px; }
.stat-card__icon--red    { background: #fef0ef; color: var(--red); }
.stat-card__icon--green  { background: #edfaf2; color: #27ae60; }
.stat-card__icon--yellow { background: #fef9ec; color: #f39c12; }
.stat-card__icon--blue   { background: #eef4fd; color: #2980b9; }

.stat-card__value { font-size: 1.5rem; font-weight: 800; color: var(--black); line-height: 1; }
.stat-card__label { font-size: 0.65rem; font-weight: 500; color: var(--muted); margin-top: 3px; }

/* ============================================================
   FORMS — flat, no cards, no borders between sections
   ============================================================ */
.form-section {
  margin-bottom: 32px;
}

.form-section__title {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}

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

.form-group--full { grid-column: 1 / -1; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--mid);
}

.form-group input,
.form-group textarea,
.form-group select {
  font-family: var(--font);
  font-size: 0.82rem;
  color: var(--black);
  background: #fff;
  border: 1.5px solid #ebebeb;
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(192,57,43,0.08);
}

.form-group textarea { resize: vertical; }

.form-hint {
  font-size: 0.64rem;
  color: var(--muted);
}

.req { color: var(--red); }

/* ============================================================
   RICH TEXT EDITOR
   ============================================================ */
.editor-wrap {
  border: 1.5px solid #ebebeb;
  border-radius: var(--radius);
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 7px 10px;
  background: #efefef;
}

.editor-toolbar button {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--mid);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.12s, color 0.12s;
  line-height: 1;
}
.editor-toolbar button:hover { background: #e2e2e2; color: var(--black); }
.editor-toolbar .sep {
  width: 1px;
  background: #ddd;
  margin: 3px 4px;
  align-self: stretch;
}

#bodyEditor {
  min-height: 300px;
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 0.88rem;
  line-height: 1.8;
  color: var(--black);
  background: #fff;
  outline: none;
}

#bodyHidden { display: none; }

/* ============================================================
   IMAGE UPLOAD
   ============================================================ */
.image-upload-area {
  position: relative;
  background: var(--light);
  border: 1.5px dashed #ddd;
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.image-upload-area:hover,
.image-upload-area.drag-over { border-color: var(--red); background: #fef5f4; }

.image-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.image-upload-area__icon svg { width: 24px; height: 24px; color: #ccc; margin: 0 auto 8px; }
.image-upload-area__text { font-size: 0.74rem; color: var(--muted); line-height: 1.5; }
.image-upload-area__text strong { color: var(--black); }

#imagePreview {
  display: none;
  max-height: 160px;
  object-fit: cover;
  border-radius: 4px;
  margin: 10px auto 0;
}

.current-image img {
  max-height: 120px;
  border-radius: 4px;
  object-fit: cover;
}
.current-image p {
  font-size: 0.64rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

thead th {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px;
  text-align: left;
  background: var(--light);
}

tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--light); }

td {
  padding: 11px 14px;
  vertical-align: middle;
  color: var(--mid);
}

.td-title a {
  font-weight: 600;
  color: var(--black);
  transition: color 0.15s;
}
.td-title a:hover { color: var(--red); }

.td-actions { display: flex; gap: 6px; align-items: center; }

.table-search {
  position: relative;
  display: flex;
  align-items: center;
}
.table-search svg {
  position: absolute;
  left: 10px;
  color: var(--muted);
  pointer-events: none;
}
.table-search input {
  font-family: var(--font);
  font-size: 0.76rem;
  padding: 8px 12px 8px 30px;
  background: #fff;
  border: 1.5px solid #ebebeb;
  border-radius: var(--radius);
  color: var(--black);
  min-width: 200px;
  transition: border-color 0.15s;
}
.table-search input:focus { outline: none; border-color: var(--red); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 600;
}
.badge--published  { background: #edfaf2; color: #27ae60; }
.badge--draft      { background: #fef9ec; color: #f39c12; }
.badge--stoke      { background: #eef4fd; color: #2980b9; }
.badge--newcastle  { background: #f5eef8; color: #8e44ad; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.78rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert--success { background: #edfaf2; color: #1e8449; }
.alert--error   { background: #fef0ef; color: var(--red-dark); }
.alert--info    { background: #eef4fd; color: #1a5276; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 16px 48px rgba(0,0,0,0.15);
}

.modal__title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--black);
  margin-bottom: 20px;
}

.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}
.modal__close:hover { background: var(--light); color: var(--black); }

/* ============================================================
   LIVE UPDATES PANEL (admin)
   ============================================================ */
.updates-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.update-item {
  background: var(--light);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.update-item__time {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--red);
  white-space: nowrap;
  padding-top: 2px;
  flex-shrink: 0;
}

.update-item__body { flex: 1; min-width: 0; }
.update-item__title { font-size: 0.78rem; font-weight: 700; color: var(--black); margin-bottom: 3px; }
.update-item__text { font-size: 0.74rem; color: var(--mid); line-height: 1.5; }

.update-item__img {
  width: 60px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.update-item__del {
  background: none;
  border: none;
  cursor: pointer;
  color: #ccc;
  padding: 2px;
  border-radius: 4px;
  transition: color 0.15s;
  flex-shrink: 0;
}
.update-item__del:hover { color: var(--red); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  background: var(--light);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.login-box__logo {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--black);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.login-box__sub {
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 28px;
}

/* ============================================================
   MISC
   ============================================================ */
.text-muted { color: var(--muted); }
