/* ═══════════════════════════════════════════════════════════
   Ognate Admin Portal — Surface-specific styles
   Tokens, components, layout primitives, typography utilities,
   and the icon class come from ../design-system/ognate.css.
   This file holds only admin-specific layout (topbar, sidebar,
   login, upload tray, footer) plus a thin spacing/text-color
   utility set used inside admin templates.
   ═══════════════════════════════════════════════════════════ */

/* ── Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--og-bg-base);
  color: var(--og-text-secondary);
  font-family: var(--og-font-body);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--og-accent-soft);
  color: var(--og-text-primary);
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--og-border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--og-text-muted); }

a {
  color: var(--og-accent);
  text-decoration: none;
  transition: color var(--og-dur) var(--og-ease);
}
a:hover { color: var(--og-accent); filter: brightness(1.1); }

hr {
  background-color: var(--og-border-default);
  height: 1px;
  border: none;
  margin: 1.5rem 0;
}

code {
  font-family: var(--og-font-mono);
  font-size: 0.86em;
  letter-spacing: -0.02em;
}

/* Details/Summary */
details summary { cursor: pointer; user-select: none; }
details summary::-webkit-details-marker { color: var(--og-text-muted); }


/* ══════════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════════ */

/* App shell: viewport-tall column so topbar + footer pin and only the content
   area scrolls — otherwise topbar + full-height layout + footer overflow by the
   footer's height and park it below the fold. */
#app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ── Topbar ────────────────────────────────────────────── */
.admin-topbar {
  height: 52px;
  flex-shrink: 0;
  background: var(--og-bg-surface);
  border-bottom: 1px solid var(--og-border-default);
  position: sticky;
  top: 0;
  z-index: 100;
}
.admin-topbar::before {
  content: '';
  position: absolute;
  top: 0;
  inset-inline: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--og-accent) 0%, var(--og-accent-soft) 50%, transparent 100%);
}
.admin-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 1.25rem;
}
.admin-topbar-title {
  font-family: var(--og-font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--og-text-primary);
  letter-spacing: -0.02em;
}
a.admin-topbar-title {
  text-decoration: none;
  transition: opacity var(--og-dur) var(--og-ease);
}
a.admin-topbar-title:hover { opacity: 0.78; }
.admin-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.admin-topbar-email {
  font-size: 0.8rem;
  color: var(--og-text-muted);
}
.admin-topbar-role {
  display: inline-block;
  font-family: var(--og-font-display);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  background: var(--og-accent-soft);
  color: var(--og-accent);
}
.admin-topbar-logout {
  background: none;
  border: none;
  color: var(--og-text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--og-r-sm);
  font-size: 0.85rem;
  transition: color var(--og-dur) var(--og-ease), background var(--og-dur) var(--og-ease);
}
.admin-topbar-logout:hover {
  color: var(--og-text-primary);
  background: var(--og-bg-elevated);
}

.admin-topbar-menu {
  display: none;
  background: none;
  border: none;
  color: var(--og-text-muted);
  cursor: pointer;
  padding: 0.5rem 0.6rem;
  margin-inline-end: 0.25rem;
  border-radius: var(--og-r-sm);
  font-size: 1rem;
  transition: color var(--og-dur) var(--og-ease), background var(--og-dur) var(--og-ease);
}
.admin-topbar-menu:hover {
  color: var(--og-text-primary);
  background: var(--og-bg-elevated);
}

/* ── Global menu (superuser dropdown next to email) ────── */
.admin-global-menu { position: relative; }
.admin-global-menu-list {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  min-width: 200px;
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  background: var(--og-bg-surface);
  border: 1px solid var(--og-border-default);
  border-radius: var(--og-r-md);
  box-shadow: var(--og-shadow-lg);
  z-index: 110;
}
.admin-global-menu-list li { margin: 0; }
.admin-global-menu-list a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.7rem;
  border-radius: var(--og-r-sm);
  color: var(--og-text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
}
.admin-global-menu-list a:hover {
  background: var(--og-bg-elevated);
  color: var(--og-text-primary);
}
.admin-global-menu-list .og-icon {
  width: 1rem;
  height: 1rem;
  color: var(--og-text-muted);
}

/* ── Main layout ───────────────────────────────────────── */
.admin-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.admin-sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--og-bg-surface);
  border-inline-end: 1px solid var(--og-border-default);
  overflow-y: auto;
  padding-top: 0.5rem;
  display: flex;
  flex-direction: column;
}
.admin-sidebar-version {
  margin-top: auto;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--og-border-subtle);
  font-family: var(--og-font-mono);
  font-size: 0.7rem;
  color: var(--og-text-muted);
  letter-spacing: 0.02em;
  opacity: 0.7;
}

/* No tenant selected — sidebar would be empty, so drop it entirely
   (and the mobile hamburger that opens it). */
body.admin-no-sidebar .admin-sidebar { display: none; }
body.admin-no-sidebar #sidebar-toggle { display: none; }

.admin-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 52px 0 0 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 90;
  opacity: 0;
  transition: opacity var(--og-dur) var(--og-ease);
}
@media (max-width: 768px) {
  .admin-sidebar-backdrop.is-visible {
    display: block;
    opacity: 1;
  }
}

.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem 2rem;
  background: var(--og-bg-base);
}

/* ── Sidebar nav ───────────────────────────────────────── */
.admin-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.admin-nav-section {
  padding: 1rem 1.25rem 0.3rem;
  font-family: var(--og-font-display);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--og-text-muted);
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 1.25rem;
  color: var(--og-text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 450;
  border-inline-start: 2px solid transparent;
  transition: all var(--og-dur) var(--og-ease);
  margin: 1px 0;
}

.admin-nav a:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--og-text-primary);
}

.admin-nav a.og-active {
  background: var(--og-accent-soft);
  border-inline-start-color: var(--og-accent);
  color: var(--og-text-primary);
  font-weight: 600;
}

.admin-nav a .og-icon {
  width: 1rem;
  height: 1rem;
  color: var(--og-text-muted);
  transition: color var(--og-dur) var(--og-ease);
}
.admin-nav a:hover .og-icon,
.admin-nav a.og-active .og-icon {
  color: var(--og-accent);
}


/* ══════════════════════════════════════════════════════════
   COMPONENTS
   ══════════════════════════════════════════════════════════ */

/* ── Login Screen ──────────────────────────────────────── */
.admin-login {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--og-bg-base);
  position: relative;
  overflow: hidden;
}

/* Dot grid background */
.admin-login::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.035) 1px, transparent 0);
  background-size: 28px 28px;
  pointer-events: none;
}

/* Radial glow behind card */
.admin-login::after {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--og-accent-soft) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.admin-login-card {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 380px;
  width: 100%;
  padding: 3rem 2.5rem;
  background: var(--og-bg-surface);
  border: 1px solid var(--og-border-default);
  border-radius: var(--og-r-xl);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  animation: loginIn 500ms var(--og-ease) both;
}

.admin-login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.admin-login-logo {
  font-family: var(--og-font-display);
  font-weight: 700;
  font-size: 2.1rem;
  color: var(--og-text-primary);
  letter-spacing: -0.03em;
}
.admin-login-label {
  font-family: var(--og-font-display);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--og-accent);
  background: var(--og-accent-soft);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  margin-top: 0.2rem;
}
.admin-login-subtitle {
  color: var(--og-text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}
.admin-login .og-btn-primary {
  width: 100%;
  height: 44px;
  font-size: 0.95rem;
  border-radius: var(--og-r-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.admin-login-hint {
  margin-top: 1.5rem;
  font-size: 0.78rem;
  color: var(--og-text-muted);
  line-height: 1.5;
}

@keyframes loginIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Page Headers ──────────────────────────────────────── */
.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--og-sp-2);
  margin-bottom: 1.75rem;
}

/* Soft-deleted session rows (Sessions > Deleted): dimmed to read as archived. */
.admin-row-muted td {
  opacity: 0.6;
}

.admin-page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--og-sp-2);
}

.admin-escalation-badge {
  font-size: 0.68rem;
  padding: 0.05rem 0.4rem;
  margin-inline-start: auto;
}

/* ── Tabs (admin-internal) ─────────────────────────────── */
.admin-tabs ul {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--og-sp-3);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid var(--og-border-default);
}
.admin-tabs li a {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 1rem;
  color: var(--og-text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--og-dur) var(--og-ease), border-color var(--og-dur) var(--og-ease);
}
.admin-tabs li a:hover {
  color: var(--og-text-primary);
}
.admin-tabs li.og-active a {
  color: var(--og-accent);
  border-bottom-color: var(--og-accent);
}

/* ── Toggle switch ─────────────────────────────────────── */
.admin-toggle {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  flex-shrink: 0;
  cursor: pointer;
}
.admin-toggle input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}
.admin-toggle-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--og-border-default);
  transition: background var(--og-dur) var(--og-ease);
}
.admin-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform var(--og-dur) var(--og-ease);
}
.admin-toggle input:checked + .admin-toggle-track { background: var(--og-accent); }
.admin-toggle input:checked + .admin-toggle-track::after { transform: translateX(14px); }
.admin-toggle input:focus-visible + .admin-toggle-track {
  outline: 2px solid var(--og-accent);
  outline-offset: 2px;
}

/* ── Upload Dropzone (admin-specific spacing) ──────────── */
#upload-dropzone { margin-bottom: 1rem; }

/* ── Transcript ────────────────────────────────────────── */
.admin-transcript {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.25rem;
  max-height: 560px;
  overflow-y: auto;
  background: var(--og-bg-base);
  border-radius: var(--og-r-md);
}

/* ══════════════════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════════════════ */

/* Subtle page content entrance */
.admin-content > *:first-child {
  animation: contentIn 300ms var(--og-ease) both;
}
@keyframes contentIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Swagger UI mounts its Authorize / definition modals via `position: fixed`.
   The `contentIn` keyframe above leaves `transform: translateY(0)` (identity)
   on the page root, which creates a containing block per CSS spec and re-anchors
   `position: fixed` descendants to it — pushing the modal below the viewport. */
#api-docs-swagger-ui {
  animation: none;
}


/* ══════════════════════════════════════════════════════════
   UPLOAD TRAY
   ══════════════════════════════════════════════════════════ */
#upload-tray {
  position: fixed;
  inset-inline-end: 1.25rem;
  bottom: 1.25rem;
  width: 340px;
  max-width: calc(100vw - 2.5rem);
  z-index: 90;
  display: none;
  flex-direction: column;
  gap: 0.5rem;
}
#upload-tray.has-items { display: flex; }

.upload-row {
  background: var(--og-bg-elevated);
  border: 1px solid var(--og-border-default);
  border-radius: var(--og-r-md);
  padding: 0.75rem;
  color: var(--og-text-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  font-size: 0.85rem;
}
.upload-row-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.upload-filename {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.upload-badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  font-weight: 500;
}
.upload-badge-info    { background: var(--og-info-soft);    color: var(--og-info); }
.upload-badge-success { background: var(--og-success-soft); color: var(--og-success); }
.upload-badge-warning { background: var(--og-info-soft);    color: var(--og-info); }
.upload-badge-danger  { background: var(--og-danger-soft);  color: var(--og-danger); }

.upload-progress {
  width: 100%;
  height: 6px;
  margin: 0.25rem 0 0.4rem;
  appearance: none;
}
.upload-progress::-webkit-progress-bar { background: var(--og-bg-base); border-radius: 3px; }
.upload-progress::-webkit-progress-value { background: var(--og-accent); border-radius: 3px; }
.upload-progress::-moz-progress-bar { background: var(--og-accent); }

.upload-row-status {
  font-size: 0.72rem;
  color: var(--og-text-secondary);
  margin-bottom: 0.4rem;
}
.upload-row-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
}
.upload-pending {
  border-inline-start: 3px solid var(--og-info);
}


/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .admin-topbar-menu { display: inline-flex; }

  #upload-tray {
    inset-inline-end: 0.5rem;
    bottom: 0.5rem;
    width: calc(100vw - 1rem);
  }

  .admin-sidebar {
    position: fixed;
    top: 52px;
    inset-inline-start: -260px;
    bottom: 0;
    width: 260px;
    min-width: 0;
    max-width: 80vw;
    z-index: 95;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.4);
    transition: inset-inline-start var(--og-dur) var(--og-ease);
  }
  .admin-sidebar.is-open { inset-inline-start: 0; }

  .admin-content { padding: 1rem; }
  .admin-login-card { margin: 1rem; padding: 2rem 1.5rem; }
  .admin-topbar-email { display: none; }
  .admin-topbar-inner { padding: 0 0.75rem; }
}
