/* help152fz workbench auth UI */

:root {
  --primary: #0f2942;
  --primary-light: #3b6dc7;
  --accent: #3b6dc7;
  --text: #4A5568;
  --text-light: #718096;
  --bg: #FFFFFF;
  --bg-soft: #f1f3f6;
  --border: #CBD5E0;
  --error: #E53E3E;
  --success: #38A169;
  --warning: #DD6B20;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-soft);
  line-height: 1.5;
  padding-top: 56px; /* topbar height; auth-page overrides this */
}

/* auth-page (login/setup/forgot-password) has its own centering layout */
body.auth-page { padding-top: 0; }

/* ===== auth pages (login/setup/2fa) ===== */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1B3A6B 0%, #2D5A8C 100%);
  padding: 20px;
}

.auth-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  display: block;
  max-width: 180px;
  margin: 0 auto 24px;
}

.auth-card h1 {
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 24px;
}

.auth-card .note,
.auth-card .warning {
  background: var(--bg-soft);
  padding: 12px;
  border-radius: 6px;
  font-size: 13px;
  margin: 0 0 20px;
}

.auth-card .warning {
  background: #FFF5F5;
  border-left: 3px solid var(--warning);
  color: #744210;
}

.auth-card label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  margin: 16px 0 6px;
}

.input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s;
  background: var(--bg);
  color: var(--text);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,144,217,0.15);
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234A5568' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.code-input {
  text-align: center;
  letter-spacing: 8px;
  font-size: 22px;
  font-family: ui-monospace, monospace;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  margin-top: 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--primary-light); }
.btn-primary:disabled { background: #A0AEC0; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover { background: var(--bg-soft); border-color: var(--accent); }

.btn-link-cancel {
  display: block;
  text-align: center;
  margin-top: 12px;
  color: var(--text-light);
  text-decoration: none;
  font-size: 13px;
}

.btn-link-cancel:hover { color: var(--primary); }

.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin: 0 0 16px;
  font-size: 13px;
}

.flash-error { background: #FED7D7; color: #742A2A; }
.flash-success { background: #C6F6D5; color: #22543D; }
.flash-info { background: #BEE3F8; color: #2A4365; }
.flash-warning { background: #FEEBC8; color: #744210; }

.field-error {
  color: var(--error);
  font-size: 12px;
  margin: 4px 0 0;
}

.qr {
  display: block;
  margin: 16px auto;
  width: 200px;
  height: 200px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.backup-codes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--bg-soft);
  padding: 16px;
  border-radius: 6px;
  margin: 16px 0;
}

.backup-codes code {
  font-family: ui-monospace, monospace;
  font-size: 15px;
  background: white;
  padding: 8px 12px;
  border-radius: 4px;
  text-align: center;
  letter-spacing: 2px;
  border: 1px solid var(--border);
}

/* ===== authenticated topbar ===== */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: #0a2540;
  color: white;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.topbar-brand {
  font-weight: 700;
  font-size: .95rem;
  color: #fff;
  text-decoration: none;
  letter-spacing: .01em;
  opacity: .9;
}
.topbar-brand:hover { opacity: 1; color: #fff; }

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.username { font-weight: 500; }

.role-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.role-admin { background: rgba(229,62,62,0.3); }
.role-operator { background: rgba(74,144,217,0.3); }
.role-viewer { background: rgba(160,174,192,0.3); }

.btn-link {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  transition: color .15s;
}
.btn-link:hover { color: #fff; opacity: 1; }

.btn-link-logout {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.btn-link-logout:hover { background: rgba(255,255,255,.22); }

.container {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 24px;
}

/* ===== page card ===== */

.page-card {
  background: white;
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.page-card h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 24px;
}

.page-card label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  margin: 16px 0 6px;
}

.page-card .note {
  background: var(--bg-soft);
  padding: 12px;
  border-radius: 6px;
  font-size: 13px;
  margin: 0 0 20px;
}

.page-card .warning {
  background: #FFF5F5;
  border-left: 3px solid var(--warning);
  color: #744210;
  padding: 12px;
  border-radius: 6px;
  font-size: 13px;
  margin: 0 0 20px;
}

/* ===== admin tables ===== */

table.users {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

table.users th,
table.users td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.users th {
  background: #e8edf3;
  font-weight: 600;
  color: #0f2942;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

table.users tr:last-child td { border-bottom: none; }
table.users tr:hover { background: var(--bg-soft); }

/* ===== action buttons ===== */

.btn-action {
  background: #3b6dc7;
  color: white;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}

.btn-action:hover { background: #2d5bb5; }

.action-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  background: var(--bg-soft);
  color: var(--primary);
  border: 1px solid var(--border);
  text-decoration: none;
  display: inline-block;
  transition: background 0.1s;
}

.btn-sm:hover { background: #E2E8F0; }
.btn-sm.btn-warn { color: var(--warning); border-color: #F6AD55; }
.btn-sm.btn-warn:hover { background: #FEEBC8; }
.btn-sm.btn-danger { color: var(--error); border-color: #FC8181; }
.btn-sm.btn-danger:hover { background: #FED7D7; }

/* ===== temp password block ===== */

.temp-password-block {
  background: #FFFFF0;
  border: 2px solid #F6E05E;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.temp-password-value {
  font-family: ui-monospace, monospace;
  font-size: 20px;
  letter-spacing: 3px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  text-align: center;
  color: var(--primary);
  font-weight: 600;
}

.link-muted {
  color: var(--text-light);
  text-decoration: none;
  font-size: 13px;
}

.link-muted:hover { color: var(--primary); text-decoration: underline; }


/* ===== D6.42 single-screen login ===== */

.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg-soft);
}

.auth-logo {
  width: 100px;
  height: auto;
  margin-bottom: 28px;
  display: block;
}

.auth-logo--small {
  width: 64px;
  margin-bottom: 20px;
}

.auth-form {
  width: 100%;
  max-width: 360px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px;
  text-align: center;
}

.auth-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 8px;
}

.auth-subtitle {
  color: var(--text-light);
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 20px;
}

.auth-field {
  margin-bottom: 12px;
}

.auth-field input[type="text"],
.auth-field input[type="password"],
.auth-field input[type="email"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--text);
}

.auth-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,144,217,.15);
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-light);
  cursor: pointer;
  user-select: none;
}

.auth-remember input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.btn-auth {
  display: block;
  width: 100%;
  padding: 11px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  margin-bottom: 12px;
  text-align: center;
  text-decoration: none;
  line-height: 1.5;
}

.btn-auth:hover { background: var(--primary-light); }
.btn-auth:disabled { opacity: .55; cursor: not-allowed; }

.auth-error {
  margin-top: 12px;
  padding: 10px 12px;
  background: #FFF5F5;
  border: 1px solid #FEB2B2;
  border-radius: 6px;
  color: var(--error);
  font-size: 13px;
  line-height: 1.5;
}

.totp-hint {
  margin: 0 0 6px;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.totp-subhint {
  margin: 0 0 12px;
  color: var(--text-light);
  font-size: 12px;
  line-height: 1.5;
}

.qr-container {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

/* Backup codes grid */
.backup-codes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.backup-code-chip {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  padding: 6px 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  text-align: center;
  letter-spacing: 1px;
  user-select: all;
  cursor: pointer;
  color: var(--primary);
}

.backup-code-chip:hover {
  background: #EBF4FF;
}

/* ── Password visibility toggle ──────────────────────────────────── */
.password-field {
  position: relative;
  width: 100%;
}

/* Comes after .auth-field input[type="password"] rule (same specificity 0,2,1)
   so cascade order ensures padding-right wins */
.password-field input[type="password"],
.password-field input[type="text"] {
  padding-right: 48px;
  box-sizing: border-box;
}

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  outline: none;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  transition: color 0.15s ease;
}

.password-toggle:hover {
  color: #1e3a5f;
}

.password-toggle:focus {
  outline: none;
}

.password-toggle svg {
  width: 22px;
  height: 22px;
  display: block;
  pointer-events: none;
}
