/* ==========================================================================
   HopeLink SACCO — Admin panel styles
   ========================================================================== */
:root {
  --primary: #1d9187; --primary-dark: #0f4944; --primary-darker: #0a2e2b;
  --primary-light: #e6f3f1; --accent: #f6cb15; --border: #e1e8e6; --border-strong: #cfdad7;
  --text: #10201d; --muted: #5c6b68; --bg: #f3f6f5; --surface: #fff;
  --danger: #c0402f; --danger-light: #fbe9e6; --warn: #8a6d00; --warn-light: #fdf3d6;
  --info: #2b5c9e; --info-light: #e7eef9;
  --font-display: 'Plus Jakarta Sans', sans-serif; --font-body: 'Inter', sans-serif;
  --radius: 12px; --shadow: 0 1px 2px rgba(10,46,43,0.05), 0 4px 16px rgba(10,46,43,0.04);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-body); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--font-display); color: var(--primary-darker); margin: 0; line-height: 1.2; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---- Layout ---- */
.admin-shell { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }
.admin-sidebar {
  background: var(--primary-darker); color: #cfe4e0; padding: 1.3rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.2rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.2rem 0.6rem 1.3rem; }
.admin-brand img { height: 26px; filter: brightness(0) invert(1); }
.admin-brand span { font-family: var(--font-display); font-weight: 700; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); border: 1px solid rgba(246,203,21,0.4); border-radius: 999px; padding: 0.1rem 0.5rem; }
.nav-group-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: #6f9590; padding: 1rem 0.7rem 0.35rem; }
.admin-nav a {
  display: flex; align-items: center; gap: 0.65rem; padding: 0.55rem 0.7rem; border-radius: 8px;
  font-weight: 500; font-size: 0.9rem; color: #b9cdc9; transition: background 0.15s, color 0.15s;
}
.admin-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.admin-nav a.is-active { background: var(--primary); color: #fff; font-weight: 600; }
.admin-nav svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-count { margin-left: auto; background: var(--accent); color: var(--primary-darker); font-size: 0.7rem; font-weight: 800; border-radius: 999px; padding: 0.05rem 0.45rem; min-width: 20px; text-align: center; }
.admin-sidebar .sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.08); }

.admin-main { min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.8rem clamp(1rem, 3vw, 2.2rem); background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.admin-topbar .menu-btn { display: none; background: none; border: 0; padding: 0.4rem; cursor: pointer; color: var(--primary-darker); }
.topbar-right { display: flex; align-items: center; gap: 0.8rem; margin-left: auto; }
.topbar-user { display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-light); color: var(--primary-darker); display: grid; place-items: center; font-weight: 800; font-size: 0.8rem; font-family: var(--font-display); }
.topbar-user small { display: block; color: var(--muted); font-size: 0.74rem; }
.admin-content { padding: clamp(1.2rem, 3vw, 2.2rem); max-width: 1400px; width: 100%; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.page-head h1 { font-size: 1.55rem; }
.page-head p { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.9rem; }
.page-head .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.crumbs { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
.crumbs a { color: var(--primary); }

/* ---- Cards, stats ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; margin-bottom: 1.4rem; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.card-head h2 { font-size: 1.02rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 1.1rem 1.3rem 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; display: flex; gap: 0.9rem; align-items: center; box-shadow: var(--shadow); }
.stat .ico { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-light); color: var(--primary); flex-shrink: 0; }
.stat .ico svg { width: 20px; height: 20px; }
.stat .ico.warn { background: var(--warn-light); color: var(--warn); }
.stat .ico.info { background: var(--info-light); color: var(--info); }
.stat .n, .stat .l { display: block; }
.stat .n { font-family: var(--font-display); font-weight: 800; font-size: 1.55rem; color: var(--primary-darker); line-height: 1.1; }
.stat .l { font-size: 0.8rem; color: var(--muted); }
.stat:hover { border-color: var(--border-strong); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
.grid-2 > .card { margin-bottom: 0; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.table th { text-align: left; padding: 0.7rem 0.9rem; background: #f8faf9; color: var(--muted); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafcfb; }
.table .muted { color: var(--muted); font-size: 0.8rem; }
.table .strong { font-weight: 600; color: var(--primary-darker); }
.table .row-actions { display: flex; gap: 0.35rem; justify-content: flex-end; white-space: nowrap; }
.table tr.unread td { background: #fbfdf5; }
.table tr.unread .strong::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 0.45rem; vertical-align: middle; }
.thumb { width: 64px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--primary-light); }
.thumb.round { width: 40px; height: 40px; border-radius: 50%; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; background: #eef2f1; color: var(--muted); }
.badge.pending, .badge.new, .badge.draft, .badge.scheduled { background: var(--warn-light); color: var(--warn); }
.badge.approved, .badge.published, .badge.open, .badge.hired, .badge.active { background: var(--primary-light); color: var(--primary-darker); }
.badge.rejected, .badge.closed, .badge.inactive { background: var(--danger-light); color: var(--danger); }
.badge.shortlisted, .badge.interview, .badge.editor, .badge.officer { background: var(--info-light); color: var(--info); }
.badge.admin { background: var(--primary-darker); color: #fff; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; font-weight: 600; font-size: 0.84rem; padding: 0.55rem 0.95rem; border-radius: 8px; border: 1px solid transparent; cursor: pointer; font-family: inherit; line-height: 1.2; white-space: nowrap; transition: background 0.15s, border-color 0.15s; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: var(--primary-darker); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { border-color: var(--border-strong); color: var(--text); background: #fff; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-darker); }
.btn-ghost-danger { color: var(--danger); background: transparent; border-color: transparent; }
.btn-ghost-danger:hover { background: var(--danger-light); }
.btn-sm { padding: 0.35rem 0.6rem; font-size: 0.78rem; }
.btn-icon { padding: 0.4rem; }
form.inline { display: inline; margin: 0; }

/* ---- Filters ---- */
.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; padding: 1rem 1.3rem; border-bottom: 1px solid var(--border); }
.filters select, .filters input[type="search"] { padding: 0.5rem 0.75rem; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 0.85rem; font-family: inherit; background: #fff; }
.filters input[type="search"] { min-width: 240px; flex: 1; max-width: 360px; }
.tabs { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.tabs a { padding: 0.4rem 0.8rem; border-radius: 999px; font-size: 0.82rem; font-weight: 600; color: var(--muted); border: 1px solid transparent; }
.tabs a.is-active { background: var(--primary-light); color: var(--primary-darker); border-color: #cde6e2; }
.tabs a .c { opacity: 0.6; margin-left: 0.2rem; font-weight: 500; }

/* ---- Pagination ---- */
.pager { display: flex; gap: 0.3rem; justify-content: center; padding: 1rem; }
.pager a, .pager span { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); font-size: 0.85rem; font-weight: 600; padding: 0 0.5rem; background: #fff; }
.pager span.is-active { background: var(--primary-darker); color: #fff; border-color: var(--primary-darker); }
.pager a:hover { border-color: var(--primary); }

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.2rem; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-weight: 600; font-size: 0.83rem; color: var(--primary-darker); }
.field .hint { font-size: 0.76rem; color: var(--muted); }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="url"],
.field input[type="date"], .field input[type="datetime-local"], .field input[type="number"], .field input[type="tel"],
.field select, .field textarea {
  width: 100%; padding: 0.62rem 0.8rem; border: 1px solid var(--border-strong); border-radius: 8px;
  font-family: inherit; font-size: 0.9rem; background: #fff; color: var(--text);
}
.field textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
.field textarea.tall { min-height: 340px; font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 0.86rem; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(29,145,135,0.15); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field .error { color: var(--danger); font-size: 0.78rem; font-weight: 600; }
.check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; font-weight: 500; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.form-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }
.form-actions .spacer { flex: 1; }
.editor-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.4rem; align-items: start; }
.editor-layout .card { margin-bottom: 1.4rem; }
.format-help { font-size: 0.78rem; color: var(--muted); background: #f8faf9; border: 1px solid var(--border); border-radius: 8px; padding: 0.7rem 0.9rem; line-height: 1.7; }
.format-help code { background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: 0 0.3rem; font-size: 0.76rem; }
.image-preview { border-radius: 8px; overflow: hidden; background: var(--primary-light); aspect-ratio: 16/10; margin-bottom: 0.6rem; border: 1px solid var(--border); }
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-preview.square { aspect-ratio: 1; max-width: 200px; }

/* ---- Detail lists ---- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem 1.5rem; margin: 0; font-size: 0.9rem; }
.detail-grid dt { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.detail-grid dd { margin: 0.15rem 0 0; word-break: break-word; }
.detail-grid .wide { grid-column: 1 / -1; }
.section-title { font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; color: var(--primary-darker); margin: 1.8rem 0 0.9rem; padding-top: 1.3rem; border-top: 1px solid var(--border); }
.section-title:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.message-body { white-space: pre-wrap; background: #f8faf9; border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.1rem; font-size: 0.92rem; }

/* ---- Flash ---- */
.flash { display: flex; gap: 0.6rem; align-items: center; padding: 0.85rem 1.1rem; border-radius: 10px; margin-bottom: 1.3rem; font-size: 0.88rem; font-weight: 600; }
.flash.success { background: var(--primary-light); color: var(--primary-darker); border: 1px solid #cde6e2; }
.flash.error { background: var(--danger-light); color: var(--danger); border: 1px solid #f3cfc8; }
.flash svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---- Dashboard bits ---- */
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 130px; padding-top: 0.5rem; }
.bar-chart .bar { flex: 1; background: var(--primary-light); border-radius: 4px 4px 0 0; position: relative; min-height: 3px; }
.bar-chart .bar span { position: absolute; inset: auto 0 0 0; background: var(--primary); border-radius: 4px 4px 0 0; }
.bar-chart .bar:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--primary-darker); color: #fff; font-size: 0.72rem; padding: 0.25rem 0.5rem; border-radius: 6px; white-space: nowrap; z-index: 2; }
.chart-legend { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--muted); margin-top: 0.4rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; padding: 0.7rem 0; border-bottom: 1px solid var(--border); font-size: 0.87rem; }
.list li:last-child { border-bottom: 0; }
.list .meta { color: var(--muted); font-size: 0.78rem; }
.quick-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.7rem; }
.quick-links a { display: flex; align-items: center; gap: 0.6rem; padding: 0.8rem; border: 1px solid var(--border); border-radius: 10px; font-weight: 600; font-size: 0.85rem; }
.quick-links a:hover { border-color: var(--primary); background: #fafcfb; }
.quick-links svg { width: 18px; height: 18px; color: var(--primary); }

/* ---- Media slots ---- */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.1rem; }
.slot { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.slot img { aspect-ratio: 16/10; object-fit: cover; width: 100%; background: var(--primary-light); }
.slot-body { padding: 0.8rem 0.9rem 0.9rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.slot-body strong { font-size: 0.87rem; }
.slot-body .badge { align-self: flex-start; }
.slot-body input[type="file"] { font-size: 0.78rem; max-width: 100%; }
.slot-body .slot-actions { display: flex; gap: 0.4rem; margin-top: auto; flex-wrap: wrap; }

/* ---- Login ---- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--surface); }
.login-visual { position: relative; background: var(--primary-darker) center/cover no-repeat; }
.login-visual::after { content: ''; position: absolute; inset: 0; background: linear-gradient(160deg, rgba(10,46,43,0.55), rgba(10,46,43,0.92)); }
.login-visual .quote { position: absolute; left: 3rem; right: 3rem; bottom: 3rem; z-index: 1; color: #fff; }
.login-visual .quote h2 { color: #fff; font-size: 1.9rem; max-width: 18ch; margin-bottom: 0.6rem; }
.login-visual .quote p { color: #cfe4e0; margin: 0; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.login-box { width: 100%; max-width: 380px; }
.login-box img { height: 36px; margin-bottom: 2rem; }
.login-box h1 { font-size: 1.5rem; margin-bottom: 0.4rem; }
.login-box .sub { color: var(--muted); margin: 0 0 1.8rem; font-size: 0.9rem; }
.login-box .field { margin-bottom: 1rem; }
.login-box .btn { width: 100%; padding: 0.8rem; font-size: 0.92rem; margin-top: 0.4rem; }
.login-box .back { display: inline-block; margin-top: 1.5rem; font-size: 0.83rem; color: var(--primary); }

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .editor-layout { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 50; transform: translateX(-100%); transition: transform 0.25s; }
  body.nav-open .admin-sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,0.4); }
  .admin-topbar .menu-btn { display: inline-flex; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar-user .who { display: none; }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
}
