﻿:root {
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --border-subtle: #F1F5F9;
  --text: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --success: #16A34A;
  --warning: #D97706;
  --danger: #DC2626;
  --radius: 8px;
  --shadow: none;
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --sidebar-bg: #1E293B;
  --sidebar-border: rgba(255,255,255,0.08);
  --sidebar-text: rgba(255,255,255,0.7);
  --sidebar-text-active: #FFFFFF;
  --sidebar-text-muted: rgba(255,255,255,0.35);
  --sidebar-text-subtle: rgba(255,255,255,0.45);
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-active: rgba(255,255,255,0.08);
  --sidebar-placeholder: rgba(255,255,255,0.15);
  --sidebar-avatar-color: rgba(255,255,255,0.90);
  --sidebar-logout-hover: rgba(255,255,255,0.10);
  --primary-fg: #FFFFFF;
  --accent-fg: #FFFFFF;
  --primary-readable: #2563EB; /* overridden by theme.css for light themes */

  /* ── Post content typography — shared by editor (TinyMCE content_style),
        preview modal (.preview-content), and published post (.post-body).
        Change here → update the matching value in TINYMCE_INLINE_CONFIG
        content_style in news-editor.html (TinyMCE cannot read CSS vars). ── */
  --post-p-margin: 0 0 5px;
}

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

html, body {
  font-family: sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

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

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

/* ── Sidebar — flat dark slate, no gradient ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: none;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.2s;
  font-size: 14px;
  line-height: 1.5;
  box-sizing: border-box;
}

.sidebar-logo {
  padding: 16px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--topbar-height);
}
.sidebar-logo img { height: 28px; width: 28px; object-fit: contain; border-radius: 5px; }
.sidebar-logo .logo-placeholder {
  width: 28px; height: 28px;
  background: var(--sidebar-placeholder);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--sidebar-text-active); font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.sidebar-logo span {
  font-weight: 600; font-size: 13.5px; color: var(--sidebar-text-active);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }

.nav-section { margin-bottom: 2px; }
.nav-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  color: var(--sidebar-text-muted); padding: 8px 20px 3px;
  text-transform: uppercase; line-height: 1.4;
}

/* Active state: left accent bar instead of rounded highlight */
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 20px; border-radius: 0;
  color: var(--sidebar-text); font-weight: 500;
  cursor: pointer; transition: background 0.12s, color 0.12s;
  text-decoration: none; font-size: 13px;
  line-height: 1.4; box-sizing: border-box;
  border-left: 2px solid transparent;
  margin: 1px 0;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  text-decoration: none;
}
.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  font-weight: 600;
  border-left-color: var(--primary);
}
.nav-item .nav-icon {
  font-size: 15px; width: 18px; text-align: center; flex-shrink: 0;
  opacity: 0.75;
}
.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-user .user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--sidebar-placeholder); color: var(--sidebar-avatar-color);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0; overflow: hidden;
}
.sidebar-user .user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-weight: 600; font-size: 12.5px; color: var(--sidebar-text-active); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 10.5px; color: var(--sidebar-text-subtle); text-transform: capitalize; }
.sidebar-user .logout-btn {
  background: none; border: none; cursor: pointer; color: var(--sidebar-text-subtle);
  font-size: 11px; font-weight: 500; padding: 4px 6px; border-radius: 4px;
  white-space: nowrap; font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.sidebar-user .logout-btn:hover { color: var(--sidebar-text-active); background: var(--sidebar-logout-hover); }

/* ── Main content area ── */
.main { margin-left: var(--sidebar-width); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* Topbar — clean white, single border, no shadow ── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  height: var(--topbar-height);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title {
  font-weight: 700; font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

/* Topbar buttons — always visible regardless of theme colour */
.topbar .btn-primary {
  border: 1px solid var(--primary-dark);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.topbar .btn-ghost {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.topbar .btn-ghost:hover {
  background: var(--border);
  color: var(--text);
}
.topbar .btn-secondary {
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* Global search */
.global-search-wrap { flex: 1; max-width: 380px; margin: 0 auto; position: relative; }
.global-search-input {
  width: 100%; padding: 7px 14px 7px 36px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; font-family: inherit; outline: none;
  background: var(--bg); color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.global-search-input:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 3px var(--primary-light); }
.global-search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 13px; pointer-events: none; color: var(--text-light); }
.search-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: white; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1); z-index: 200; overflow: hidden; display: none;
}
.search-dropdown.show { display: block; }
.search-group-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-light); padding: 10px 14px 4px;
}
.search-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  cursor: pointer; text-decoration: none; color: inherit; transition: background 0.1s;
}
.search-item:hover, .search-item.focused { background: var(--bg); }
.search-item-icon {
  width: 30px; height: 30px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; overflow: hidden;
}
.search-item-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.search-item-title { font-size: 13px; font-weight: 600; line-height: 1.3; }
.search-item-sub { font-size: 11px; color: var(--text-muted); }
.search-divider { height: 1px; background: var(--border); margin: 4px 0; }
.search-empty { padding: 18px 14px; text-align: center; color: var(--text-muted); font-size: 13px; }

.page-content { padding: 24px; flex: 1; }

/* ── Cards — border only, no shadow, clean ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: none;
  padding: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }

/* ── Grid ── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ── Buttons — solid, no gradients, restrained ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; font-size: 13px;
  font-weight: 600; cursor: pointer; border: none;
  transition: background 0.12s, opacity 0.12s; white-space: nowrap;
  font-family: inherit; letter-spacing: 0.01em;
}
.btn:active { opacity: 0.88; }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: #CBD5E1; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #B91C1C; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 11.5px; }
.btn-icon { padding: 6px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 5px; color: var(--text); }
.form-control {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 13.5px; font-family: inherit; color: var(--text);
  background: var(--surface); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-control::placeholder { color: var(--text-light); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
}
.badge-blue   { background: #DBEAFE; color: #1E40AF; }
.badge-green  { background: #D1FAE5; color: #065F46; }
.badge-red    { background: #FEE2E2; color: #991B1B; }
.badge-yellow { background: #FEF3C7; color: #92400E; }
.badge-purple { background: #EDE9FE; color: #5B21B6; }
.badge-gray   { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 9px 14px;
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--bg); letter-spacing: 0.03em;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFBFD; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 44px; margin-bottom: 10px; }
.empty-state h3 { font-size: 15px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.empty-state p { font-size: 13px; }

/* ── Alerts ── */
.alert {
  padding: 11px 14px; border-radius: 6px;
  font-size: 13px; margin-bottom: 14px; display: flex; gap: 8px; align-items: flex-start;
}
.alert-success { background: #D1FAE5; color: #065F46; }
.alert-danger  { background: #FEE2E2; color: #991B1B; }
.alert-warning { background: #FEF3C7; color: #92400E; }
.alert-info    { background: #DBEAFE; color: #1E40AF; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  /* Dim, don't blur — the page behind a dialog must stay readable so you can
     refer to it while filling the form in. Keep this in sync with the one-off
     dialog backdrops: #layoutModal (admin/branding.html), #imgLinkModal (news-editor.html). */
  background: rgba(15,23,42,0.40);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: 10px;
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,0.2);
  border: 1px solid var(--border);
}
.modal-header {
  padding: 18px 22px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-muted); }
.modal-body { padding: 14px 22px 22px; }

/* ── Avatar ── */
.avatar {
  border-radius: 50%; object-fit: cover;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 42px; height: 42px; font-size: 15px; }
.avatar-lg { width: 60px; height: 60px; font-size: 22px; }

/* ── Utility ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12.5px; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Loading spinner ── */
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--primary);
  animation: spin 0.65s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center; padding: 60px; }

/* ── Pagination ── */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 24px; }
.page-btn {
  padding: 5px 11px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 13px; font-family: inherit;
  color: var(--text-muted);
}
.page-btn.active { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.page-btn:hover:not(.active) { background: var(--bg); color: var(--text); }

/* ── Tag pills ── */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 4px;
  font-size: 11.5px; font-weight: 500;
  background: var(--bg); color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Post card — fixed height so every tile is uniform regardless of content length ── */
.post-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color 0.15s; cursor: pointer;
  display: flex; flex-direction: column;
  height: 340px;
}
.post-card:hover { border-color: #CBD5E1; box-shadow: var(--shadow-md); }
.post-card-cover-wrap {
  width: 100%; height: 160px; flex-shrink: 0;
  background: var(--primary-light); overflow: hidden; position: relative;
}
.post-card-cover { width: 100%; height: 160px; object-fit: cover; display: block; }
.post-card-cover-placeholder {
  width: 100%; height: 100%;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center; font-size: 38px;
}
.post-card-body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.post-card-cat { margin-bottom: 7px; }
.post-card-title {
  font-weight: 700; font-size: 14px; margin-bottom: 6px; line-height: 1.4; letter-spacing: -0.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-card-excerpt {
  font-size: 13px; color: var(--text-muted); line-height: 1.55; margin-bottom: 12px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); margin-top: auto; }

/* ── Stat card — flat icon, no gradient ── */
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 18px 20px;
  display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px; border-radius: 8px;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-value { font-size: 24px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Search bar ── */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 11px;
}
.search-bar input { border: none; background: transparent; outline: none; font-size: 13px; font-family: inherit; flex: 1; }
.search-bar input::placeholder { color: var(--text-light); }

/* ── Sidebar mobile toggle ── */
.sidebar-toggle {
  display: none; background: none; border: none;
  font-size: 18px; cursor: pointer; color: var(--text-muted); padding: 4px;
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.2); }
  .main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
}
