/* Darul Ihsaan CMS — admin + inline editor styles. Loaded only for admins. */

/* The [hidden] attribute must always win over component display rules below
   (.modal/#editToolbar/#insertMenu/#selToolbar set display:grid|flex, which would
   otherwise override hidden and leave an invisible full-screen overlay that
   swallows every click). */
[hidden] { display: none !important; }

/* Floating edit bar (bottom-right) */
#adminBar { position: fixed; right: 18px; bottom: 18px; z-index: 1000; display: flex; gap: 8px; }
#adminBar button, #adminBar a { display: inline-flex; align-items: center; justify-content: center; height: 48px; padding: 0 18px; border-radius: 999px; border: none; background: var(--di-grad); color: #fff; font-weight: 700; font-size: 1rem; cursor: pointer; box-shadow: var(--di-shadow-lg); text-decoration: none; }
#adminBar a#adminLink { width: 48px; padding: 0; font-size: 1.3rem; }
body.editing #editToggle { background: #b91c1c; }

/* Edit toolbar (sticky top when editing) */
#editToolbar { position: fixed; top: 0; left: 0; right: 0; z-index: 1001; display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 10px 16px; background: rgba(15,23,42,.96); backdrop-filter: blur(10px); box-shadow: 0 6px 24px rgba(15,23,42,.28); }
#editToolbar .tb-group { display: flex; gap: 8px; align-items: center; }
.tb-btn { background: #1e293b; color: #e2e8f0; border: 1px solid #334155; border-radius: 10px; padding: 9px 14px; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; transition: background .14s, transform .1s, border-color .14s; }
.tb-btn:hover { background: #334155; transform: translateY(-1px); }
.tb-btn:active { transform: translateY(0); }
.tb-btn--accent { background: rgba(53,134,139,.18); border-color: rgba(53,134,139,.5); color: #99e6ec; }
.tb-btn--accent:hover { background: rgba(53,134,139,.3); }
.tb-btn--save { background: var(--di-grad); border: none; color: #fff; font-weight: 700; }
.tb-btn--save:disabled { opacity: .6; cursor: default; transform: none; }
.tb-status { color: #94a3b8; font-size: .82rem; font-weight: 500; }
body.editing { padding-top: 60px; }
body.editing [data-edit] { outline: 2px dashed rgba(53,134,139,.6); outline-offset: 5px; border-radius: 8px; min-height: 1em; transition: outline-color .15s, background .15s; }
body.editing [data-edit]:focus { outline: 2px solid var(--di-teal); background: rgba(53,134,139,.045); }

/* Insert-block menu */
#insertMenu { position: fixed; z-index: 1003; width: 220px; max-height: 70vh; overflow: auto; background: #fff; border: 1px solid var(--di-border); border-radius: 16px; box-shadow: var(--di-shadow-lg); padding: 8px; display: grid; gap: 2px; }
.ins { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 11px; border: none; background: none; border-radius: 10px; font: inherit; font-size: .92rem; font-weight: 500; color: var(--di-ink); cursor: pointer; text-align: left; }
.ins:hover { background: var(--di-bg-3); }
.ins__i { width: 26px; height: 26px; flex: none; border-radius: 7px; background: var(--di-bg-3); display: grid; place-items: center; font-size: .8rem; font-weight: 800; color: var(--di-teal-deep); }
.ins__i[data-i="h2"]::before { content: "H2"; } .ins__i[data-i="h3"]::before { content: "H3"; }
.ins__i[data-i="p"]::before { content: "¶"; } .ins__i[data-i="ul"]::before { content: "•"; }
.ins__i[data-i="ol"]::before { content: "1."; font-size: .7rem; } .ins__i[data-i="quote"]::before { content: "❝"; }
.ins__i[data-i="callout"]::before { content: "★"; } .ins__i[data-i="button"]::before { content: "▭"; }
.ins__i[data-i="image"]::before { content: "🖼"; } .ins__i[data-i="embed"]::before { content: "▶"; }
.ins__i[data-i="cols"]::before { content: "⫶⫶"; letter-spacing:-2px; } .ins__i[data-i="divider"]::before { content: "—"; }

/* Floating selection toolbar */
#selToolbar { position: fixed; z-index: 1004; display: flex; gap: 2px; padding: 5px; background: #0f172a; border-radius: 12px; box-shadow: 0 8px 28px rgba(15,23,42,.4); }
#selToolbar button { background: none; border: none; color: #e2e8f0; width: 34px; height: 34px; border-radius: 8px; font-size: .95rem; cursor: pointer; transition: background .12s; }
#selToolbar button:hover { background: #334155; }
/* Text-colour control: an "A" over the live swatch; the native input is the
   clickable surface, kept visually inside the chip. */
#selColor { position: relative; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; overflow: hidden; transition: background .12s; }
#selColor:hover { background: #334155; }
#selColor span { position: absolute; top: 4px; left: 0; right: 0; text-align: center; color: #e2e8f0; font-weight: 800; font-size: .85rem; pointer-events: none; z-index: 1; }
#selColor input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; margin: 0; border: none; background: none; cursor: pointer; opacity: 0; }
#selColor::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 5px; height: 3px; border-radius: 2px; background: currentColor; color: #5fd3dd; pointer-events: none; }

.admin-banner { background: var(--di-amber-bg); color: var(--di-amber-text); padding: 10px 0; text-align: center; font-weight: 600; font-size: .95rem; }
.toast { position: fixed; bottom: 80px; right: 18px; z-index: 1002; background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--di-shadow-lg); opacity: 0; transform: translateY(8px); transition: .2s; }
.toast.show { opacity: 1; transform: none; }
.toast.err { background: #b91c1c; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--di-bg-2); padding: 20px; }
.login-card { background: #fff; border: 1px solid var(--di-border); border-radius: var(--di-radius-card); padding: 36px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; box-shadow: var(--di-shadow); }
.login-card h1 { font-size: 1.4rem; margin: 0; }
.login-card input { width: 100%; padding: 13px 16px; border: 1px solid var(--di-border); border-radius: var(--di-radius-btn); font-size: 1rem; }
.login-card .btn { width: 100%; justify-content: center; }
.login-card .err { color: #b91c1c; font-weight: 600; margin: 0; }

/* Dashboard */
.admin-top { background: #0f172a; color: #fff; padding: 11px 0; }
/* Brand stays left; the full nav flows to the right and WRAPS onto more rows
   instead of squashing — every admin link is always visible, never clipped. */
.admin-top .container { display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; }
.admin-top nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 5px; margin-left: auto; }
.admin-top nav > * { white-space: nowrap; }
.admin-top a { color: #cbd5e1; font-weight: 600; }
.admin-top a:not(.admin-user):not(.btn) { padding: 6px 11px; border-radius: 8px; transition: background .14s, color .14s; }
.admin-top a:not(.admin-user):not(.btn):hover { background: rgba(255,255,255,.09); color: #fff; }
.admin-top a[aria-current="page"] { background: var(--di-teal); color: #fff; }
.admin-nav__ext { opacity: .8; }
.admin-nav__ext::before { content: ""; display: inline-block; width: 1px; height: 14px; background: rgba(255,255,255,.18); margin-right: 9px; vertical-align: -2px; }
.admin-user { display: inline-flex; align-items: center; gap: 6px; color: #e2e8f0; font-weight: 600; font-size: .84rem; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); padding: 5px 12px; border-radius: 999px; max-width: 200px; overflow: hidden; white-space: nowrap; }
.admin-user span { overflow: hidden; text-overflow: ellipsis; }
.admin-user svg { color: #9fe0e6; flex: none; }
.admin-brand__cms { color: #94a3b8; font-weight: 700; font-size: .92rem; letter-spacing: .06em; text-transform: uppercase; }
@media (max-width: 640px) {
  .admin-top .container { gap: 8px 12px; }
  .admin-top a:not(.admin-user):not(.btn) { padding: 6px 9px; font-size: .92rem; }
  .admin-user { max-width: 150px; padding: 5px 10px; }
}
.admin-main { padding: 28px 0 80px; }
.panel { background: #fff; border: 1px solid var(--di-border); border-radius: var(--di-radius-card); margin-top: 22px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--di-border); }
.panel-head h2 { margin: 0; font-size: 1.2rem; }
.cms-table { width: 100%; border-collapse: collapse; }
.cms-table th, .cms-table td { padding: 12px 22px; text-align: left; border-bottom: 1px solid var(--di-bg-3); font-size: .95rem; vertical-align: middle; }
.cms-table .slug { color: var(--di-muted); font-size: .82rem; }
.cms-table .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.mini { border: 1px solid var(--di-border); background: #fff; border-radius: 8px; padding: 6px 12px; font-size: .85rem; cursor: pointer; color: var(--di-ink); text-decoration: none; }
.mini:hover { background: var(--di-bg-3); }
.mini.danger { color: #b91c1c; border-color: #fecaca; }
.s { padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.s--published { background: var(--di-success-bg); color: var(--di-success); }
.s--draft { background: var(--di-bg-3); color: var(--di-muted); }
.s--scheduled { background: var(--di-amber-bg); color: var(--di-amber-text); }
.btn--sm { padding: 8px 14px; font-size: .9rem; }

/* ---- Dashboard refinements (scheduling, templates, modal) ---- */
.admin-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; }
.admin-brand img { border-radius: 8px; }
.admin-brand .muted { color: #94a3b8; font-weight: 600; }
.admin-intro { margin: 28px 0 8px; }
.admin-intro h1 { font-size: 1.7rem; margin: 0 0 4px; }
.admin-credit { max-width: var(--di-maxw); margin: 24px auto 0; padding: 20px 20px 36px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px solid var(--di-border); color: var(--di-muted); font-size: .82rem; }
.admin-credit__by { font-weight: 700; color: var(--di-teal-deep); }
@media (max-width: 560px) { .admin-credit { flex-direction: column; gap: 4px; text-align: center; } }
.panel-head h2 .count { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; margin-left: 6px; border-radius: 999px; background: var(--di-bg-3); color: var(--di-muted); font-size: .8rem; font-weight: 700; vertical-align: middle; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cms-table .ta-r { text-align: right; }
.cms-table td.empty { text-align: center; padding: 30px; }

/* Template selector — custom chevron, token-aligned, with a save flash */
.tpl { display: inline-block; position: relative; }
.tpl-select {
  appearance: none; -webkit-appearance: none;
  font: inherit; font-size: .85rem; font-weight: 600; color: var(--di-ink);
  padding: 7px 30px 7px 12px; border: 1px solid var(--di-border); border-radius: var(--di-radius-sm);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.tpl-select:hover { border-color: var(--di-teal); }
.tpl-select:focus { outline: none; border-color: var(--di-teal); box-shadow: 0 0 0 3px rgba(53,134,139,.18); }
.tpl-select.saved { border-color: var(--di-success); box-shadow: 0 0 0 3px var(--di-success-bg); }
.mini.primary-ghost { color: var(--di-teal-deep); border-color: rgba(53,134,139,.4); font-weight: 700; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 20px; background: rgba(15,23,42,.45); backdrop-filter: blur(5px); opacity: 0; transition: opacity .2s ease; }
.modal.show { opacity: 1; }
.modal-card { background: #fff; border-radius: var(--di-radius-card); padding: 30px; width: 100%; max-width: 430px; max-height: calc(100dvh - 32px); overflow-y: auto; box-shadow: var(--di-shadow-lg); transform: translateY(10px) scale(.98); transition: transform .2s cubic-bezier(.2,.8,.2,1); }
/* Keep the actions reachable at the bottom of a long, scrolling form */
.modal-card .modal-actions { position: sticky; bottom: -30px; margin: 24px -30px -30px; padding: 16px 30px; background: #fff; border-top: 1px solid var(--di-border); }
.modal.show .modal-card { transform: none; }
.modal-card h3 { margin: 0 0 6px; font-size: 1.25rem; }
.modal-card .muted { margin: 0 0 18px; font-size: .95rem; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 700; color: var(--di-muted); }
.field input { font: inherit; font-weight: 500; color: var(--di-ink); padding: 13px 14px; border: 1px solid var(--di-border); border-radius: var(--di-radius-btn); }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--di-teal); box-shadow: 0 0 0 3px rgba(53,134,139,.18); }
.field textarea { font: inherit; font-weight: 500; color: var(--di-ink); padding: 11px 13px; border: 1px solid var(--di-border); border-radius: 12px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* Properties modal */
.modal-card--wide { max-width: 520px; }
.modal-card--wide .field, .modal-card--wide .check { margin-top: 15px; }
.check { display: flex; align-items: center; gap: 10px; font-size: .92rem; font-weight: 600; color: var(--di-ink); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--di-teal); }
.img-preview { margin-top: 8px; border: 1px solid var(--di-border); border-radius: 12px; overflow: hidden; background: var(--di-bg-3); }
.img-preview img { width: 100%; max-height: 170px; object-fit: cover; display: block; }
.cms-table .lock { font-size: .82rem; }

/* Hero slider editor */
.hero-savebar { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; gap: 16px; padding: 16px 0; margin-top: 22px; background: linear-gradient(transparent, var(--di-bg) 30%); }
.hslides { padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 16px; }
.hslide { border: 1px solid var(--di-border); border-radius: var(--di-radius-card); padding: 18px; background: var(--di-bg-2); }
.hslide-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.hslide-actions { display: flex; gap: 6px; }
.hgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.hgrid-btns { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--di-border); }
.hf { display: flex; flex-direction: column; gap: 5px; font-size: .82rem; font-weight: 600; color: var(--di-muted); }
.hf.hf-wide { grid-column: 1 / -1; }
.hf span b { color: var(--di-teal-deep); }
.hf input[type=text], .hf input[type=url], .hf input[type=number], .hf select, .hf textarea {
  font: inherit; font-weight: 500; color: var(--di-ink); padding: 10px 12px; border: 1px solid var(--di-border); border-radius: 10px; background: #fff;
}
.hf input:focus, .hf select:focus, .hf textarea:focus { outline: none; border-color: var(--di-teal); box-shadow: 0 0 0 3px rgba(53,134,139,.18); }
.hf input[type=range] { accent-color: var(--di-teal); }
.hf-check { flex-direction: row; align-items: center; gap: 9px; }
.hf-check input { width: 18px; height: 18px; accent-color: var(--di-teal); }
.hcolor { display: flex; gap: 8px; align-items: stretch; }
.hcolor input[type=text] { flex: 1; }
.hcolor-swatch { width: 42px; flex: none; padding: 0; border: 1px solid var(--di-border); border-radius: 10px; background: none; cursor: pointer; }
.hcolor-swatch::-webkit-color-swatch-wrapper { padding: 4px; }
.hcolor-swatch::-webkit-color-swatch { border: none; border-radius: 6px; }
.hcolor-swatch::-moz-color-swatch { border: none; border-radius: 6px; }
@media (max-width: 640px) { .hgrid { grid-template-columns: 1fr; } }

@media (max-width: 640px) {
  #editToolbar { gap: 4px; padding: 8px; }
  #editToolbar button { padding: 7px 9px; font-size: .82rem; }
  .cms-table th, .cms-table td { padding: 12px 14px; }
  .cms-table .actions { gap: 6px; }
  .mini { padding: 7px 10px; }
  .modal-card { padding: 24px; }
  .modal-card .modal-actions { margin: 20px -24px -24px; padding: 14px 24px; bottom: -24px; }
  .modal-actions .btn { flex: 1; justify-content: center; }
}

/* ─────────────────────────────────────────────────────────────
   State-of-the-art refresh — sticky glass header, gradient title,
   stat tiles, softer panels/tables. Loaded after base rules so it wins.
   ───────────────────────────────────────────────────────────── */
body { background: #f1f5f9; }
.admin-top { position: sticky; top: 0; z-index: 40; background: rgba(15,23,42,.95); backdrop-filter: blur(12px); box-shadow: 0 2px 24px rgba(15,23,42,.14); padding: 12px 0; }
.admin-top a:not(.admin-user):not(.btn) { padding: 7px 12px; border-radius: 9px; transition: background .15s, color .15s; }
.admin-top a:not(.admin-user):not(.btn):hover { background: rgba(255,255,255,.1); color: #fff; }
.admin-brand { font-size: 1.1rem; gap: 12px; }
.admin-brand img { width: auto !important; height: 42px !important; border-radius: 6px; filter: brightness(0) invert(1); }
.admin-main { padding: 24px 0 90px; }

/* Content tables — tighter, calmer action row */
.panel { padding: 4px 4px 8px; }
.panel-head { padding: 16px 18px 10px; }
.cms-table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--di-muted); font-weight: 700; }
.cms-table td .slug { font-size: .78rem; color: var(--di-muted); margin-top: 2px; }
.cms-table td.actions { white-space: nowrap; }
.cms-table td.actions .mini { padding: 6px 10px; font-size: .8rem; border-radius: 8px; }
.cms-table td.actions .mini.danger { color: var(--di-danger); }
.s { font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; text-transform: capitalize; }
.s--published { background: var(--di-success-bg); color: var(--di-success); }
.s--draft { background: var(--di-bg-3); color: var(--di-muted); }
.s--scheduled { background: var(--di-amber-bg); color: var(--di-amber-text); }
.admin-intro h1 { font-family: var(--di-font-display); background: var(--di-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 18px 0 28px; }
.stat-tile { display: flex; flex-direction: column; gap: 3px; background: #fff; border: 1px solid var(--di-border); border-radius: 16px; padding: 18px 20px; box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 20px rgba(15,23,42,.05); text-decoration: none; position: relative; overflow: hidden; transition: transform .14s, box-shadow .14s, border-color .14s; }
.stat-tile::before { content: ""; position: absolute; left: 0; top: 0; height: 3px; width: 100%; background: var(--di-grad); transform: scaleX(0); transform-origin: left; transition: transform .3s; }
.stat-tile:hover { transform: translateY(-3px); box-shadow: var(--di-shadow-lg); border-color: rgba(53,134,139,.3); text-decoration: none; }
.stat-tile:hover::before { transform: scaleX(1); }
.stat-tile__n { font-family: var(--di-font-display); font-size: 2rem; font-weight: 800; line-height: 1; color: var(--di-ink); }
.stat-tile__l { font-size: .8rem; font-weight: 700; color: var(--di-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-tile__ic { position: absolute; right: 14px; top: 14px; font-size: 1.15rem; opacity: .55; }

.panel { border-radius: 18px; box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 10px 30px rgba(15,23,42,.05); }
.cms-table tbody tr { transition: background .12s; }
.cms-table tbody tr:hover { background: var(--di-bg-2); }
.mini { transition: border-color .14s, color .14s, background .14s, transform .1s; }
.mini:hover { border-color: var(--di-teal); color: var(--di-teal-deep); transform: translateY(-1px); }

/* Mobile: collapse the admin nav behind a burger */
.admin-burger{display:none;margin-left:auto;width:44px;height:44px;border:0;border-radius:10px;background:rgba(255,255,255,.08);cursor:pointer;flex-direction:column;align-items:center;justify-content:center;gap:5px;padding:0}
.admin-burger span{display:block;width:22px;height:2px;background:#fff;border-radius:2px;transition:transform .18s,opacity .18s}
.admin-burger[aria-expanded="true"] span:nth-child(1){transform:translateY(7px) rotate(45deg)}
.admin-burger[aria-expanded="true"] span:nth-child(2){opacity:0}
.admin-burger[aria-expanded="true"] span:nth-child(3){transform:translateY(-7px) rotate(-45deg)}
@media(max-width:860px){
  .admin-burger{display:flex}
  .admin-top nav{display:none;flex-basis:100%;flex-direction:column;align-items:stretch;gap:2px;margin:6px 0 0;max-height:75vh;overflow:auto}
  .admin-top nav.open{display:flex}
  .admin-top nav a:not(.admin-user):not(.btn){padding:12px 14px}
}
