/* ==========================================================================
   Ageless — shared UI components
   Loaded on every page, independent of the Pro Theme toggle, so avatars,
   the profile menu and the dashboard cards look the same either way.
   ========================================================================== */

/* ── Profile avatar ─────────────────────────────────────────────────────── */

.nxl-avatar-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(99, 102, 241, .25);
}

/* Initials badge shown when a user has no picture. */
.nxl-avatar-initials {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .02em;
  line-height: 1;
  user-select: none;
  border: 2px solid rgba(255, 255, 255, .35);
}

.nxl-user-dropdown .nxl-avatar-img,
.nxl-user-dropdown .nxl-avatar-initials {
  width: 44px;
  height: 44px;
  font-size: 1rem;
  margin-right: .75rem;
}

/* ── Open the account menu on hover, not just click ─────────────────────── */
/* Pointer devices only: on touch, hover would fire on the tap that is meant
   to open the menu, and the menu would immediately close again. */
@media (hover: hover) and (pointer: fine) {
  .nxl-profile-hover:hover > .dropdown-menu {
    display: block;
    animation: nxlFadeDown .14s ease-out;
  }
  /* Keeps the menu reachable across the gap between avatar and panel. */
  .nxl-profile-hover > .dropdown-menu::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
  }
}

@keyframes nxlFadeDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.nxl-user-dropdown .dropdown-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem 1rem;
  font-size: .86rem;
}

.nxl-user-dropdown .dropdown-item i {
  width: 16px;
  color: #6366f1;
}

.nxl-user-dropdown .dropdown-item:hover {
  background: #f5f3ff;
  color: #4f46e5;
}

/* ── Dashboard statistic tiles ──────────────────────────────────────────── */

.stat-tile {
  position: relative;
  background: #fff;
  border: 1px solid #e9edf5;
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  height: 100%;
  transition: box-shadow .18s ease, transform .18s ease;
  overflow: hidden;
}

.stat-tile:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
  transform: translateY(-2px);
}

/* Accent stripe carries the tile's meaning; set --tile-accent per tile. */
.stat-tile::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--tile-accent, #6366f1);
}

.stat-tile-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: .35rem;
}

.stat-tile-value {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.1;
  color: #0f172a;
}

.stat-tile-sub {
  font-size: .76rem;
  color: #64748b;
  margin-top: .3rem;
}

.stat-tile-icon {
  position: absolute;
  right: 1rem;
  top: 1rem;
  font-size: 1.15rem;
  opacity: .28;
  color: var(--tile-accent, #6366f1);
}

/* ── Branch comparison (super admin) ────────────────────────────────────── */

.branch-card {
  border: 1px solid #e9edf5;
  border-radius: 12px;
  overflow: hidden;
  height: 100%;
  background: #fff;
}

.branch-card-head {
  padding: .85rem 1.1rem;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.branch-card-head.branch-1 { background: linear-gradient(135deg, #4f46e5, #6366f1); }
.branch-card-head.branch-2 { background: linear-gradient(135deg, #0891b2, #06b6d4); }

.branch-metric {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: .55rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.branch-metric:last-child { border-bottom: none; }
.branch-metric-label { color: #64748b; font-size: .82rem; }
.branch-metric-value { font-weight: 700; color: #0f172a; font-size: 1.05rem; }

/* Share-of-total bar under a comparison metric. */
.share-bar {
  height: 6px;
  border-radius: 3px;
  background: #eef2f7;
  overflow: hidden;
  margin-top: .15rem;
}

.share-bar > span {
  display: block;
  height: 100%;
  border-radius: 3px;
}

/* ── Small helpers ──────────────────────────────────────────────────────── */

.mini-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.section-title {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #94a3b8;
}

.empty-hint {
  color: #94a3b8;
  font-size: .85rem;
  text-align: center;
  padding: 1.5rem 0;
}

/* Long tables should scroll inside their card, never widen the page. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Dark-mode friendliness for the Pro Theme ───────────────────────────── */

body.pro-theme .stat-tile,
body.pro-theme .branch-card {
  border-color: rgba(148, 163, 184, .18);
}


/* ── Branch switcher (header, Super Admin only) ──────────────────────────── */
/* A segmented control rather than a dropdown: which branch you are working in
   changes what every page shows and what new jobs are stamped with, so it has
   to be readable at a glance, not one click away. */
.branch-switch {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  padding: 2px;
  gap: 2px;
}

.branch-switch-option {
  display: inline-flex;
  align-items: center;
  padding: .28rem .7rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.2;
  color: #64748b;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}

.branch-switch-option:hover {
  color: #4338ca;
  background: #eef2ff;
}

.branch-switch-option.is-active {
  color: #fff;
  background: #4f46e5;
}

.branch-switch-option.is-active:hover {
  color: #fff;
  background: #4338ca;
}

body.pro-theme .branch-switch {
  border-color: rgba(148, 163, 184, .18);
  background: rgba(148, 163, 184, .08);
}

@media (max-width: 575.98px) {
  /* The header is tight on a phone, so tighten the control rather than wrap it. */
  .branch-switch-option { padding: .28rem .5rem; font-size: .72rem; }
}

/* ── DJI script clients pill (header, Super Admin) ──────────────────────── */
/* Who is running the DJI userscript right now: grey when nobody, green when
   everyone online is logged in to DJI, amber when someone is not. */

.dji-clients-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .28rem .7rem;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  color: #64748b;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}

.dji-clients-pill:hover { color: #334155; background: #f1f5f9; }
.dji-clients-pill.is-on   { color: #065f46; border-color: #a7f3d0; background: #ecfdf5; }
.dji-clients-pill.is-warn { color: #92400e; border-color: #fde68a; background: #fffbeb; }

.dji-clients-menu { min-width: 340px; max-width: 420px; }

body.pro-theme .dji-clients-pill {
  border-color: rgba(148, 163, 184, .18);
  background: rgba(148, 163, 184, .08);
}

@media (max-width: 575.98px) {
  .dji-clients-pill span { display: none; }
}

/* ── Branch text mark ───────────────────────────────────────────────────── */
/* Shown in place of the sidebar logo for a branch that has not uploaded one
   (header.php / branchLogoMarkup()), so each company shows its own name. */

.b-brand .brand-text {
  display: inline-flex;
  align-items: center;
  height: 30px;
  max-width: 180px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: .03em;
  line-height: 1;
  color: #4680ff;
}

.b-brand .brand-text.brand-text-sm {
  width: 42px;
  height: 42px;
  max-width: none;
  justify-content: center;
  border-radius: 10px;
  background: #4680ff;
  color: #fff;
  font-size: .8rem;
  letter-spacing: .04em;
}

/* ── Mobile app link (header, every page) ───────────────────────────────── */
.mobile-app-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .28rem .7rem;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  color: #4f46e5;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}
.mobile-app-link:hover { color: #4338ca; background: #e0e7ff; }
