/* Theme tokens. Defaults are the "Default Dark" look; a theme (Admin -> Content -> Themes) changes any of them. */
:root {
  --bg: #0f1115;
  --card: #151923;
  --text: #e7eaf0;
  --muted: #aab3c5;
  --border: #23283a;
  --border-hover: #2f3752;
  --accent: #5ea2ff;
  --accent-text: #06101f;
  --danger: #ff5e6a;
  --danger-text: #24060a;
  --ok: #35d07f;
  --ok-text: #06180f;
  --warning: #c8891a;
  --input-bg: #0b0d12;
  --btn-bg: #1b2233;
  --tile-bg: #0b0d12;
  --hover: rgba(255, 255, 255, 0.08);
  --subtle: rgba(255, 255, 255, 0.03);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-size: 16px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(0,0,0,.25);
  --page-width: 1100px;
  --bg-image: none;
  --bg-repeat: no-repeat;
  --bg-size: cover;
  --bg-pos: center;
  --bg-attach: fixed;
  --scheme: dark;
  /* old names some plugin pages still use */
  --color-warning: var(--warning);
  --color-success: var(--ok);
  --color-border-primary: var(--border);
  color-scheme: var(--scheme);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--font-size);
  background-color: var(--bg);
  background-image: var(--bg-image);
  background-repeat: var(--bg-repeat);
  background-size: var(--bg-size);
  background-position: var(--bg-pos);
  background-attachment: var(--bg-attach);
  color: var(--text);
}

a { color: var(--link, var(--accent)); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--link-hover, var(--link, var(--accent))); }

.container { max-width: var(--page-width); margin: 0 auto; padding: 22px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 260px; }

h1,h2,h3,h4 { font-family: var(--heading-font, inherit); }
h1,h2,h3 { margin: 0 0 12px; color: var(--heading, inherit); }
.small { color: var(--muted); font-size: 0.92rem; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  outline: none;
}
textarea { min-height: 120px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; padding: 0; margin: 0 6px 0 0; vertical-align: middle; }

label { display:block; margin: 10px 0 6px; color: var(--muted); }

.btn {
  display: inline-block;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: var(--border-hover); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-text); font-weight: 650; }
.btn.danger { background: var(--danger); border-color: transparent; color: var(--danger-text); font-weight: 650; }
.btn.ok { background: var(--ok); border-color: transparent; color: var(--ok-text); font-weight: 650; }

.topbar {
  display:flex; justify-content: space-between; align-items:center;
  gap: 14px; margin-bottom: 16px;
}
.nav a { margin-right: 12px; color: var(--muted); }
.nav a:hover { color: var(--text); }

.alert { padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin: 12px 0; }
.alert.bad { border-color: rgba(255,94,106,.35); background: rgba(255,94,106,.10); }
.alert.good { border-color: rgba(53,208,127,.35); background: rgba(53,208,127,.10); }

.table { width:100%; border-collapse: collapse; }
.table th, .table td { text-align:left; padding: 10px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; }

/* --- Dashboard grid/tiles --- */
.grid {
  display:grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  gap: 12px;
}

.tile {
  position: relative;
  background: var(--tile-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding: 10px;
}

.tile .title { padding: 10px; }

.tile img {
  width:100%;
  height:100%;
  object-fit: cover;
  display:block;
}

.tile .overlay {
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  background: rgba(0,0,0,.45);
  opacity: 0;
  transition: opacity .12s ease-in-out;
}

.tile:hover .overlay { opacity: 1; }

.tile .overlay span {
  background: color-mix(in srgb, var(--card) 88%, transparent);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Disabled tile behavior + lock icon */
.tile.disabled {
  opacity: .62;
  cursor: not-allowed;
}
.tile.disabled a { pointer-events: none; }
.tile.disabled:hover .overlay { opacity: 1; } /* keep overlay but it's not clickable */

.tile.disabled .overlay span::before {
  content: "🔒";
  font-size: 1.05em;
  line-height: 1;
  opacity: 0.95;
}

/* Responsive grid */
@media (max-width: 980px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); } }


/* ---- Dashboard blocks (zones) ---- */
.zones { display: flex; flex-direction: column; gap: 16px; }
.zone, .zone-row { min-width: 0; }
.zone { display: flex; flex-direction: column; gap: 16px; }
.zone-row { display: grid; gap: 16px; align-items: start; }
.zone-row > .zone { min-width: 0; overflow: hidden; }
.zone > * { min-width: 0; }
.block { min-width: 0; max-width: 100%; overflow: hidden; container-type: inline-size; }
.block .block-title { margin-top: 0; }
.block-body { min-width: 0; max-width: 100%; overflow-x: auto; }
.block-body img, .block-body video, .block-body canvas, .block-body svg, .block-body iframe { max-width: 100%; height: auto; }
.block-body table { max-width: 100%; }
.block-body pre { overflow-x: auto; }
/* Tiles: honour the "tiles per row" setting, but never squeeze a tile below ~84px. When the zone is
   too narrow for the configured count the grid drops a column (auto-fill), so nothing overflows. */
.block .grid { grid-template-columns: repeat(auto-fill, minmax(max(84px, calc((100% - (var(--cols, 5) - 1) * var(--tile-gap, 12px)) / var(--cols, 5))), 1fr)); }
/* Fixed tile size (Admin -> Tiles -> Tile size): square tiles of --tile-size, at most --cols per row,
   wrapping to fewer when the zone is narrow. */
.block .grid.grid-sized {
  display: flex; flex-wrap: wrap;
  max-width: calc(var(--cols, 5) * var(--tile-size) + (var(--cols, 5) - 1) * var(--tile-gap, 12px));
  justify-content: var(--tile-justify, flex-start);
  margin-left: var(--tile-ml, 0); margin-right: var(--tile-mr, auto);
}
.block .grid.grid-sized > .tile { flex: 0 0 var(--tile-size); width: var(--tile-size); max-width: 100%; }
/* Auto tiles per row: as many as fit, wrapping with the available width. */
.block .grid.grid-auto { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); max-width: none; }
.block .grid.grid-sized.grid-auto { max-width: none; margin-left: 0; margin-right: 0; }
@container (max-width: 130px) { .block .grid.grid-auto { grid-template-columns: 1fr; } }
/* phones and small tablets: one column, middle first */
@media (max-width: 820px) {
  .zone-row { grid-template-columns: 1fr !important; justify-content: stretch !important; }
  .zone-row > .zone-middle { order: 1; }
  .zone-row > .zone-left   { order: 2; }
  .zone-row > .zone-right  { order: 3; }
}

/* nav dropdown (Admin -> Audit) */
.nav .nav-menu { display: inline-block; position: relative; margin-right: 12px; }
.nav .nav-menu > summary { list-style: none; cursor: pointer; color: var(--muted); display: inline; }
.nav .nav-menu > summary::-webkit-details-marker { display: none; }
.nav .nav-menu > summary::after { content: " \25BE"; font-size: 11px; }
.nav .nav-menu > summary:hover, .nav .nav-menu[open] > summary { color: var(--text); }
.nav .nav-menu-list { position: absolute; z-index: 20; top: 100%; left: 0; margin-top: 6px; min-width: 130px; padding: 6px; border-radius: var(--radius-sm);
  background: var(--card, #161b24); border: 1px solid var(--border, #3a4358); box-shadow: var(--shadow); }
.nav .nav-menu-list a { display: block; margin: 0; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.nav .nav-menu-list a:hover { background: var(--hover); }

/* Account menu sits at the right edge: open it leftwards so it never runs off screen */
.nav .nav-menu-right { left: auto; right: 0; }

/* notifications bell */
.nav .nav-bell > summary::after { content: none; }
.nav .nav-bell > summary { display: inline-flex; align-items: center; gap: 4px; }
.nav .nav-bell svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bell-count { background: #c62828; color: #fff; font-size: 11px; line-height: 1; padding: 3px 6px; border-radius: 999px; font-weight: 700; }
.nav .bell-list { min-width: 280px; max-width: min(360px, 92vw); white-space: normal; }
.nav .bell-list a { white-space: normal; }
.nav .bell-list a.unread { font-weight: 600; border-left: 3px solid var(--accent, #4a90e2); }
.nav .bell-list a small { display: block; font-weight: 400; opacity: .7; }
.nav .bell-list .bell-foot { border-top: 1px solid var(--border, rgba(128,128,128,.3)); margin-top: 4px; padding-top: 4px; }
.notif-row { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border, rgba(128,128,128,.25)); flex-wrap: wrap; }
.notif-row.unread .notif-title { font-weight: 700; }
.notif-row .notif-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.notif-row .notif-actions form { margin: 0; }
@media (max-width: 640px) {
  .utilbar { position: relative; }
  .nav .nav-bell { position: static; }
  .nav .nav-bell .bell-list { position: absolute; left: 8px; right: 8px; top: 100%; min-width: 0; max-width: none; }
}

/* profile wall */
.wall-post { padding: 12px 0; border-bottom: 1px solid var(--border, rgba(128,128,128,.25)); }
.wall-post:last-child { border-bottom: 0; }
.wall-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.wall-reply { margin: 10px 0 0 18px; padding-left: 12px; border-left: 3px solid var(--border, rgba(128,128,128,.35)); }
.wall-del { margin: 6px 0 0; }
.wall-del .btn { padding: 2px 8px; font-size: 12px; }
.wall-replybox { margin: 10px 0 0 18px; }
.wall-replybox > summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* utility bar (full width, above the page) */
.utilbar { position: relative; z-index: 30; width: 100%; background: var(--card); border-bottom: 1px solid var(--border); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.utilbar-in { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 8px 18px; min-height: 42px; }
.utilbar-in a { margin-right: 0; }
.ub-left, .ub-right { display: flex; align-items: center; gap: 16px; min-width: 0; flex-wrap: wrap; }
.ub-right { justify-content: flex-end; }
.ub-brand { font-weight: 700; color: var(--text) !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; text-align: center; justify-self: center; }
.utilbar .ub-link { color: var(--muted); white-space: nowrap; }
.utilbar .ub-link:hover { color: var(--text); }
.utilbar .nav-menu { margin-right: 0; }
.utilbar .nav-menu > summary { display: inline-flex; align-items: center; gap: 6px; }
.utilbar .nav-user > summary::after { content: " \25BE"; font-size: 11px; }
.ub-avatar { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 6px; background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.ub-clock { color: var(--muted); font-size: 13px; white-space: nowrap; }
.utilbar + .container { padding-top: 16px; }
@media (max-width: 640px) {
  .utilbar-in { padding: 6px 10px; gap: 8px; grid-template-columns: 1fr auto; }
  .ub-left, .ub-right { gap: 10px; }
  .ub-brand, .ub-clock, .utilbar .ub-label { display: none; }
  .utilbar .nav-bell .ub-label { display: none; }
}
