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

:root {
  --bg: #f6f6f8;
  --bg-subtle: #f0f0f3;
  --panel: #ffffff;
  --border: #e7e7ec;
  --border-strong: #d7d8df;
  --text: #16181d;
  --text-secondary: #4b4e57;
  --muted: #8b8e98;

  --primary: #e91e63;
  --primary-hover: #cc1251;
  --primary-fg: #ffffff;
  --primary-light: #fdeef3;
  --primary-light-strong: #fad2e1;

  --accent-bg: #fce4ec;
  --accent-fg: #870d36;

  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --success: #15803d;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --warning: #92610b;
  --warning-bg: #fef9ec;
  --warning-border: #fbe6ab;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-w: 260px;

  --shadow-xs: 0 1px 2px rgba(20, 21, 26, 0.04);
  --shadow-sm: 0 2px 8px -2px rgba(20, 21, 26, 0.08), 0 1px 2px rgba(20, 21, 26, 0.04);
  --shadow-md: 0 12px 28px -12px rgba(20, 21, 26, 0.18);
  --shadow-lg: 0 24px 48px -20px rgba(20, 21, 26, 0.22);
  --shadow-primary: 0 10px 22px -8px rgba(233, 30, 99, 0.45);

  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

h1, h2, h3, .sidebar-brand-name {
  font-family: 'Manrope', 'Inter', ui-sans-serif, system-ui, sans-serif;
  color: var(--text);
}

.icon { flex-shrink: 0; display: inline-block; vertical-align: middle; }

/* ---------- Shell / sidebar ---------- */

.admin-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.admin-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
}
.sidebar-brand img { height: 34px; width: 34px; display: block; border-radius: 9px; }
.sidebar-brand-name { font-weight: 800; font-size: 15px; color: var(--text); line-height: 1.25; }
.sidebar-brand-tag { display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary); margin-top: 1px; }

.sidebar-section-label {
  padding: 4px 20px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 10px 0 6px;
}

.sidebar-nav { padding: 0 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13.5px;
  transition: background 0.14s ease, color 0.14s ease;
}
.sidebar-nav a .icon { color: var(--muted); transition: color 0.14s ease; }
.sidebar-nav a:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.sidebar-nav a:hover .icon { color: var(--text); }
.sidebar-nav a.active { background: var(--primary-light); color: var(--accent-fg); }
.sidebar-nav a.active .icon { color: var(--primary); }

.sidebar-divider { height: 1px; background: var(--border); margin: 14px 16px; }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 16px 18px;
  border-top: 1px solid var(--border);
}
.sidebar-external {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  margin: 0 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
}
.sidebar-external:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.sidebar-external .icon { color: var(--muted); margin-left: auto; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
.sidebar-user-avatar {
  width: 32px; height: 32px; border-radius: 999px;
  background: linear-gradient(145deg, var(--primary), var(--secondary, #c2185b));
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; flex: 1; }
.sidebar-user-name { font-weight: 700; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: 11.5px; color: var(--muted); }
.sidebar-user-logout {
  flex-shrink: 0; color: var(--muted); display: flex; padding: 6px;
  border-radius: var(--radius-sm);
}
.sidebar-user-logout:hover { background: var(--danger-bg); color: var(--danger); }

/* ---------- Main content ---------- */

.admin-main {
  flex: 1;
  min-width: 0;
  padding: 30px 36px 70px;
  max-width: 1180px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}
.page-header-title h1 { font-size: 23px; margin: 0; font-weight: 800; letter-spacing: -0.01em; }
.page-header-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 13.5px; }
.page-header-actions { display: flex; gap: 10px; flex-shrink: 0; }

.back-link {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--muted); font-weight: 600; font-size: 12.5px;
  margin-bottom: 10px;
}
.back-link:hover { color: var(--primary); text-decoration: none; }

h2 { font-size: 15.5px; margin: 0 0 4px; font-weight: 800; }
h2.panel-title { margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
h2.panel-title .icon { color: var(--primary); }

/* ---------- Stat cards ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-xs);
}
.stat-card-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--primary-light); color: var(--primary);
}
.stat-card-success .stat-card-icon { background: var(--success-bg); color: var(--success); }
.stat-card-warning .stat-card-icon { background: var(--warning-bg); color: var(--warning); }
.stat-card-neutral .stat-card-icon { background: var(--bg-subtle); color: var(--text-secondary); }
.stat-card-value { font-size: 21px; font-weight: 800; line-height: 1.1; font-family: 'Manrope', sans-serif; }
.stat-card-label { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 2px; }

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--primary);
  color: var(--primary-fg);
  border: none;
  padding: 9px 17px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  font-size: 13.5px;
  font-family: inherit;
  box-shadow: var(--shadow-primary);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.button:hover { background: var(--primary-hover); text-decoration: none; transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-xs); }
.button.secondary:hover { background: var(--bg-subtle); transform: none; }
.button.ghost { background: transparent; color: var(--text-secondary); box-shadow: none; border: 1px solid transparent; }
.button.ghost:hover { background: var(--bg-subtle); color: var(--text); transform: none; }
.button.danger { background: var(--danger); box-shadow: 0 10px 22px -8px rgba(220, 38, 38, 0.45); }
.button.danger:hover { background: #b91c1c; }
.button.full { width: 100%; justify-content: center; }
.button.small {
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 700;
  background: var(--panel);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: none;
}
.button.small:hover { background: var(--primary-light); border-color: var(--primary-light-strong); color: var(--accent-fg); transform: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.icon-btn:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn:disabled:hover { background: var(--panel); color: var(--text-secondary); }

.link-button {
  background: none; border: none; color: var(--primary);
  cursor: pointer; padding: 0; font-size: 13px; font-weight: 600; font-family: inherit;
}
.link-button:hover { color: var(--primary-hover); }
.link-button.danger { color: var(--danger); }
.link-button.danger:hover { color: #b91c1c; }
.inline-form { display: inline; }

/* ---------- Panels / cards ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-xs);
  margin-bottom: 18px;
}
.panel:last-child { margin-bottom: 0; }

/* ---------- Table / list card ---------- */

.list-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.list-card-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.search-field {
  position: relative;
  max-width: 280px;
  flex: 1;
}
.search-field .icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.search-field input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 13px;
  background: var(--bg-subtle);
}
.search-field input:focus { background: var(--panel); }
.list-count { font-size: 12.5px; color: var(--muted); font-weight: 600; flex-shrink: 0; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table th { background: var(--bg-subtle); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.admin-table tbody tr { transition: background 0.12s ease; }
.admin-table tbody tr:hover { background: var(--bg-subtle); }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table-actions { display: flex; gap: 6px; justify-content: flex-end; }
.admin-table .empty-cell { padding: 48px 18px; text-align: center; color: var(--muted); }

.row-title { display: flex; align-items: center; gap: 12px; }
.row-thumb {
  width: 40px; height: 40px; border-radius: 9px; object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--border);
}
.row-thumb-placeholder {
  width: 40px; height: 40px; border-radius: 9px; flex-shrink: 0;
  background: var(--bg-subtle); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.row-title-text { font-weight: 700; color: var(--text); min-width: 0; }
.row-title-sub { font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 1px; }

.tag-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg-subtle); color: var(--text-secondary);
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}

.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.status-published { background: var(--success-bg); color: var(--success); }
.status-draft { background: var(--warning-bg); color: var(--warning); }
.badge { margin-left: 8px; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; background: var(--accent-bg); color: var(--accent-fg); padding: 2px 9px; border-radius: 999px; }

/* ---------- Alerts ---------- */

.error, .success {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; font-weight: 500;
  padding: 11px 15px; border-radius: var(--radius-sm);
  margin-bottom: 18px;
}
.error { color: var(--danger); background: var(--danger-bg); border: 1px solid var(--danger-border); }
.success { color: var(--success); background: var(--success-bg); border: 1px solid var(--success-border); }

/* ---------- Form controls ---------- */

input[type="text"], input[type="number"], input[type="datetime-local"],
input[type="password"], input[type="file"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
input[type="file"] { padding: 7px 9px; font-size: 13px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
textarea { resize: vertical; }

label { display: block; margin-bottom: 15px; font-weight: 700; font-size: 12.5px; color: var(--text-secondary); }
label:last-child { margin-bottom: 0; }
label .hint, .hint { font-weight: 400; color: var(--muted); font-size: 12px; text-transform: none; letter-spacing: 0; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.checkbox-label input { width: auto; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.span-2 { grid-column: span 2; }

.form-actions { display: flex; gap: 10px; margin-top: 22px; }

.inline-form-row { display: flex; gap: 10px; margin-bottom: 18px; align-items: flex-end; }
.inline-form-row > div { flex: 1; max-width: 320px; }
.inline-form-row label { margin-bottom: 0; }

/* ---------- Editor (post form) two-column layout ---------- */

.editor-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
  align-items: start;
}
.editor-main { min-width: 0; }
.editor-sidebar { min-width: 0; position: sticky; top: 30px; }

/* ---------- Block editor ---------- */

.block-add-toolbar { margin-bottom: 16px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.block-add-toolbar-label { font-size: 12px; font-weight: 700; color: var(--muted); margin-right: 2px; }
.button.small .icon { margin-right: 1px; }

.block-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.block-card:focus-within { border-color: var(--primary-light-strong); box-shadow: 0 0 0 3px var(--primary-light); }
.block-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.block-type { display: flex; align-items: center; gap: 7px; font-size: 11px; text-transform: uppercase; font-weight: 800; color: var(--primary); letter-spacing: 0.05em; }
.block-type .icon { color: var(--primary); }
.block-controls { display: flex; gap: 4px; align-items: center; }

.rt-toolbar { display: flex; gap: 4px; margin-bottom: 7px; }
.rt-btn {
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-secondary);
  padding: 4px 10px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.rt-btn:hover { background: var(--primary-light); border-color: var(--primary-light-strong); color: var(--accent-fg); }

.heading-row { display: flex; gap: 10px; }
.heading-row select { width: 84px; flex-shrink: 0; }

.code-input { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: 12.5px; background: var(--bg-subtle); }

.image-preview { margin-bottom: 10px; }
.image-preview img { max-width: 100%; max-height: 180px; border-radius: 8px; display: block; margin-bottom: 8px; border: 1px solid var(--border); }
.image-preview .hint { display: flex; align-items: center; gap: 6px; }

.cover-preview img { max-width: 100%; border-radius: 10px; display: block; margin-bottom: 8px; border: 1px solid var(--border); }

/* ---------- Auth pages ---------- */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(640px circle at 12% 8%, rgba(233, 30, 99, 0.14), transparent 55%),
    radial-gradient(520px circle at 88% 92%, rgba(194, 24, 91, 0.12), transparent 55%),
    var(--bg);
  padding: 20px;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 34px 30px;
  width: 360px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.auth-logo { height: 52px; width: 52px; margin: 0 auto 16px; display: block; border-radius: 13px; }
.auth-card h1 { font-size: 18px; margin-bottom: 4px; font-weight: 800; }
.auth-card p.auth-subtitle { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.auth-card .error, .auth-card .success { text-align: left; }
.auth-card form { text-align: left; }
.auth-card button { width: 100%; margin-top: 6px; justify-content: center; }
.auth-foot { margin-top: 20px; font-size: 12px; color: var(--muted); }

@media (max-width: 1080px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-sidebar { position: static; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .admin-sidebar { position: fixed; z-index: 20; transform: translateX(-100%); transition: transform 0.2s ease; }
  .admin-main { padding: 22px 16px 60px; }
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; }
}
