/* ============================================================================
   Nexus Technology Solutions — Customer Portal & Training Module Stylesheet
   Matches main-2.css design tokens while meeting WCAG 2.1 AA contrast & focus.
   ============================================================================ */

:root {
  --portal-bg: #f1f5f9;
  --portal-surface: #ffffff;
  --portal-border: #e2e8f0;
  --portal-text: #0f172a;
  --portal-muted: #475569;
  --portal-danger: #b91c1c;
  --portal-danger-bg: #fef2f2;
  --portal-success: #15803d;
  --portal-success-bg: #f0fdf4;
  --portal-warn: #b45309;
  --portal-warn-bg: #fffbeb;
  --portal-info: #0369a1;
  --portal-info-bg: #f0f9ff;
}

body.portal-body {
  background: var(--portal-bg);
  color: var(--portal-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Ensure HTML [hidden] always overrides flex/grid display rules */
[hidden] {
  display: none !important;
}

/* Focus indicators for WCAG 2.1 AA keyboard navigation */
.portal-body :focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Login / Auth Shell ── */
.portal-auth-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-900) 0%, var(--brand-800) 55%, var(--dark) 100%);
  padding: 24px;
}

.portal-auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-xl);
  position: relative;
  overflow: hidden;
}

.portal-auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

.portal-auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.portal-auth-logo {
  height: 52px;
  width: auto;
  margin: 0 auto 14px;
}

.portal-auth-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand-900);
  margin-bottom: 4px;
}

.portal-auth-sub {
  font-size: 0.92rem;
  color: var(--portal-muted);
}

.portal-auth-footer {
  margin-top: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.875rem;
}

.portal-auth-back {
  color: rgba(255, 255, 255, 0.85);
  margin-top: 20px;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.portal-auth-back:hover {
  color: var(--accent);
}

/* ── Top App Bar ── */
.portal-topbar {
  background: var(--brand-900);
  color: var(--white);
  border-bottom: 2px solid rgba(0, 194, 255, 0.35);
  position: sticky;
  top: 0;
  z-index: 120;
}

.portal-topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--white);
  font-weight: 700;
  font-size: 1rem;
}

.portal-brand img {
  height: 36px;
  width: auto;
}

.portal-brand-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(0, 194, 255, 0.16);
  color: var(--accent);
  border: 1px solid rgba(0, 194, 255, 0.4);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.portal-nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.portal-tab-btn {
  color: rgba(255, 255, 255, 0.82);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background 0.18s ease, color 0.18s ease;
}

.portal-tab-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
}

.portal-tab-btn.active {
  background: var(--brand);
  color: var(--white);
}

.portal-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal-icon-btn {
  position: relative;
  color: var(--white);
  background: rgba(255, 255, 255, 0.08);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.portal-icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.portal-notif-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: var(--white);
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.portal-user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.9);
}

.portal-user-org {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.78rem;
}

/* ── Main Layout ── */
.portal-main {
  flex: 1;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.portal-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.portal-page-head h1 {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--brand-900);
}

.portal-page-sub {
  color: var(--portal-muted);
  font-size: 0.95rem;
}

/* ── Cards, Grids & KPIs ── */
.portal-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.portal-kpi-card {
  background: var(--portal-surface);
  border: 1px solid var(--portal-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.portal-kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--portal-muted);
  margin-bottom: 6px;
}

.portal-kpi-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--brand-900);
}

.portal-card {
  background: var(--portal-surface);
  border: 1px solid var(--portal-border);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}

.portal-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--portal-border);
}

.portal-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.portal-training-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
}

.training-card {
  background: var(--portal-surface);
  border: 1px solid var(--portal-border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.training-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.training-card.is-overdue {
  border-left: 4px solid var(--portal-danger);
}

.training-card-title {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--brand-900);
  margin-bottom: 6px;
}

.training-card-desc {
  font-size: 0.88rem;
  color: var(--portal-muted);
  line-height: 1.5;
}

.training-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--portal-muted);
  margin-top: 10px;
}

/* ── Progress Bars & Badges ── */
.progress-track {
  width: 100%;
  height: 8px;
  background: var(--gray-200);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width 0.25s ease;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-neutral { background: var(--gray-100); color: var(--gray-800); }
.badge-info    { background: var(--portal-info-bg); color: var(--portal-info); }
.badge-success { background: var(--portal-success-bg); color: var(--portal-success); }
.badge-warn    { background: var(--portal-warn-bg); color: var(--portal-warn); }
.badge-danger  { background: var(--portal-danger-bg); color: var(--portal-danger); }

/* ── Forms & Buttons ── */
.portal-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.portal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.portal-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-800);
}

.portal-field input[type="text"],
.portal-field input[type="email"],
.portal-field input[type="password"],
.portal-field input[type="number"],
.portal-field input[type="date"],
.portal-field input[type="file"],
.portal-field select,
.portal-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--portal-text);
  background: var(--white);
}

.portal-field input:disabled,
.portal-field input[readonly] {
  background: var(--gray-100);
  color: var(--portal-muted);
}

.btn-p {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.15s ease;
  cursor: pointer;
}

.btn-p-primary { background: var(--brand); color: var(--white); }
.btn-p-primary:hover { background: var(--brand-700); color: var(--white); }
.btn-p-secondary { background: var(--gray-100); color: var(--gray-800); border: 1px solid #cbd5e1; }
.btn-p-secondary:hover { background: var(--gray-200); }
.btn-p-danger { background: var(--portal-danger-bg); color: var(--portal-danger); border: 1px solid #fecaca; }
.btn-p-danger:hover { background: #fee2e2; }
.btn-p-sm { padding: 6px 10px; font-size: 0.8rem; }
.btn-p:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── Tables ── */
.portal-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.portal-table th,
.portal-table td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--portal-border);
  vertical-align: middle;
}

.portal-table th {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--portal-muted);
  background: var(--gray-50);
}

.portal-table tr:hover td {
  background: #f8fafc;
}

/* ── Sub-navigation in Admin / Reports ── */
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.subtab-btn {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--white);
  color: var(--portal-muted);
  border: 1px solid var(--portal-border);
}

.subtab-btn.active {
  background: var(--brand-900);
  color: var(--white);
  border-color: var(--brand-900);
}

/* ── Training Player & PDF Slideshow ── */
.player-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 22px;
  align-items: start;
}

.player-sidebar {
  background: var(--white);
  border: 1px solid var(--portal-border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.player-step-btn {
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 0.88rem;
  color: var(--portal-text);
}

.player-step-btn:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--portal-border);
}

.player-step-btn.active {
  background: var(--brand-100);
  border-color: var(--brand-300);
  font-weight: 600;
}

.player-step-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.player-stage {
  background: var(--white);
  border: 1px solid var(--portal-border);
  border-radius: var(--radius-md);
  padding: 22px;
}

.video-container {
  background: #000000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.video-container video {
  width: 100%;
  max-height: 70vh;
  display: block;
}

.video-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--gray-50);
  border: 1px solid var(--portal-border);
  border-radius: var(--radius-sm);
}

.pdf-slideshow-shell {
  background: #1e293b;
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pdf-canvas-wrap {
  width: 100%;
  max-height: 72vh;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: #0f172a;
  border-radius: 4px;
  padding: 12px;
}

.pdf-canvas-wrap canvas {
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  max-width: 100%;
  height: auto;
}

.pdf-controls {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--white);
  font-size: 0.9rem;
}

/* ── Quiz UI ── */
.quiz-question-card {
  border: 1px solid var(--portal-border);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 16px;
  background: var(--gray-50);
}

.quiz-option-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-top: 8px;
  background: var(--white);
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.quiz-option-label:hover {
  border-color: var(--brand);
}

/* ── Modals & Banners ── */
.portal-alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.portal-alert-error   { background: var(--portal-danger-bg); color: var(--portal-danger); border: 1px solid #fecaca; }
.portal-alert-success { background: var(--portal-success-bg); color: var(--portal-success); border: 1px solid #bbf7d0; }
.portal-alert-info    { background: var(--portal-info-bg); color: var(--portal-info); border: 1px solid #bae6fd; }

.portal-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 300;
}

.portal-modal {
  background: var(--white);
  border-radius: var(--radius-md);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-xl);
}

.portal-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--portal-border);
}

.notif-popover {
  position: absolute;
  top: 64px;
  right: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: 440px;
  overflow-y: auto;
  background: var(--white);
  color: var(--portal-text);
  border: 1px solid var(--portal-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: 250;
  padding: 14px;
}

/* ── Portal Home & Module Launcher ── */
.portal-welcome-banner {
  background: linear-gradient(135deg, var(--brand-900) 0%, var(--brand-800) 65%, var(--brand-700) 100%);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 26px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(0, 194, 255, 0.2);
}

.portal-welcome-banner h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--white);
  margin-bottom: 6px;
}

.portal-welcome-banner p {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.82);
}

.portal-modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 26px;
}

.portal-module-tile {
  background: var(--portal-surface);
  border: 1px solid var(--portal-border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.portal-module-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-300);
}

.portal-module-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--brand-100);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.portal-module-widget {
  background: var(--gray-50);
  border: 1px solid var(--portal-border);
  border-radius: var(--radius-sm);
  padding: 14px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .player-layout {
    grid-template-columns: 1fr;
  }
  .portal-topbar-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 16px;
  }
  .portal-nav-tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-top: 6px;
  }
}

/* ── Print Stylesheet for Reports ── */
@media print {
  .portal-topbar,
  .subtabs,
  .no-print,
  button,
  .btn-p {
    display: none !important;
  }
  body.portal-body {
    background: #ffffff;
  }
  .portal-main {
    max-width: 100%;
    padding: 0;
  }
  .portal-card {
    border: none;
    box-shadow: none;
    padding: 0;
  }
}

