/* Web access-control styles (login overlay, role gating, VA device list,
   admin dashboard). Added 2026-06-01. Loaded after styles.css. Self-contained
   and reversible — removing this file + its <link> reverts the UI. */

/* ----------------------------------------------------------- login overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 120% at 50% 0%, rgba(14, 98, 181, 0.35), rgba(4, 8, 18, 0.96));
  backdrop-filter: blur(8px);
}
.auth-overlay.show { display: flex; }

.auth-card {
  width: min(420px, 100%);
  background: var(--panel, rgba(7, 14, 27, 0.92));
  border: 1px solid var(--line-strong, rgba(65, 224, 255, 0.32));
  border-radius: var(--radius, 24px);
  box-shadow: var(--shadow, 0 28px 80px rgba(0, 0, 0, 0.42));
  padding: 32px 28px;
  color: var(--ink, #f2f7ff);
}
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand .eyebrow { letter-spacing: 0.18em; text-transform: uppercase; font-size: 0.7rem; color: var(--accent, #28d7ff); margin: 0 0 4px; }
.auth-brand h1 { margin: 0; font-size: 1.8rem; }
.auth-intro { font-size: 0.9rem; color: var(--muted, #96a8c8); line-height: 1.5; margin-bottom: 8px; }
.auth-intro strong { color: var(--ink, #f2f7ff); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > span { font-size: 0.8rem; color: var(--muted, #96a8c8); }
.auth-field input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line, rgba(100, 140, 220, 0.22));
  border-radius: 12px;
  padding: 11px 13px;
  color: var(--ink, #f2f7ff);
  font-size: 0.95rem;
  outline: none;
}
.auth-field input:focus { border-color: var(--accent, #28d7ff); }
.auth-error { color: #ff7a90; font-size: 0.85rem; min-height: 1em; margin: 0; }
.auth-submit {
  margin-top: 4px;
  padding: 12px 16px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(40, 215, 255, 0.95), rgba(14, 120, 200, 0.95));
  color: #03121f;
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
}
.auth-submit:disabled { opacity: 0.6; cursor: default; }
body.auth-locked { overflow: hidden; }

/* --------------------------------------------------------------- role gating */
/* The whole standard navigation (Control Panel, Script Editor, Devices,
   Automation, Bios, AI/Tools, Account Logins, Subsheet, XXTouch, iPhone Mirror)
   is hidden UNCONDITIONALLY — this app is always behind login and both roles
   navigate purely via their device list. Hiding by default (not only when a
   JS class is present) makes it impossible for an automation tab to flash or
   leak if a script is slow/stale. The pages/code stay in the DOM. */
.sidebar-nav-btn { display: none !important; }
.sidebar-hidden-tabs,
#sidebarToggle { display: none !important; }

/* The ONLY nav button ever shown: the Admin tab, and only for admins. */
body.np-role-admin .sidebar-nav-btn[data-page="admin"] { display: flex !important; }

/* The original nav is a fixed CSS grid sized for ~10 buttons; with all but the
   Admin button hidden it collapsed to ~20px and clipped/overlapped. Force it to
   a plain block so it sizes to the single visible (Admin) button. */
body.np-authed .sidebar-nav {
  display: block !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  flex: 0 0 auto !important;
}
body.np-role-admin .sidebar-nav-btn[data-page="admin"] { width: 100%; margin: 0; }
/* Separate the device list from the nav; let it fill + scroll. */
body.np-authed #npSideDevices {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 10px;
  border-top: 1px solid var(--line, rgba(100, 140, 220, 0.18));
}
/* When there is no Admin tab (VA), drop the dividing line. */
body.np-role-va .sidebar-nav { display: none !important; }
body.np-role-va #npSideDevices { border-top: 0; margin-top: 0; }

/* ------------------------------------------------------ sidebar device list */
/* Shown to both roles — admin sees every phone, a VA sees only theirs. */
.np-side-devices { display: none; padding: 4px 12px 12px; overflow-y: auto; }
body.np-authed .np-side-devices { display: block; }
.np-side-heading {
  font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted, #96a8c8); margin: 8px 4px 10px;
}
.np-side-empty { font-size: 0.85rem; color: var(--muted, #96a8c8); line-height: 1.5; padding: 0 4px; }
.np-side-device {
  width: 100%; text-align: left; display: flex; flex-direction: column; gap: 3px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line, rgba(100, 140, 220, 0.18));
  border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
  color: var(--ink, #f2f7ff); transition: border-color 120ms ease, transform 120ms ease;
}
.np-side-device:hover { border-color: var(--accent, #28d7ff); transform: translateY(-1px); }
.np-side-device.selected { border-color: var(--accent, #28d7ff); background: rgba(40, 215, 255, 0.12); }
.np-side-device.offline { opacity: 0.55; }
.np-side-device-name { font-weight: 600; font-size: 0.95rem; }
.np-side-device-status { font-size: 0.76rem; color: var(--muted, #96a8c8); }
.np-side-device-status.live { color: #4ce0a0; }

/* ---------------------------------------------------------------- user bar */
.np-user-bar {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 12px; border-top: 1px solid var(--line, rgba(100, 140, 220, 0.18));
}
.np-user-label { font-size: 0.82rem; color: var(--muted, #96a8c8); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-logout-btn { flex: 0 0 auto; }

/* --------------------------------------------------------------- admin page */
.admin-panel {
  background: var(--panel-soft, rgba(10, 18, 34, 0.82));
  border: 1px solid var(--line, rgba(100, 140, 220, 0.18));
  border-radius: 18px; padding: 18px 20px; margin: 16px 0;
}
.admin-panel .panel-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.admin-create-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.admin-create-form input {
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line, rgba(100, 140, 220, 0.22));
  border-radius: 10px; padding: 9px 12px; color: var(--ink, #f2f7ff); font-size: 0.9rem; min-width: 160px;
}
.admin-create-form button {
  border: 0; border-radius: 10px; padding: 9px 16px; cursor: pointer; font-weight: 700;
  background: linear-gradient(180deg, rgba(40, 215, 255, 0.95), rgba(14, 120, 200, 0.95)); color: #03121f;
}
.admin-users-list { display: flex; flex-direction: column; gap: 8px; }
.admin-user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line, rgba(100, 140, 220, 0.16)); border-radius: 12px;
}
.admin-user-info { display: flex; flex-direction: column; gap: 2px; }
.admin-user-name { font-weight: 600; }
.admin-user-meta { font-size: 0.78rem; color: var(--muted, #96a8c8); }
.admin-user-actions { display: flex; gap: 8px; }
.admin-danger { color: #ff7a90 !important; }

.admin-assignments-wrap { overflow-x: auto; }
.admin-assign-table { border-collapse: collapse; width: 100%; min-width: 360px; }
.admin-assign-table th, .admin-assign-table td {
  border-bottom: 1px solid var(--line, rgba(100, 140, 220, 0.14)); padding: 9px 12px; text-align: center;
}
.admin-assign-table th { font-size: 0.8rem; color: var(--muted, #96a8c8); font-weight: 600; }
.admin-assign-table th:first-child, .admin-assign-device { text-align: left; }
.admin-assign-device { display: flex; flex-direction: column; gap: 2px; }
.admin-assign-device-name { font-weight: 600; font-size: 0.9rem; }
.admin-assign-device-sub { font-size: 0.74rem; color: var(--muted, #96a8c8); }
.admin-assign-cell input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent, #28d7ff); }

/* ----------------------------------------------------------- admin overview */
.admin-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 14px;
}
.admin-stat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line, rgba(100, 140, 220, 0.18));
  border-radius: 14px; padding: 14px 16px;
}
.admin-stat.accent { border-color: var(--accent, #28d7ff); background: rgba(40, 215, 255, 0.10); }
.admin-stat-value { font-size: 1.9rem; font-weight: 700; color: var(--ink, #f2f7ff); line-height: 1.1; }
.admin-stat.accent .admin-stat-value { color: var(--accent, #28d7ff); }
.admin-stat-label { font-size: 0.76rem; color: var(--muted, #96a8c8); margin-top: 3px; }
.admin-overview-vas { display: flex; flex-direction: column; gap: 6px; }
.admin-overview-va {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border: 1px solid var(--line, rgba(100, 140, 220, 0.14)); border-radius: 10px;
}
.admin-overview-va-name { font-weight: 600; }
.admin-overview-va-meta { font-size: 0.78rem; color: var(--muted, #96a8c8); margin-left: auto; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #5a6b86; flex: 0 0 auto; }
.live-dot.online { background: #4ce0a0; box-shadow: 0 0 8px rgba(76, 224, 160, 0.7); }
