/* ==========================================================================
   Imbewu — admin panel styles
   ========================================================================== */

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

:root {
  --blue: #2D5D7B;
  --blue-dark: #1E4260;
  --blue-deep: #17303E;
  --teal: #4F8A8B;
  --seed: #37A93C;
  --seed-dark: #1B7A34;
  --red: #B4342B;
  --amber: #B3791B;
  --ink: #1F2A30;
  --body: #4A5860;
  --muted: #6B7A84;
  --line: #E2E8ED;
  --line-soft: #EDF1F4;
  --bg: #F4F7F9;
  --white: #fff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(23,48,62,0.07);
  --shadow: 0 4px 18px rgba(23,48,62,0.09);
  --shadow-lg: 0 16px 48px rgba(23,48,62,0.18);
  --sidebar-w: 248px;
  --topbar-h: 62px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--body);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--ink); line-height: 1.3; font-weight: 650; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
ul { list-style: none; }
button { font: inherit; }

:focus-visible { outline: 3px solid rgba(79,138,139,0.5); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ==========================================================================
   SIGN-IN SCREEN
   ========================================================================== */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(150deg, #EDF3F7 0%, #F4F7F9 45%, #EBF3F2 100%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 38px 34px 32px;
  border: 1px solid var(--line);
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand img { height: 56px; width: auto; margin: 0 auto 14px; }
.login-brand h1 { font-size: 1.15rem; margin-bottom: 4px; }
.login-brand p { font-size: 0.86rem; color: var(--muted); }
.login-card .btn { width: 100%; margin-top: 6px; }
.login-foot { text-align: center; margin-top: 22px; font-size: 0.84rem; color: var(--muted); }

/* ==========================================================================
   SHELL
   ========================================================================== */
.admin-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--blue-deep);
  color: rgba(255,255,255,0.72);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.09);
}
.sidebar-brand img {
  width: 38px; height: 38px;
  object-fit: contain;
  background: #fff;
  border-radius: 9px;
  padding: 4px;
  flex-shrink: 0;
}
.sidebar-brand strong { color: #fff; font-size: 0.95rem; display: block; line-height: 1.25; }
.sidebar-brand span { font-size: 0.7rem; color: rgba(255,255,255,0.45); letter-spacing: 0.05em; text-transform: uppercase; }

.sidebar-nav { padding: 14px 12px; flex-grow: 1; }
.sidebar-heading {
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.32);
  padding: 14px 10px 7px;
  font-weight: 700;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.72);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: var(--blue); color: #fff; }
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.9; }
.sidebar-nav a .count {
  margin-left: auto;
  background: rgba(255,255,255,0.16);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 20px;
}
.sidebar-nav a .count.alert { background: var(--seed); }

.sidebar-foot { padding: 14px 20px 18px; border-top: 1px solid rgba(255,255,255,0.09); font-size: 0.8rem; }
.sidebar-foot a { color: rgba(255,255,255,0.6); display: inline-flex; align-items: center; gap: 7px; }
.sidebar-foot a:hover { color: #fff; }
.sidebar-foot svg { width: 15px; height: 15px; }

.admin-main { flex-grow: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar h1 { font-size: 1.02rem; font-weight: 650; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-user { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.topbar-user .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  color: #fff;
  display: grid; place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.sidebar-toggle {
  display: none;
  width: 40px; height: 40px;
  border: 1px solid var(--line);
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--blue);
  place-items: center;
}
.sidebar-toggle svg { width: 20px; height: 20px; }

.admin-content { padding: 26px 24px 60px; flex-grow: 1; min-width: 0; }
.card, .card-head, .card-body, .card-foot { min-width: 0; }
.card-head h2, .card-head p { overflow-wrap: anywhere; }
/* Any long value — a URL, an email, a file path — must wrap instead of
   stretching the page. Applies wherever .help is used, not just in a .field. */
.help { font-size: 0.79rem; color: var(--muted); margin-top: 5px; overflow-wrap: anywhere; }
.help a, .help code, .card-body a, pre { overflow-wrap: anywhere; word-break: break-word; }
.content-width { max-width: 1080px; }

.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(23,48,62,0.45);
  z-index: 50;
  opacity: 0; visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.89rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  min-height: 42px;
  text-decoration: none !important;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-secondary { background: var(--white); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }
.btn-success { background: var(--seed-dark); color: #fff; border-color: var(--seed-dark); }
.btn-success:hover { background: #14612a; }
.btn-danger { background: var(--white); color: var(--red); border-color: rgba(180,52,43,0.4); }
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn-ghost { background: none; color: var(--muted); border-color: transparent; padding: 8px 10px; }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn-sm { padding: 7px 13px; min-height: 34px; font-size: 0.82rem; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ==========================================================================
   CARDS & PANELS
   ========================================================================== */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}
.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.card-head h2 { font-size: 0.98rem; font-weight: 650; }
.card-head p { font-size: 0.83rem; color: var(--muted); margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }
.card-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: #FAFCFD;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Sticky save bar */
.save-bar {
  position: sticky;
  bottom: 0;
  background: var(--white);
  border-top: 1px solid var(--line);
  padding: 14px 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 -24px -60px;
  box-shadow: 0 -4px 18px rgba(23,48,62,0.07);
  z-index: 30;
}
.save-bar .hint { font-size: 0.82rem; color: var(--muted); margin-left: auto; }

/* ==========================================================================
   STATS
   ========================================================================== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 14px;
  align-items: center;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: rgba(45,93,123,0.1);
  color: var(--blue);
  flex-shrink: 0;
}
.stat-icon svg { width: 21px; height: 21px; }
.stat-icon.green { background: rgba(55,169,60,0.12); color: var(--seed-dark); }
.stat-icon.amber { background: rgba(179,121,27,0.12); color: var(--amber); }
.stat-icon.teal { background: rgba(79,138,139,0.13); color: var(--teal); }
.stat-value { font-size: 1.65rem; font-weight: 700; color: var(--ink); line-height: 1.1; }
.stat-label { font-size: 0.81rem; color: var(--muted); }

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ==========================================================================
   FORMS
   ========================================================================== */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field label, .field > .label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
.field .help { font-size: 0.79rem; color: var(--muted); margin-top: 5px; overflow-wrap: anywhere; }
.field .help a, .field .help code { overflow-wrap: anywhere; word-break: break-word; }
.field .help.warn { color: var(--amber); }

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=search], input[type=tel], input[type=date],
input[type=datetime-local], select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(45,93,123,0.12);
}
input[readonly], input:disabled, textarea:disabled { background: var(--line-soft); color: var(--muted); }
textarea { resize: vertical; min-height: 92px; line-height: 1.6; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7A84' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 17px;
  padding-right: 38px;
}
.input-error { border-color: var(--red) !important; }
.error-text { color: var(--red); font-size: 0.8rem; margin-top: 5px; }

.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }
.field-row.thirds { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 0.89rem;
  color: var(--ink);
  font-weight: 500;
}
.checkbox input[type=checkbox] {
  width: 19px; height: 19px;
  accent-color: var(--blue);
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}
.checkbox .checkbox-help { display: block; font-size: 0.79rem; color: var(--muted); font-weight: 400; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 44px; height: 25px;
  background: #C7D2D9;
  border-radius: 20px;
  position: relative;
  transition: background 0.18s;
  flex-shrink: 0;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 19px; height: 19px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.18s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .track { background: var(--seed); }
.switch input:checked + .track::after { transform: translateX(19px); }
.switch input:focus-visible + .track { outline: 3px solid rgba(79,138,139,0.5); outline-offset: 2px; }
.switch .switch-label { font-size: 0.86rem; font-weight: 600; color: var(--ink); }

/* ==========================================================================
   ALERTS
   ========================================================================== */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 0.89rem;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  border: 1px solid;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.alert-success { background: rgba(55,169,60,0.09); border-color: rgba(55,169,60,0.3); color: var(--seed-dark); }
.alert-error   { background: rgba(180,52,43,0.07); border-color: rgba(180,52,43,0.28); color: var(--red); }
.alert-warning { background: rgba(179,121,27,0.09); border-color: rgba(179,121,27,0.3); color: var(--amber); }
.alert-info    { background: rgba(45,93,123,0.07); border-color: rgba(45,93,123,0.22); color: var(--blue-dark); }
.alert a { color: inherit; font-weight: 700; text-decoration: underline; }

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-wrap {
  /* position:relative gives this box a positioning context. Without it,
     positioned descendants escape the overflow clip and make the whole admin
     page scroll sideways on a phone instead of the table scrolling on its own. */
  position: relative;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th {
  text-align: left;
  padding: 11px 16px;
  background: #FAFCFD;
  border-bottom: 1px solid var(--line);
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  white-space: nowrap;
}
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #FAFCFD; }
table.data .title-cell { font-weight: 600; color: var(--ink); }
table.data .title-cell a { color: var(--ink); }
table.data .title-cell a:hover { color: var(--blue); }
table.data .sub { font-size: 0.79rem; color: var(--muted); font-weight: 400; }
table.data .actions { display: flex; gap: 6px; justify-content: flex-end; }
table.data .thumb {
  width: 54px; height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--line-soft);
  flex-shrink: 0;
}
.row-flex { display: flex; align-items: center; gap: 12px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-published { background: rgba(55,169,60,0.13); color: var(--seed-dark); }
.badge-draft     { background: rgba(107,122,132,0.14); color: var(--muted); }
.badge-scheduled { background: rgba(179,121,27,0.14); color: var(--amber); }
.badge-featured  { background: rgba(45,93,123,0.12); color: var(--blue); }
.badge-new       { background: rgba(180,52,43,0.1); color: var(--red); }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-bar select, .filter-bar input { width: auto; min-width: 150px; }

.empty {
  padding: 46px 24px;
  text-align: center;
  color: var(--muted);
}
.empty svg { width: 40px; height: 40px; margin: 0 auto 14px; color: var(--teal); }
.empty h3 { font-size: 1rem; margin-bottom: 6px; }
.empty p { font-size: 0.88rem; margin-bottom: 16px; }

.pager { display: flex; gap: 6px; padding: 14px 20px; flex-wrap: wrap; align-items: center; }
.pager a, .pager span {
  min-width: 36px; height: 36px;
  padding: 0 11px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--body);
  background: var(--white);
}
.pager a:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }
.pager .current { background: var(--blue); border-color: var(--blue); color: #fff; }
.pager .muted { border: none; background: none; color: var(--muted); font-weight: 400; }

/* ==========================================================================
   TABS
   ========================================================================== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tabs a {
  padding: 11px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs a:hover { color: var(--blue); text-decoration: none; }
.tabs a.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ==========================================================================
   IMAGE PICKER
   ========================================================================== */
.image-picker {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.image-preview {
  width: 168px;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--line-soft);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  padding: 6px;
}
.image-preview img { max-width: 100%; max-height: 200px; width: auto; height: auto; object-fit: contain; border-radius: 4px; }
.image-preview .none { color: var(--muted); font-size: 0.79rem; text-align: center; padding: 20px 10px; }
.image-picker-controls { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.image-picker-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.upload-drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 30px 20px;
  text-align: center;
  background: #FAFCFD;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.upload-drop:hover, .upload-drop.dragover { border-color: var(--blue); background: rgba(45,93,123,0.04); }
.upload-drop svg { width: 34px; height: 34px; color: var(--teal); margin: 0 auto 10px; }
.upload-drop strong { display: block; color: var(--ink); font-size: 0.94rem; margin-bottom: 4px; }
.upload-drop span { font-size: 0.82rem; color: var(--muted); }
.upload-drop input[type=file] { display: none; }

/* Media library grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 16px; }
.media-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}
.media-item:hover { border-color: var(--blue); box-shadow: var(--shadow); }
.media-item.selected { border-color: var(--seed); box-shadow: 0 0 0 2px rgba(55,169,60,0.35); }
.media-thumb {
  aspect-ratio: 4 / 3;
  background: repeating-conic-gradient(#EFF3F5 0% 25%, #fff 0% 50%) 50% / 16px 16px;
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
  border: none;
  padding: 0;
  width: 100%;
}
.media-thumb img { width: 100%; height: 100%; object-fit: contain; }
.media-info { padding: 9px 11px; font-size: 0.76rem; color: var(--muted); border-top: 1px solid var(--line-soft); }
.media-info strong {
  display: block;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}
.media-actions { display: flex; gap: 5px; padding: 0 9px 9px; flex-wrap: wrap; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(23,48,62,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 880px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-box.narrow { max-width: 460px; }
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-head h2 { font-size: 1rem; }
.modal-body { padding: 20px; overflow-y: auto; flex-grow: 1; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; background: #FAFCFD; }
.modal-close {
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  background: none;
  border-radius: 7px;
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--muted);
  flex-shrink: 0;
}
.modal-close:hover { color: var(--ink); border-color: var(--blue); }
.modal-close svg { width: 17px; height: 17px; }

/* ==========================================================================
   ARTICLE EDITOR
   ========================================================================== */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
/* Grid items default to min-width:auto, so a wide table inside one refuses to
   shrink and pushes the page sideways. Clearing it lets the inner scrollers do
   their job. */
.editor-layout > * { min-width: 0; }
.editor-side { display: flex; flex-direction: column; gap: 22px; position: sticky; top: calc(var(--topbar-h) + 20px); }

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #FAFCFD;
  position: sticky;
  top: var(--topbar-h);
  z-index: 20;
  border-radius: var(--radius) var(--radius) 0 0;
}
.editor-toolbar button {
  min-width: 34px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid transparent;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--body);
  font-size: 0.84rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.editor-toolbar button:hover { background: var(--white); border-color: var(--line); color: var(--ink); }
.editor-toolbar button.is-active { background: var(--blue); border-color: var(--blue); color: #fff; }
.editor-toolbar button svg { width: 16px; height: 16px; }
.editor-toolbar .sep { width: 1px; background: var(--line); margin: 4px 5px; align-self: stretch; }

.editor-area {
  min-height: 460px;
  padding: 24px 26px;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--ink);
  outline: none;
  overflow-wrap: break-word;
}
.editor-area:empty::before { content: attr(data-placeholder); color: #A6B3BB; }
.editor-area > * + * { margin-top: 1em; }
.editor-area h2 { font-size: 1.4rem; margin-top: 1.5em; }
.editor-area h3 { font-size: 1.16rem; margin-top: 1.3em; }
.editor-area h4 { font-size: 1.02rem; color: var(--blue); }
.editor-area ul { list-style: disc; padding-left: 1.5em; }
.editor-area ol { list-style: decimal; padding-left: 1.5em; }
.editor-area li { margin-bottom: 0.35em; }
.editor-area blockquote {
  border-left: 4px solid var(--teal);
  background: rgba(79,138,139,0.07);
  padding: 12px 18px;
  font-style: italic;
  border-radius: 0 6px 6px 0;
}
.editor-area a { color: var(--blue); text-decoration: underline; }
.editor-area img { max-width: 100%; height: auto; border-radius: 6px; margin: 10px auto; }
.editor-area figure { margin: 1.2em 0; text-align: center; }
.editor-area figcaption { font-size: 0.84rem; color: var(--muted); font-style: italic; margin-top: 6px; }
.editor-area hr { border: none; border-top: 1px solid var(--line); margin: 1.6em 0; }
.editor-area table { width: 100%; border-collapse: collapse; }
.editor-area th, .editor-area td { border: 1px solid var(--line); padding: 8px 10px; }
.editor-source {
  width: 100%;
  min-height: 460px;
  border: none;
  border-radius: 0;
  padding: 20px 24px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  resize: vertical;
}
.editor-source:focus { box-shadow: none; }

.slug-preview {
  font-size: 0.79rem;
  color: var(--muted);
  word-break: break-all;
  background: var(--line-soft);
  padding: 7px 10px;
  border-radius: 6px;
  margin-top: 6px;
}
.char-count { font-size: 0.76rem; color: var(--muted); text-align: right; margin-top: 4px; }
.char-count.over { color: var(--red); font-weight: 600; }

/* ==========================================================================
   SOCIAL MANAGER
   ========================================================================== */
.social-row {
  display: grid;
  grid-template-columns: 44px 1fr 190px minmax(0, 2fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.social-row:last-child { border-bottom: none; }
.social-row.is-off { background: #FBFCFD; }
.social-row.is-off .social-name { color: var(--muted); }
.social-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: #fff;
  flex-shrink: 0;
}
.social-mark svg { width: 21px; height: 21px; }
.social-row.is-off .social-mark { filter: grayscale(1); opacity: 0.5; }
.social-name { font-weight: 650; color: var(--ink); font-size: 0.9rem; }
.social-name .platform-hint { display: block; font-size: 0.75rem; color: var(--muted); font-weight: 400; }
.social-order { display: flex; gap: 4px; }
.order-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 6px;
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--muted);
}
.order-btn:hover { border-color: var(--blue); color: var(--blue); }
.order-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.order-btn svg { width: 15px; height: 15px; }

.social-preview {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  padding: 18px 20px;
  background: var(--blue-deep);
  border-radius: var(--radius-sm);
}
.social-preview a, .social-preview span {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: grid; place-items: center;
  color: rgba(255,255,255,0.8);
}
.social-preview svg { width: 18px; height: 18px; }

/* ==========================================================================
   SORTABLE CONTENT LISTS
   ========================================================================== */
.sort-list { display: flex; flex-direction: column; }
.sort-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.sort-item:last-child { border-bottom: none; }
.sort-item.is-off { background: #FBFCFD; opacity: 0.72; }
.sort-item-body { flex: 1 1 auto; min-width: 0; }
.sort-item-body strong { display: block; color: var(--ink); font-size: 0.92rem; margin-bottom: 3px; }
.sort-item-body p { font-size: 0.83rem; color: var(--muted); }
.sort-item-tools { display: flex; gap: 6px; align-items: center; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* ==========================================================================
   MESSAGES
   ========================================================================== */
.message-item { padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.message-item:last-child { border-bottom: none; }
.message-item.unread { background: rgba(45,93,123,0.035); border-left: 3px solid var(--blue); }
.message-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 8px; }
.message-head strong { color: var(--ink); font-size: 0.95rem; }
.message-contact { display: flex; gap: 8px 18px; flex-wrap: wrap; font-size: 0.84rem; margin-bottom: 8px; }
.message-body { font-size: 0.89rem; white-space: pre-wrap; background: #FAFCFD; border: 1px solid var(--line-soft); border-radius: 7px; padding: 12px 14px; }
.message-time { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1080px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-side { position: static; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }
  .admin-main { margin-left: 0; }
  .sidebar-toggle { display: grid; }
  .topbar { padding: 0 16px; }
  .admin-content { padding: 20px 16px 60px; }
  .save-bar { margin: 0 -16px -60px; }
  .social-row { grid-template-columns: 40px 1fr; gap: 10px 12px; }
  .social-row > *:nth-child(n+3) { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  /* Comfortable touch targets: 34px is fine with a mouse, too small with a thumb. */
  .editor-toolbar { gap: 5px; padding: 9px 10px; }
  .editor-toolbar button { min-width: 42px; height: 42px; padding: 0 11px; }
  .order-btn { width: 40px; height: 40px; }
  .modal-close, .sidebar-toggle { width: 44px; height: 44px; }
  .btn-sm { min-height: 40px; padding: 9px 15px; }
  .topbar h1 { font-size: 0.94rem; }
  .topbar-user span.name { display: none; }
  .card-head { padding: 14px 16px; }
  .card-body { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 14px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .stat-value { font-size: 1.4rem; }
  .editor-area { padding: 18px 16px; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
  .filter-bar select, .filter-bar input { width: 100%; min-width: 0; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  table.data th, table.data td { padding: 10px 12px; }
  .btn { min-height: 44px; }
}
