/* ==========================================================================
   Thornhill Corporation — Admin panel styles
   ========================================================================== */
body.admin { background: var(--bg-alt); min-height: 100vh; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-side {
  background: #05070b; color: #f4f6fa; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-side::before {
  content: ""; position: absolute; width: 640px; height: 640px; border-radius: 50%; left: -200px; bottom: -260px;
  background: radial-gradient(circle, rgba(37, 99, 235, .5), transparent 65%);
}
.login-side::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 48px 48px; mask-image: linear-gradient(to bottom, #000, transparent); -webkit-mask-image: linear-gradient(to bottom, #000, transparent);
}
.login-side > * { position: relative; z-index: 1; }
.login-side .brand { color: #fff; }
.login-side h2 { color: #fff; font-size: clamp(2rem, 3.5vw, 2.8rem); max-width: 440px; }
.login-side p { color: #a8b1c2; max-width: 420px; }
.login-side small { color: #6f7a8f; }
.login-main { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); position: relative; }
.login-main .theme-toggle { position: absolute; top: 24px; right: 24px; }
.login-main .back { position: absolute; top: 28px; left: 24px; font-weight: 600; font-size: .9rem; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.login-main .back:hover { color: var(--accent); }
.login-main .back svg { width: 16px; height: 16px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .lock { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 24px; }
.login-card .lock svg { width: 26px; height: 26px; }
.login-card h1 { font-size: 2rem; }
.login-card .field { margin-bottom: 18px; }
.code-wrap { position: relative; }
.code-wrap input { padding-right: 52px; letter-spacing: .08em; }
.code-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; cursor: pointer; padding: 8px; color: var(--text-3); border-radius: 8px; }
.code-wrap button:hover { color: var(--text); }
.code-wrap svg { width: 18px; height: 18px; display: block; }
.form-error { display: none; padding: 12px 14px; border-radius: 12px; margin-bottom: 18px; font-size: .9rem; font-weight: 600;
  background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.form-error.show { display: block; }
.demo-note { margin-top: 22px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--border); font-size: .85rem; color: var(--text-2); }
.demo-note code { font-weight: 700; color: var(--text); }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@media (max-width: 860px) { .login-wrap { grid-template-columns: 1fr; } .login-side { display: none; } }

/* ---------- Dashboard shell ---------- */
.dash { display: none; }
.dash.show { display: block; }
.topbar { position: sticky; top: 0; z-index: 30; background: var(--nav-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 16px; }
.topbar .tag { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); margin-left: 6px; }
.user-chip { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: .9rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; font-family: var(--font-display); font-size: .85rem; }
@media (max-width: 640px) { .user-chip .uname, .topbar .tag { display: none; } }

.dash-main { padding: 36px 0 80px; }
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.dash-head h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); margin: 0; }
.dash-head p { margin: 4px 0 0; }

.banner { padding: 14px 18px; border-radius: 14px; margin-bottom: 24px; font-size: .9rem; display: flex; gap: 12px; align-items: flex-start;
  background: color-mix(in srgb, var(--warning) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); color: var(--text); }
.banner svg { width: 20px; height: 20px; color: var(--warning); flex: none; margin-top: 1px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; }
.stat span { font-size: .82rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; display: flex; align-items: center; gap: 8px; }
.stat strong { display: block; font-family: var(--font-display); font-size: 2rem; margin-top: 6px; }
.stat .pip { width: 8px; height: 8px; border-radius: 50%; }
@media (max-width: 760px) { .stats { grid-template-columns: 1fr 1fr; } }

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); padding: 4px; border-radius: 999px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: .85rem; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.tabs button.active { background: var(--text); color: var(--bg); }
.tabs button .c { opacity: .6; margin-left: 4px; }
.search { flex: 1; min-width: 200px; position: relative; }
.search input { padding-left: 42px; border-radius: 999px; background: var(--surface); }
.search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; }
@media (max-width: 1020px) { .workspace { grid-template-columns: 1fr; } }

.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; padding: 18px 20px; border-top: 1px solid var(--border); cursor: pointer; transition: background-color .15s; width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; }
.item:first-child { border-top: 0; }
.item:hover { background: var(--surface-2); }
.item.selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.item .avatar { width: 40px; height: 40px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.item.unread .avatar { background: var(--accent); color: #fff; border-color: transparent; }
.item h4 { font-family: var(--font-body); font-size: .95rem; margin: 0; letter-spacing: 0; display: flex; gap: 8px; align-items: center; }
.item .subj { font-size: .9rem; font-weight: 600; color: var(--text); margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .prev { font-size: .85rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
.item .meta { text-align: right; font-size: .78rem; color: var(--text-3); display: grid; gap: 6px; justify-items: end; }
.item > div { min-width: 0; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.new { color: var(--accent); background: var(--accent-soft); }
.status.in_progress { color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, transparent); }
.status.resolved { color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); }

.empty { text-align: center; padding: 64px 24px; color: var(--text-3); }
.empty svg { width: 44px; height: 44px; margin: 0 auto 14px; opacity: .6; }
.empty strong { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }

.detail { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); position: sticky; top: 88px; max-height: calc(100vh - 108px); overflow: auto; }
.detail-head { padding: 26px 28px 20px; border-bottom: 1px solid var(--border); }
.detail-head .ref { margin: 0 0 12px; font-size: .8rem; padding: 4px 10px; }
.detail-head h2 { font-size: 1.4rem; margin-bottom: 14px; }
.who { display: flex; gap: 14px; align-items: center; }
.who .avatar { width: 46px; height: 46px; background: var(--accent); color: #fff; }
.who strong { display: block; }
.who a { color: var(--accent); font-weight: 600; font-size: .92rem; word-break: break-all; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border-bottom: 1px solid var(--border); }
.facts div { background: var(--surface); padding: 14px 18px; }
.facts span { display: block; font-size: .72rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; }
.facts strong { font-size: .9rem; word-break: break-word; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr 1fr; } }
.detail-body { padding: 24px 28px; }
.detail-body h5 { font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); margin: 0 0 10px; font-family: var(--font-body); }
.message-box { white-space: pre-wrap; word-break: break-word; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin-bottom: 24px; font-size: .95rem; line-height: 1.7; }
.manage { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 20px; }
.manage textarea { min-height: 90px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 20px 28px 26px; border-top: 1px solid var(--border); }
.actions .spacer { flex: 1; }
.detail .close-detail { display: none; }

@media (max-width: 1020px) {
  .detail { position: fixed; inset: 0; top: 0; max-height: none; border-radius: 0; z-index: 60; transform: translateX(100%); transition: transform .3s var(--ease); }
  .detail.open { transform: none; }
  .detail .close-detail { display: inline-flex; margin-bottom: 14px; }
  .workspace .detail.placeholder { display: none; }
}

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(5, 7, 11, .55); display: none; place-items: center; padding: 20px; backdrop-filter: blur(4px); }
.modal.open { display: grid; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); animation: pop .25s var(--ease); }
.modal-card h3 { font-size: 1.25rem; }
.modal-card .row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ==========================================================================
   Section switcher + Document hub
   ========================================================================== */
.view-switch { display: inline-flex; gap: 4px; padding: 5px; margin-bottom: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow); }
.view-switch button { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer; padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: .92rem; color: var(--text-2); transition: background-color .2s, color .2s; }
.view-switch button svg { width: 17px; height: 17px; }
.view-switch button:hover { color: var(--text); }
.view-switch button.active { background: var(--text); color: var(--bg); }
.count-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .72rem; display: inline-grid; place-items: center; }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.doc-grid > .empty { grid-column: 1 / -1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
@media (max-width: 420px) { .doc-grid { grid-template-columns: 1fr; } }
.doc-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; display: flex; flex-direction: column; gap: 14px; transition: border-color .2s, box-shadow .2s; }
.doc-card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); box-shadow: var(--shadow); }
.doc-top { display: flex; gap: 14px; align-items: flex-start; }
.doc-icon { width: 46px; height: 46px; flex: none; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: .78rem; letter-spacing: .04em; }
.doc-icon svg { width: 22px; height: 22px; }
.doc-icon.google { background: var(--accent-soft); color: var(--accent); }
.doc-icon.pdf { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.doc-meta { flex: 1; min-width: 0; }
.doc-meta h3 { font-size: 1.05rem; margin: 0 0 2px; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.doc-meta span { font-size: .82rem; color: var(--text-3); font-weight: 600; }
.vis { font-size: .72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.vis.public { background: var(--accent-soft); color: var(--accent); }
.doc-desc { margin: 0; font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.doc-foot { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }
.doc-foot small { color: var(--text-3); font-size: .8rem; }
.doc-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.link-box { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 12px; background: var(--bg-alt); border: 1px dashed var(--border); }
.link-box span { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem; font-weight: 600; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-box.small .btn { padding: 6px 12px; }

/* Modal for documents */
.modal { overflow-y: auto; }
.modal-wide { max-width: 580px; max-height: calc(100vh - 40px); overflow-y: auto; }
.modal-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-top h3 { margin: 0; }
.modal-wide .field { margin-bottom: 18px; }
.modal-wide textarea { min-height: 90px; }
.modal-wide .check strong { display: contents; }
.hint .ok { color: var(--success); font-weight: 600; }
.hint .bad { color: var(--danger); font-weight: 600; }

.source-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .source-switch { grid-template-columns: 1fr; } }
.source-opt { cursor: pointer; }
.source-opt input { position: absolute; opacity: 0; pointer-events: none; }
.source-opt span { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; padding: 14px 16px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--bg); transition: border-color .2s, background-color .2s; }
.source-opt svg { width: 22px; height: 22px; grid-row: span 2; color: var(--text-3); }
.source-opt strong { font-size: .92rem; }
.source-opt small { font-size: .78rem; color: var(--text-3); }
.source-opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.source-opt input:checked + span svg { color: var(--accent); }
.source-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 28px 20px; border-radius: 14px; border: 2px dashed var(--border); background: var(--bg); cursor: pointer; transition: border-color .2s, background-color .2s; }
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--accent); }
.dropzone svg { width: 34px; height: 34px; color: var(--accent); }
.dropzone strong { font-size: .95rem; overflow-wrap: anywhere; }
.dropzone small { color: var(--text-3); font-size: .82rem; }

.slug-input { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); overflow: hidden; transition: border-color .2s, box-shadow .2s; }
.slug-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.slug-input span { display: flex; align-items: center; padding: 0 4px 0 14px; color: var(--text-3); font-size: .88rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); border-right: 1px solid var(--border); padding-right: 10px; }
.field .slug-input input { border: 0; box-shadow: none !important; border-radius: 0; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92rem; }
@media (max-width: 520px) { .slug-input { flex-direction: column; } .slug-input span { padding: 8px 14px; border-right: 0; border-bottom: 1px solid var(--border); } }

.doc-success { text-align: center; padding: 8px 4px; }
.doc-success .tick { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.doc-success .tick svg { width: 30px; height: 30px; }
.doc-success .link-box { margin: 18px 0 6px; text-align: left; }
.doc-success .link-box span { font-size: .92rem; }

#enquiriesView, #documentsView, #redirectsView { padding: 0; }
.slug-input.readonly { background: var(--surface-2); }
.field .slug-input.readonly input { background: transparent; color: var(--accent); font-weight: 700; cursor: default; }

/* ---------- Link Hub: redirects list ---------- */
.stats.stats-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 760px) { .stats.stats-3 { grid-template-columns: 1fr 1fr; } }
.stat .top-link { font-size: 1.1rem; margin-top: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.red-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.red-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 20px; align-items: center; padding: 18px 22px; border-top: 1px solid var(--border); }
.red-row:first-child { border-top: 0; }
.red-row:hover { background: var(--surface-2); }
.red-main { min-width: 0; display: grid; gap: 4px; }
.red-short { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; color: var(--accent); font-size: .98rem; overflow-wrap: anywhere; }
.red-short .dom { color: var(--text-3); font-weight: 600; }
.red-dest { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: .88rem; min-width: 0; }
.red-dest svg { width: 15px; height: 15px; flex: none; color: var(--text-3); }
.red-dest span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.red-label { font-size: .8rem; color: var(--text-3); font-weight: 600; }
.red-clicks { text-align: center; min-width: 64px; }
.red-clicks strong { display: block; font-family: var(--font-display); font-size: 1.3rem; }
.red-clicks span { font-size: .75rem; color: var(--text-3); font-weight: 600; }
.red-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.red-list > .empty { border: 0; }
@media (max-width: 900px) {
  .red-row { grid-template-columns: minmax(0, 1fr) auto; }
  .red-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
.view-switch .hub-link { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: .92rem; color: var(--text-2); transition: background-color .2s, color .2s; }
.view-switch .hub-link:hover { color: var(--accent); background: var(--accent-soft); }
.view-switch .hub-link svg { width: 17px; height: 17px; }
.view-switch .hub-link svg.ext { width: 14px; height: 14px; opacity: .7; }
