﻿/* ===== POD Governance — Admin Portal Styles ===== */
/* Loaded after AiDELoop design system (assets/css/style.css + assets/fonts/inter.css).
   Uses AiDELoop CSS custom properties throughout. */

/* ===== ADMIN CSS VARIABLES (mapped to AiDELoop tokens) ===== */
:root {
  /* Map admin semantic names → AiDELoop tokens.
     --admin-primary follows the shared POD navy brand (WCAG AA with white text). */
  --admin-primary:       var(--brand-primary, #2563a8);
  --admin-primary-dark:  var(--brand-dark);
  --admin-success:       #16a34a;
  --admin-warning:       #d97706;
  --admin-danger:        #ef4444;
  --admin-info:          #0891b2;
  --admin-bg:            var(--bg-body);
  --admin-surface:       var(--bg-card);
  --admin-border:        var(--border);
  --admin-text:          var(--text-primary);
  --admin-muted:         var(--text-secondary);
  --admin-sidebar-bg:    var(--bg-sidebar);
  --admin-sidebar-hover: var(--bg-sidebar-hover);
  --admin-sidebar-active:var(--brand-primary);
  --admin-radius:        var(--radius-sm);
  --admin-radius-lg:     var(--radius-md);
  --admin-shadow:        var(--shadow-sm);
  --admin-shadow-md:     var(--shadow-md);
}

/* ===== ADMIN BODY OVERRIDES ===== */
body { font-size: 14px; overflow-x: hidden; }

/* Layout, sidebar, and topnav CSS removed — now handled by shared nav injection IIFE + assets/css/style.css */

.admin-section { display: none; }
.admin-section.active { display: block; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header-left h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--admin-text);
  margin-bottom: 2px;
}

.page-header-left p {
  font-size: 13px;
  color: var(--admin-muted);
}

/* ===== STAT CARDS ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card-admin {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius-lg);
  padding: 16px;
  box-shadow: var(--admin-shadow);
}

.stat-card-admin .stat-val {
  font-size: 28px;
  font-weight: 800;
  color: var(--admin-text);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card-admin .stat-lbl {
  font-size: 11px;
  color: var(--admin-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== CARD ===== */
.admin-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius-lg);
  box-shadow: var(--admin-shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--admin-border);
  background: var(--surface-subtle, #f8fafc);
}

.admin-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--admin-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-card-body { padding: 0; }

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--admin-border);
  background: var(--surface-subtle, #f8fafc);
  flex-wrap: wrap;
}

.search-input {
  padding: 7px 12px;
  border: 1.5px solid var(--admin-border);
  border-radius: var(--admin-radius);
  font-size: 13px;
  color: var(--admin-text);
  background: var(--admin-surface, var(--surface));
  outline: none;
  width: 220px;
}
.search-input:focus { border-color: var(--admin-primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

.filter-select {
  padding: 7px 10px;
  padding-right: 30px;
  border: 1.5px solid var(--admin-border);
  border-radius: var(--admin-radius);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-card, #fff);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: 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='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.filter-select:focus { border-color: var(--admin-primary); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--admin-radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary  { background: var(--admin-primary); color: #fff; }
.btn-primary:hover  { background: var(--admin-primary-dark); }
.btn-secondary { background: var(--bg-card, #fff); color: var(--text-primary); border: 1.5px solid var(--border-strong, #cbd5e1); }
.btn-secondary:hover { background: var(--tint-neutral-bg, #f8fafc); border-color: var(--admin-primary); }
.btn-outline  { background: transparent; color: var(--admin-primary); border: 1.5px solid var(--admin-primary); }
.btn-link { background: none; color: var(--admin-primary); border: none; padding-left: 4px; padding-right: 4px; }
.btn-link:hover { text-decoration: underline; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 14px;
  transition: background 0.12s;
}
.btn-icon:hover { background: var(--admin-bg); }

.action-btns { display: flex; gap: 4px; align-items: center; }

/* ===== TABLE ===== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th {
  background: var(--surface-subtle, #f8fafc);
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--admin-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--admin-border);
  white-space: nowrap;
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--admin-border);
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: var(--surface-subtle, #f8fafc); }

/* Wide tables scroll inside their card instead of crushing on narrow screens */
.admin-card-body:has(> .admin-table) { overflow-x: auto; }

/* ===== BADGES / PILLS ===== */
.id-badge {
  display: inline-block;
  background: var(--tint-neutral-bg-strong, #f1f5f9);
  border: 1px solid var(--tint-neutral-border, #e2e8f0);
  color: var(--admin-muted);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  font-family: monospace;
}

/* Project-name badge: shows the human-readable project name (truncated) instead of the
   ACC-xxx code. Used in User Directory + Scheduler tables. The proj-tooltip-host hover
   shows a floating tooltip with the project code and the user's roles. */
.proj-name-badge {
  display: inline-block;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  background: var(--tint-neutral-bg-strong, #f1f5f9);
  border: 1px solid var(--tint-neutral-border, #e2e8f0);
  color: var(--admin-muted);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
}

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.status-pill.active   { background: var(--tint-success-bg-strong, #dcfce7); color: var(--tint-success-fg, #15803d); }
.status-pill.inactive,
.status-pill.paused   { background: var(--tint-neutral-bg-strong, #f1f5f9); color: var(--text-secondary, #64748b); }
.status-pill.pending  { background: var(--tint-warning-bg, #fef3c7); color: var(--tint-warning-fg, #92400e); }

.cycle-badge-sm {
  display: inline-block;
  background: var(--tint-info-bg, #eff6ff);
  color: var(--tint-info-fg, #1d4ed8);
  border: 1px solid var(--tint-info-border, #bfdbfe);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}

.role-badge {
  display: inline-block;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  background: var(--tint-success-bg, #f0fdf4);
  color: var(--tint-success-fg, #15803d);
  border-color: var(--tint-success-border, #bbf7d0);
}
/* Per-role color modifiers — shared with styles.css .rb-* */
.rb-clusterHead     { background: var(--tint-danger-bg-strong, #fee2e2); color: var(--tint-danger-fg, #b91c1c); border-color: var(--tint-danger-border, #fecaca); }
.rb-podOwner        { background: #ffedd5; color: #c2410c; border-color: #fed7aa; }
.rb-deliverySpoc    { background: #ccfbf1; color: #0f766e; border-color: #99f6e4; }
.rb-salesSpoc       { background: var(--tint-info-bg-strong, #dbeafe); color: var(--tint-info-fg, #1d4ed8); border-color: var(--tint-info-border, #bfdbfe); }
.rb-esoSpoc         { background: var(--tint-purple-bg-strong, #ede9fe); color: var(--tint-purple-fg, #6d28d9); border-color: var(--tint-purple-border, #ddd6fe); }
.rb-recruitmentSpoc { background: #fce7f3; color: #be185d; border-color: #fbcfe8; }
.rb-pm              { background: var(--tint-warning-bg-strong, #fef3c7); color: var(--tint-warning-fg-strong, #b45309); border-color: var(--tint-warning-border, #fde68a); }
.rb-projectLead     { background: var(--tint-success-bg-strong, #dcfce7); color: var(--tint-success-fg, #15803d); border-color: var(--tint-success-border, #bbf7d0); }
.rb-pmoAssociate    { background: var(--tint-neutral-bg-strong, #f1f5f9); color: var(--tint-neutral-fg-strong, #475569); border-color: var(--border-strong, #cbd5e1); }
.rb-admin           { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }
.rb-projectContributor { background: #cffafe; color: #0e7490; border-color: #a5f3fc; }

/* ===== USER ROLES POPUP ===== */
.user-roles-host {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.user-roles-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--admin-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  cursor: default;
  white-space: nowrap;
  line-height: 1.6;
}
.user-roles-popup {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface, #fff);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 160px;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  flex-direction: column;
  gap: 5px;
  white-space: nowrap;
}
.user-roles-popup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #fff;
}
.user-roles-host:hover .user-roles-popup {
  display: flex;
}

/* ===== USER AVATAR ===== */
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--admin-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===== TOGGLE SWITCH ===== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 22px;
  transition: background 0.2s;
}
.toggle-slider:before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--admin-success); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }

/* ===== SCHEDULER ===== */

/* Frequency badges — colour-coded per screenshot */
.freq-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.freq-weekly   { background: var(--tint-info-bg-strong, #dbeafe); color: var(--tint-info-fg, #1d4ed8); }
.freq-biweekly { background: #ffedd5; color: #c2410c; }
.freq-monthly  { background: var(--tint-success-bg-strong, #dcfce7); color: var(--tint-success-fg, #15803d); }

.scheduler-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 1000px) { .scheduler-grid { grid-template-columns: 1fr; } }

/* ===== EMAIL TEMPLATES ===== */
/* Category tab bar */
.tmpl-tabbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--admin-border);
  margin-bottom: 16px;
}
.tmpl-tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tmpl-tab {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--admin-muted);
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
}
.tmpl-tab:hover { color: var(--admin-text); }
.tmpl-tab.active { color: var(--admin-primary); border-bottom-color: var(--admin-primary); }
.tmpl-tabbar-right { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; }
@media (max-width: 760px) {
  .tmpl-tabbar-right { width: 100%; padding-bottom: 12px; }
  .tmpl-tabbar-right .search-input { flex: 1; }
}

.templates-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
}
@media (max-width: 960px) { .templates-layout { grid-template-columns: 1fr; } }

.template-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 14px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.template-card:hover { border-color: var(--admin-primary); box-shadow: 0 0 0 2px rgba(37,99,235,0.08); }
.template-card.selected { border-color: var(--admin-primary); background: var(--tint-info-bg, #eff6ff); }

.template-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.template-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--admin-text);
}

.template-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--admin-muted);
  margin-bottom: 4px;
}

.template-subject-preview {
  font-size: 11px;
  color: var(--admin-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

/* Preview panel */
.preview-panel {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius-lg);
  box-shadow: var(--admin-shadow);
  overflow: hidden;
}

.preview-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--admin-border);
  background: var(--surface-subtle, #f8fafc);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.preview-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--admin-text);
  margin-bottom: 6px;
}

.preview-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--admin-muted);
}

.preview-body-area {
  padding: 20px;
}

.preview-subject-box {
  background: var(--surface-subtle, #f8fafc);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--admin-text);
  margin-bottom: 16px;
}

.preview-email-body {
  background: var(--surface, #fff);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--admin-text);
  min-height: 200px;
}
.preview-email-body p { margin: 0 0 12px; }
.preview-email-body ul,
.preview-email-body ol { margin: 0 0 12px; padding-left: 20px; }
.preview-email-body li { margin-bottom: 4px; }
.preview-email-body .email-cta { text-align: center; margin: 16px 0; }
.preview-email-body .email-cta a {
  display: inline-block; background: var(--admin-primary); color: #fff;
  border-radius: 6px; padding: 9px 22px; font-weight: 600; text-decoration: none; font-size: 13px;
}

/* ===== RENDERED EMAIL PREVIEW (HTML mode) ===== */
.email-preview-shell {
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  overflow: hidden;
  background: #f0f0f0;
}
.email-preview-bar {
  background: #e8e8e8;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--admin-border);
}
.email-preview-bar .dot { width: 10px; height: 10px; border-radius: 50%; }
.email-preview-bar .dot-r { background: #ff5f56; }
.email-preview-bar .dot-y { background: #ffbd2e; }
.email-preview-bar .dot-g { background: #27c93f; }
.email-preview-bar .addr {
  flex: 1; background: var(--surface, #fff); border-radius: 4px; padding: 4px 10px;
  font-size: 11.5px; color: var(--admin-muted); border: 1px solid var(--admin-border);
  margin-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.email-preview-body { background: #f4f5f9; padding: 24px; max-height: 60vh; overflow-y: auto; }

/* Rendered email card */
.email-card {
  background: var(--surface, #fff); border-radius: 8px; max-width: 560px; margin: 0 auto; overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.1); font-family: 'Inter', 'Segoe UI', sans-serif;
  font-size: 14px; color: #1a1a2e;
}
.email-header { background: var(--admin-primary); padding: 26px 32px; text-align: center; }
.email-header .email-logo { font-size: 21px; font-weight: 800; color: #fff; letter-spacing: -.3px; }
.email-header .email-logo span { color: #bcd6f5; }
.email-header .email-logo-sub { font-size: 11px; color: rgba(255,255,255,.75); margin-top: 3px; letter-spacing: .04em; }
.email-content { padding: 26px 32px; }
.email-content p { font-size: 14px; line-height: 1.65; color: #334155; margin: 0 0 14px; }
.email-content h2 { font-size: 18px; font-weight: 700; margin: 0 0 12px; color: #1a1a2e; }
.email-content ul, .email-content ol { margin: 0 0 14px; padding-left: 20px; color: #334155; }
.email-content li { margin-bottom: 5px; line-height: 1.5; }
.email-content .email-cta { text-align: center; margin: 22px 0 8px; }
.email-content .email-cta a {
  display: inline-block; background: var(--admin-primary); color: #fff; border-radius: 6px;
  padding: 12px 28px; font-size: 14px; font-weight: 600; text-decoration: none;
}
.email-footer { background: var(--surface-subtle, #f8fafc); padding: 16px 32px; text-align: center; border-top: 1px solid var(--tint-neutral-border, #e2e8f0); }
.email-footer p { font-size: 11.5px; color: #94a3b8; line-height: 1.6; margin: 0; }
.email-footer a { color: var(--admin-primary); text-decoration: underline; }

/* Token chip inside a rendered email (variable with no sample value) */
.email-token {
  display: inline-block; background: var(--tint-warning-bg-strong, #fef3c7); color: var(--tint-warning-fg, #92400e); border: 1px solid var(--tint-warning-border, #fde68a);
  border-radius: 4px; padding: 0 5px; font-family: 'Courier New', monospace; font-size: 12px; font-weight: 700;
}

.token-section { margin-top: 16px; }
.token-section-title { font-size: 11px; font-weight: 700; color: var(--admin-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }

.token-chip {
  display: inline-block;
  background: var(--tint-warning-bg-strong, #fef3c7);
  color: var(--tint-warning-fg, #92400e);
  border: 1px solid var(--tint-warning-border, #fde68a);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  font-family: monospace;
  margin: 2px;
}

/* Per-card usage row */
.tmpl-usage {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--admin-border);
  font-size: 11px;
  color: var(--admin-muted);
}
.tmpl-usage .status-pill { margin-left: auto; font-size: 10px; padding: 2px 8px; }

/* Preview panel usage strip */
.tmpl-usage-strip {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.tmpl-usage-strip .tmpl-stat {
  flex: 1;
  min-width: 90px;
  background: var(--surface-subtle, #f8fafc);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 10px 12px;
  text-align: center;
}
.tmpl-stat-val { font-size: 18px; font-weight: 700; color: var(--admin-text); }
.tmpl-stat-lbl { font-size: 10.5px; color: var(--admin-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }

/* Variable palette (edit modal) */
.var-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  background: var(--surface-subtle, #f8fafc);
  border: 1px solid var(--admin-border);
  border-top: none;
  border-radius: 0 0 var(--admin-radius) var(--admin-radius);
}
.var-palette-label {
  width: 100%;
  font-size: 11px;
  font-weight: 600;
  color: var(--admin-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.var-chip {
  display: inline-flex;
  align-items: center;
  background: var(--tint-info-bg, #eff6ff);
  color: var(--tint-info-fg, #1d4ed8);
  border: 1px solid var(--tint-info-border, #bfdbfe);
  border-radius: 4px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  padding: 2px 7px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.var-chip:hover { background: var(--tint-info-bg-strong, #dbeafe); border-color: var(--admin-primary); }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: pointer; /* backdrop click hint */
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--surface, #fff);
  border-radius: var(--admin-radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  cursor: default; /* prevent backdrop cursor propagating inside */
}

.modal-box.modal-lg { max-width: 720px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--admin-border);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--admin-text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--admin-muted);
  padding: 4px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--admin-bg); color: var(--admin-text); }

.modal-body { padding: 20px; }

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--admin-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-subtle, #f8fafc);
}

/* ===== FORM ===== */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--admin-text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--admin-border);
  border-radius: var(--admin-radius);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
  background: var(--bg-card, #fff);
}
.form-control:focus { border-color: var(--admin-primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }

select.form-control {
  appearance: none;
  padding-right: 30px;
  background-image: 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='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

textarea.form-control { resize: vertical; min-height: 140px; font-family: 'Courier New', monospace; }

/* ── User autocomplete (single-select, type-to-filter — mirrors Meeting Notes AI participants) ── */
.user-ac { position: relative; }
.user-ac-selected {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px;
  border: 1.5px solid var(--admin-border);
  border-radius: var(--admin-radius);
  background: var(--bg-card, #fff);
  font-size: 13px;
}
.user-ac-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--admin-primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.user-ac-name { color: var(--text-primary); font-weight: 600; }
.user-ac-role { color: var(--admin-muted); font-weight: 500; font-size: 11.5px; }
.user-ac-clear {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: var(--admin-muted); font-size: 13px; line-height: 1;
  padding: 3px 5px; border-radius: 5px;
}
.user-ac-clear:hover { background: var(--surface-subtle, #f1f5f9); color: var(--admin-danger); }
.user-ac-dropdown {
  position: fixed; z-index: 600;
  background: var(--bg-card, #fff);
  border: 1.5px solid var(--admin-border);
  border-radius: var(--admin-radius);
  box-shadow: 0 8px 24px rgba(15,23,42,0.14);
  max-height: 240px; overflow-y: auto; padding: 4px;
}
.user-ac-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: 7px; cursor: pointer; font-size: 13px;
  color: var(--text-primary);
}
.user-ac-item:hover, .user-ac-item.focused { background: var(--surface-subtle, #f1f5f9); }
.user-ac-empty { padding: 12px; font-size: 12.5px; color: var(--admin-muted); text-align: center; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--admin-text);
  cursor: pointer;
  padding: 6px 0;
  border-bottom: 1px solid var(--admin-border);
}
.checkbox-label:last-child { border-bottom: none; }
.checkbox-label input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--admin-primary); }

.form-hint {
  font-size: 11px;
  color: var(--admin-muted);
  margin-top: 4px;
}

/* ===== ALERT ===== */
.admin-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--admin-radius);
  font-size: 13px;
  margin-bottom: 16px;
}
.admin-alert.info { background: var(--tint-info-bg, #eff6ff); border: 1px solid var(--tint-info-border, #bfdbfe); color: var(--tint-info-fg-strong, #1e40af); }
.admin-alert.warning { background: var(--warn-bg, #fffbeb); border: 1px solid var(--tint-warning-border, #fde68a); color: var(--tint-warning-fg-strong, #78350f); }

/* ===== TOAST ===== */
.toast-container-admin {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--admin-radius);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--admin-shadow-md);
  animation: toast-in 0.25s ease;
}
.toast.success { background: var(--tint-success-bg, #f0fdf4); color: var(--tint-success-fg, #15803d); border: 1px solid var(--tint-success-border, #bbf7d0); }
.toast.warning { background: var(--warn-bg, #fffbeb); color: var(--tint-warning-fg, #92400e); border: 1px solid var(--tint-warning-border, #fde68a); }
.toast.default { background: var(--surface, #fff); color: var(--admin-text); border: 1px solid var(--admin-border); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Desktop (≥992px) — sidebar always visible */
@media (min-width: 992px) {
  .admin-mobile-toggle { display: none !important; }
  .sidebar-close-btn { display: none !important; }
  .admin-sidebar {
    position: relative !important;
    transform: none !important;
    box-shadow: none !important;
  }
}

/* Tablet + mobile (≤991px) — collapsible off-canvas sidebar */
@media (max-width: 991px) {
  body { overflow-y: auto; overflow-x: hidden; }
  .admin-shell { min-height: unset; overflow: visible; flex-direction: row; }
  .topnav-label-hide { display: none; }
  .topnav-divider-hide { display: none; }

  .admin-mobile-toggle { display: flex !important; }
  .sidebar-close-btn { display: block !important; }

  .admin-sidebar {
    position: fixed !important;
    top: 52px;
    left: 0;
    height: calc(100vh - 52px);
    width: 240px;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0,0,0,0.35);
  }
  .admin-sidebar.open { transform: translateX(0) !important; }

  .admin-main {
    padding: 16px;
    overflow-y: auto;
    width: 100%;
  }

  .scheduler-grid { grid-template-columns: 1fr !important; }
  .templates-layout { grid-template-columns: 1fr !important; }
}

/* Tablet portrait (≤767px) */
@media (max-width: 767px) {
  .admin-main { padding: 12px; }
  .topnav-back-hide { display: none; }
  .topnav-user-text { display: none; }
  /* Keep Profile + Sign Out reachable on mobile — show icons only, hide the labels.
     (Previously the whole Sign Out button was hidden, leaving no way to sign out.) */
  .topnav-btn-label { display: none; }
  .topnav-signout-btn { padding: 5px 8px; }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .stat-val { font-size: 22px !important; }

  .admin-card-header { flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
  .admin-card-body { padding: 12px 14px; }

  .toolbar { flex-wrap: wrap; gap: 8px; }
  .search-input { width: 100% !important; }
  .filter-select { flex: 1; min-width: 120px; }

  .admin-table { font-size: 12px; }
  .admin-table th, .admin-table td { padding: 8px 8px; }

  .page-header { flex-wrap: wrap; gap: 10px; }
  .modal-box { max-width: 95vw !important; max-height: 95vh; }
  .modal-overlay { padding: 12px; }

  .preview-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .preview-meta-row { flex-direction: column; gap: 4px; }

  .form-row { grid-template-columns: 1fr !important; }
}

/* Mobile (≤575px) */
@media (max-width: 575px) {
  .admin-main { padding: 8px; }
  .topnav-brand-text { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
  .stat-card-admin { padding: 12px; }

  .admin-table th:nth-child(3),
  .admin-table td:nth-child(3) { display: none; }

  .toast-container-admin { bottom: 10px; right: 10px; left: 10px; }
  .toast { width: 100%; }
}

/* Print */
@media print {
  .admin-topnav, .admin-sidebar,
  .admin-mobile-toggle, .toolbar,
  .modal-overlay { display: none !important; }
  .admin-shell { display: block; }
  .admin-main { padding: 0; overflow: visible; }
  .admin-card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  body { background: var(--surface, #fff); overflow: auto; }
}

/* ===== PROJECT BADGE TOOLTIP (User Directory → Projects column) ===== */
/*
 * Hovering over a project name badge shows a floating tooltip with the project
 * code (e.g. ACC-001) and the roles held by that user on that project.
 * The badge itself now displays the human-readable project name; the tooltip
 * surfaces the code (supplementary) + roles — no duplication of the name.
 */
.proj-tooltip-host {
  display: inline-block; /* sizes to badge so tooltip centres correctly */
  position: relative;
  cursor: default;
}

.proj-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f1f5f9;
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 160px;
  max-width: 240px;
  font-size: 12px;
  line-height: 1.5;
  white-space: normal;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  z-index: 9000;
  pointer-events: none;
  text-align: left;
}

/* Caret arrow */
.proj-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1e293b;
}

.proj-tooltip-host:hover .proj-tooltip {
  display: block;
}

.proj-tooltip strong {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 5px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  padding-bottom: 4px;
}

.proj-tooltip-roles {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 2px;
}

.proj-tooltip-role-chip {
  display: inline-block;
  background: rgba(99,179,237,0.18);
  color: #93c5fd;
  border: 1px solid rgba(147,197,253,0.25);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* ===== PAGINATION ===== */
.pager {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  border-top: 1px solid var(--admin-border);
  flex-wrap: wrap;
}
.pager-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  background: var(--admin-surface);
  color: var(--admin-text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  line-height: 1;
}
.pager-btn:hover:not(:disabled) { background: var(--admin-bg); border-color: var(--admin-primary); color: var(--admin-primary); }
.pager-btn.active { background: var(--admin-primary); border-color: var(--admin-primary); color: #fff; }
.pager-btn:disabled { opacity: .4; cursor: default; }
.pager-info { margin-left: 8px; font-size: 12px; color: var(--admin-muted); }

/* Small-viewport units: fix 100vh vs mobile browser chrome (see design-system.css) */
@supports (height: 100dvh) {
  @media (max-width: 900px) {
    .admin-sidebar { height: calc(100dvh - 52px); }
  }
}
