/* Admin panel shell: top bar, sidebar, shared panel styles. */
/* Prefix is "ap-", not "ad-": ad blockers hide elements with classes like .ad-sidebar / .ad-main. */
:root {
  --ap-bg: #0e0f10;
  --ap-surface: #17181a;
  --ap-surface-2: #1f2023;
  --ap-border: #2c2e32;
  --ap-text: #e9ecef;
  --ap-muted: #8b9096;
  --ap-accent: #ffc107;
  --ap-accent-ink: #1a1400;
  --ap-ok: #2fbf71;
  --ap-warn: #f0a020;
  --ap-bad: #e5534b;
  --ap-topbar-h: 56px;
  --ap-side-w: 232px;
  --ap-side-w-min: 64px;
}

body.admin-shell { background: var(--ap-bg); color: var(--ap-text); font-size: 14px; margin: 0; padding: 0; min-height: 100vh; }

/* ---------- top bar ---------- */
.ap-topbar { position: fixed; inset: 0 0 auto 0; height: var(--ap-topbar-h); z-index: 1030; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--ap-surface); border-bottom: 1px solid var(--ap-border); }
.ap-brand { display: flex; align-items: center; gap: 10px; color: var(--ap-text); text-decoration: none; font-weight: 600; letter-spacing: .04em; }
.ap-brand:hover { color: var(--ap-text); }
.ap-brand img { height: 28px; }
.ap-brand span { font-size: 13px; text-transform: uppercase; }
.ap-proj-btn { display: flex; align-items: center; gap: 10px; background: var(--ap-surface-2); border: 1px solid var(--ap-border); color: var(--ap-text); border-radius: 6px; padding: 5px 12px; min-width: 220px; text-align: left; }
.ap-proj-btn:hover { border-color: #3d4045; }
.ap-proj-btn .code { font-weight: 700; }
.ap-proj-menu { width: 320px; padding: 8px; background: var(--ap-surface-2); border-color: var(--ap-border); }
.ap-proj-menu .list { max-height: 380px; overflow-y: auto; }
.ap-proj-menu .dropdown-item { border-radius: 4px; font-weight: 600; }
.ap-proj-menu .dropdown-item.active { background: rgba(255, 193, 7, .15); color: var(--ap-text); }
.ap-icon-btn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; color: var(--ap-muted); background: transparent; border: 0; font-size: 17px; }
.ap-icon-btn:hover { background: var(--ap-surface-2); color: var(--ap-text); }

/* ---------- sidebar ---------- */
.ap-sidebar { position: fixed; top: var(--ap-topbar-h); bottom: 0; left: 0; width: var(--ap-side-w); background: var(--ap-surface); border-right: 1px solid var(--ap-border); overflow-y: auto; overflow-x: hidden; padding: 12px 8px; transition: width .15s, transform .15s; z-index: 1020; flex-wrap: nowrap !important; }
.ap-sidebar .ap-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ap-muted); padding: 14px 10px 6px; white-space: nowrap; }
.ap-sidebar .nav-link { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 6px; color: #c5c9ce; white-space: nowrap; position: relative; width: 100%; text-align: left; font-weight: 500; }
.ap-sidebar .nav-link i { font-size: 17px; width: 20px; text-align: center; flex: none; }
.ap-sidebar .nav-link:hover { background: var(--ap-surface-2); color: var(--ap-text); }
.ap-sidebar .nav-link.active { background: rgba(255, 193, 7, .12); color: var(--ap-accent); }
.ap-sidebar .nav-link.active::before { content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px; width: 3px; border-radius: 2px; background: var(--ap-accent); }
.ap-sidebar .ap-count { margin-left: auto; font-size: 11px; background: #33363b; color: var(--ap-text); border-radius: 10px; padding: 1px 7px; }
.ap-sidebar .ap-count:empty { display: none; }
body.ap-collapsed .ap-sidebar { width: var(--ap-side-w-min); }
body.ap-collapsed .ap-sidebar .ap-label, body.ap-collapsed .ap-sidebar .ap-count { display: none; }
body.ap-collapsed .ap-sidebar .ap-group { visibility: hidden; height: 10px; padding: 0; }
body.ap-collapsed .ap-main { margin-left: var(--ap-side-w-min); }

/* ---------- main ---------- */
.ap-main { margin-left: var(--ap-side-w); padding: calc(var(--ap-topbar-h) + 20px) 24px 40px; transition: margin-left .15s; }
.ap-page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.ap-page-head h1 { font-size: 22px; font-weight: 600; margin: 0; }
.ap-page-head .sub { color: var(--ap-muted); }
.ap-page-head .actions { margin-left: auto; display: flex; gap: 8px; }

.tab-content .tab-pane { display: none !important; }
.tab-content .tab-pane.active.show { display: block !important; }

/* Empty / loading state before a project is open */
#apNoProject { display: none; min-height: 50vh; align-items: center; justify-content: center; text-align: center; color: var(--ap-muted); }
body.ap-no-project #apNoProject { display: flex; }
body.ap-no-project #adminTabContent { display: none; }

/* ---------- shared panel styles (replace the inline-styled grey boxes) ---------- */
.admin-panel { background: var(--ap-surface); border: 1px solid var(--ap-border); border-radius: 8px; padding: 20px; margin-bottom: 20px; max-width: 100%; }
.admin-panel > .h4:first-child, .admin-panel .h4.text-white { font-size: 18px; font-weight: 600; }
.ap-panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--ap-border); }
.ap-panel-head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.ap-panel-head .tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.admin-panel.p-0 .ap-panel-body { padding: 16px; }
.ap-link { color: var(--ap-muted); text-decoration: none; font-size: 13px; cursor: pointer; }
.ap-link:hover { color: var(--ap-accent); }

/* Bootstrap leftovers inside panels: match the dark theme */
.admin-shell .table-dark { --bs-table-bg: var(--ap-surface); --bs-table-border-color: var(--ap-border); --bs-table-hover-bg: #1c1d20; }
.admin-shell .table-responsive.border { border-color: var(--ap-border) !important; }
.admin-shell .form-control.bg-black, .admin-shell .form-select.bg-black { background-color: var(--ap-surface-2) !important; border-color: var(--ap-border) !important; }
.admin-shell .input-group-text.bg-dark { background-color: #26282c !important; border-color: var(--ap-border) !important; }
.admin-shell .card { background: var(--ap-surface); border-color: var(--ap-border); }
.admin-shell .card-header { background: var(--ap-surface-2); border-color: var(--ap-border); font-size: 15px; font-weight: 600; }
.admin-shell .btn-warning { --bs-btn-color: var(--ap-accent-ink); }

/* Photos tab */
.ap-drop { border: 2px dashed #3a3d42; border-radius: 8px; padding: 18px 12px; text-align: center; color: var(--ap-muted); }
.ap-drop i { font-size: 26px; display: block; margin-bottom: 6px; color: var(--ap-accent); }
.ap-drop input[type=file] { margin-top: 10px; }
.ap-label { font-size: 12px; color: var(--ap-muted); margin-bottom: 4px; display: block; }
@media (min-width: 1400px) { #lightbox-gallery-admin .col-md-4 { width: 25%; } }
@media (min-width: 1800px) { #lightbox-gallery-admin .col-md-4 { width: 20%; } }

/* Overview */
.ap-stat { padding: 14px 16px; cursor: pointer; transition: border-color .12s; margin-bottom: 0; height: 100%; }
.ap-stat:hover { border-color: #44474d; }
.ap-stat .k { color: var(--ap-muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.ap-stat .v { font-size: 28px; font-weight: 700; line-height: 1.15; margin-top: 4px; }
.ap-stat .d { font-size: 12px; color: var(--ap-muted); }
.ap-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.ap-ph-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ap-ph-strip a, .ap-ph-strip div { aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: #2a2c30; display: block; }
.ap-ph-strip img { width: 100%; height: 100%; object-fit: cover; }
.ap-feed { list-style: none; margin: 0; padding: 0; }
.ap-feed li { display: flex; gap: 12px; padding: 10px 16px; border-bottom: 1px solid #232528; }
.ap-feed li:last-child { border-bottom: 0; }
.ap-feed .ic { width: 30px; height: 30px; border-radius: 6px; background: var(--ap-surface-2); display: flex; align-items: center; justify-content: center; flex: none; color: var(--ap-muted); }
.ap-feed .t { color: var(--ap-muted); font-size: 12px; }
.ap-feed .empty { color: var(--ap-muted); }
.ap-meter { height: 8px; border-radius: 4px; background: #2c2e32; overflow: hidden; }
.ap-meter > div { height: 100%; background: var(--ap-ok); width: 0; transition: width .3s; }

/* ---------- mobile ---------- */
@media (max-width: 991.98px) {
  .ap-sidebar { transform: translateX(-100%); width: var(--ap-side-w); }
  body.ap-nav-open .ap-sidebar { transform: none; box-shadow: 12px 0 30px rgba(0,0,0,.4); }
  .ap-main, body.ap-collapsed .ap-main { margin-left: 0; padding-left: 16px; padding-right: 16px; }
  .ap-proj-btn { min-width: 0; }
  .ap-brand span { display: none; }
  .ap-ph-strip { grid-template-columns: repeat(2, 1fr); }
}

/* Project card photo preview (Photos tab) */
.ap-cover-preview { aspect-ratio: 16 / 8; border-radius: 6px; background: var(--ap-surface-2); border: 1px solid var(--ap-border); overflow: hidden; display: flex; align-items: center; justify-content: center; text-align: center; padding: 0; }
.ap-cover-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- admin tool pages (Projects, Users, Invites, Access Codes) ---------- */
.ap-crumb { color: var(--ap-muted); font-size: 13px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.ap-crumb a { color: var(--ap-muted); text-decoration: none; }
.ap-crumb a:hover { color: var(--ap-accent); }
.ap-crumb strong { color: var(--ap-text); font-weight: 600; }
.ap-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--ap-border); }
.ap-toolbar .form-control, .ap-toolbar .form-select { max-width: 340px; }
.ap-toolbar .form-select { max-width: 200px; }
.ap-toolbar .meta { margin-left: auto; color: var(--ap-muted); font-size: 13px; }
.ap-status { color: var(--ap-muted); font-size: 13px; padding: 10px 16px 0; }
.ap-status:empty { display: none; }
.ap-table-wrap { padding: 4px 0 0; }
.admin-shell .ap-table { margin: 0; --bs-table-bg: transparent; --bs-table-striped-bg: rgba(255,255,255,.025); --bs-table-hover-bg: #1c1d20; --bs-table-border-color: #232528; }
.admin-shell .ap-table > thead th { color: var(--ap-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; border-bottom-color: var(--ap-border); white-space: nowrap; background: var(--ap-surface); }
.admin-shell .ap-table > :not(caption) > * > * { padding: 9px 12px; }
.admin-shell .ap-table > :not(caption) > * > :first-child { padding-left: 16px; }
.admin-shell .ap-table > :not(caption) > * > :last-child { padding-right: 16px; }
.admin-shell .ap-table code { color: var(--ap-text); font-size: 13px; }
.ap-note { color: var(--ap-muted); font-size: 12px; padding: 12px 16px; border-top: 1px solid var(--ap-border); }
.ap-field-hint { color: var(--ap-muted); font-size: 12px; margin-top: 4px; }
.ap-field-hint code { color: var(--ap-muted); }
.ap-box { background: var(--ap-bg); border: 1px solid var(--ap-border); border-radius: 6px; padding: 10px 12px; }
.ap-box.scroll { max-height: 300px; overflow: auto; }
#usersTable th.sel, #usersTable td.sel { width: 36px; }
#usersTable td:nth-child(2) { min-width: 140px; word-break: break-word; }
#usersTable td:nth-child(3) { min-width: 200px; overflow-wrap: anywhere; }
#usersTable td:nth-child(4) { min-width: 120px; }
#usersTable td:nth-child(n+5) { white-space: nowrap; }

/* Dark modals */
.admin-shell .modal-content { background: var(--ap-surface); border: 1px solid var(--ap-border); border-radius: 10px; color: var(--ap-text); }
.admin-shell .modal-header, .admin-shell .modal-footer { border-color: var(--ap-border); }
.admin-shell .modal-footer.sticky { position: sticky; bottom: 0; background: var(--ap-surface); z-index: 5; }
.admin-shell .modal-title { font-size: 17px; font-weight: 600; }
.admin-shell .form-label { color: #c5c9ce; font-size: 13px; font-weight: 500; }
.admin-shell .modal .form-control, .admin-shell .modal .form-select { background-color: var(--ap-surface-2); border-color: var(--ap-border); }
.admin-shell .dropdown-item.active { background: rgba(255, 193, 7, .15); color: var(--ap-text); }

/* Script-generated cards (Users mobile list, Invites groups) */
.ap-tool-page .card.bg-dark { background: var(--ap-surface) !important; border-color: var(--ap-border) !important; border-radius: 8px; }
#invitesRoot .card-body { padding: 0; }
#invitesRoot .card-body > .d-flex:first-child { padding: 14px 16px; }
#invitesRoot .card-body > hr { display: none; }
#invitesRoot .card-body > .mb-3 { margin: 0 !important; border-top: 1px solid var(--ap-border); }
#invitesRoot .bg-secondary { background: var(--ap-surface-2) !important; padding: 2px 6px; flex-wrap: wrap; column-gap: 12px; }
#invitesRoot .table th, #invitesRoot .table td:not([colspan]) { white-space: nowrap; }
#invitesRoot .table-responsive { margin-top: 0 !important; }
#invitesRoot .table { --bs-table-bg: transparent; --bs-table-border-color: #232528; }
#invitesRoot .table th { color: var(--ap-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
#invitesRoot .table > :not(caption) > * > :first-child { padding-left: 16px; }
#invitesRoot .text-monospace { font-family: var(--bs-font-monospace); font-size: 13px; }
.ap-empty { color: var(--ap-muted); text-align: center; padding: 40px 16px; }

@media (max-width: 991.98px) {
  .ap-crumb .sep, .ap-crumb .home { display: none; }
}
@media (max-width: 575.98px) {
  .ap-page-head .actions { margin-left: 0; width: 100%; }
  .ap-toolbar .form-control, .ap-toolbar .form-select { max-width: none; flex: 1 1 140px; }
  .ap-toolbar .meta { margin-left: 0; width: 100%; }
}

/* Project editor: Details / Access tabs */
.ap-tabs { border-bottom: 1px solid var(--ap-border); padding: 0 16px; flex-wrap: nowrap; }
.ap-tabs .nav-link { color: var(--ap-muted); border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 4px; margin-right: 18px; font-weight: 500; background: none; }
.ap-tabs .nav-link:hover { color: var(--ap-text); }
.ap-tabs .nav-link.active { color: var(--ap-text); border-bottom-color: var(--ap-accent); }
.ap-sec { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ap-muted); margin-bottom: 8px; font-weight: 600; }
.ap-sec-note { text-transform: none; letter-spacing: 0; font-weight: 400; }
.ap-code { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--ap-border); border-radius: 20px; background: var(--ap-surface-2); cursor: pointer; user-select: none; margin: 0 6px 6px 0; }
.ap-code input { margin: 0; }
.ap-code.on { border-color: rgba(255,193,7,.6); background: rgba(255,193,7,.1); }
.ap-code .n { color: var(--ap-muted); font-size: 12px; }
.ap-people { max-height: 420px; overflow: auto; border: 1px solid var(--ap-border); border-radius: 6px; }
.ap-people thead th { position: sticky; top: 0; z-index: 1; }
.ap-people td.c, .ap-people th.c { text-align: center; width: 92px; }
.ap-people .who .e { color: var(--ap-muted); font-size: 12px; }
.ap-people .tag { font-size: 10px; color: var(--ap-muted); border: 1px solid var(--ap-border); border-radius: 4px; padding: 0 4px; margin-left: 6px; }
.ap-via { font-size: 10px; color: var(--ap-accent); display: block; line-height: 1; margin-top: 2px; }
.ap-people tr.changed td:first-child { box-shadow: inset 3px 0 0 var(--ap-accent); }
.ap-col-all { font-size: 11px; color: var(--ap-muted); cursor: pointer; text-transform: none; letter-spacing: 0; display: block; font-weight: 400; }
.ap-col-all:hover { color: var(--ap-accent); }
.ap-summary { color: var(--ap-muted); font-size: 13px; }
.ap-summary b { color: var(--ap-text); }
@media (max-width: 575.98px) {
  .ap-people td.c, .ap-people th.c { width: 58px; padding-left: 4px !important; padding-right: 4px !important; }
  .ap-people .who .e, .ap-hide-sm { display: none; }
  .ap-summary { width: 100%; }
}
