/* ════════════════════════════════════════════════════════════════════
   Smith Orthodontics — OSHA Training Platform
   Branded stylesheet (matches Ordering Platform + Apps launcher)
   ════════════════════════════════════════════════════════════════════ */

:root {
  /* Brand palette — synced with sOrthoOrdering / Apps launcher */
  --primary:        #1e6eb4;
  --primary-dark:   #155a9c;
  --primary-light:  #e8f4fd;
  --brand-blue:     #5ab4fa;
  --brand-charcoal: #3c3c3c;
  --brand-gray:     #646e6e;

  --success:        #16a34a;
  --success-bg:     #dcfce7;
  --warning:        #d97706;
  --warning-bg:     #fef3c7;
  --danger:         #dc2626;
  --danger-bg:      #fee2e2;

  --bg:             #f0f6fc;
  --bg-elev:        #ffffff;
  --card:           #ffffff;
  --border:         #d6e4f0;
  --border-soft:    #eaf2f9;
  --text:           #1e293b;
  --text-muted:     #64748b;

  --shadow-sm:      0 1px 2px rgba(30,110,180,0.05);
  --shadow-md:      0 2px 12px rgba(30,110,180,0.08);
  --shadow-lg:      0 8px 28px rgba(30,110,180,0.15);

  --radius-sm:      8px;
  --radius:         12px;
  --radius-lg:      16px;

  --topbar-h:       62px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* Subtle background pattern for depth (not overdone) */
body {
  background-image:
    radial-gradient(circle at 20% 0%, rgba(90,180,250,0.06) 0%, transparent 40%),
    radial-gradient(circle at 80% 100%, rgba(30,110,180,0.05) 0%, transparent 45%);
  background-attachment: fixed;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

input, select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(90,180,250,0.20);
}
label {
  display: block;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-row { margin-bottom: 1rem; }
.form-row.inline { display: flex; gap: 0.75rem; align-items: end; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.94rem;
  cursor: pointer;
  transition: background .15s, transform .05s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: var(--text-muted); cursor: not-allowed; opacity: 0.7; }

.btn.secondary {
  background: white;
  color: var(--primary);
  border: 1px solid var(--border);
}
.btn.secondary:hover { background: var(--primary-light); border-color: var(--brand-blue); }

.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }

.btn.success { background: var(--success); }
.btn.success:hover { background: #15803d; }

.btn.small { padding: 0.4rem 0.85rem; font-size: 0.85rem; }

.btn.link {
  background: none;
  color: var(--primary);
  padding: 0;
  font-weight: 600;
}
.btn.link:hover { text-decoration: underline; background: none; }

/* ── App shell + topbar ─────────────────────────────────────────── */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: #ffffff;
  height: var(--topbar-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(30,110,180,0.08);
  border-bottom: 3px solid var(--brand-blue);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.topbar-logo {
  height: 38px;
  width: auto;
  display: block;
}
.topbar-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}
.topbar-app-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
}
.topbar-right {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 13.5px;
  color: var(--text);
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}
.role-badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid #cfe5fa;
}
.role-badge.admin {
  background: var(--brand-charcoal);
  color: white;
  border-color: var(--brand-charcoal);
}

/* ── Tabs ───────────────────────────────────────────────────────── */
.tabs {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 24px;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.tab {
  padding: 0.85rem 1.15rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.tab:hover { color: var(--primary); background: rgba(90,180,250,0.06); }
.tab.active { color: var(--primary); border-bottom-color: var(--brand-blue); }

/* ── Container ──────────────────────────────────────────────────── */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px;
  width: 100%;
  flex: 1;
}

/* ── Section header ─────────────────────────────────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}
.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.section-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.card h2, .card h3 { margin-top: 0; color: var(--text); }
.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

/* Stat tile (admin dashboard) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ── Auth screens (login + setup) ───────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 40px 20px 32px;
  position: relative;
}
.auth-wrap::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--brand-blue));
  z-index: 50;
}
.auth-header {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo {
  width: 220px;
  max-width: 80vw;
  height: auto;
  display: block;
  margin: 16px auto 14px;
}
.auth-header-sub {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 32px 26px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}
.auth-card.wide { max-width: 500px; }
.auth-card h1 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  color: var(--text);
  font-weight: 700;
}
.auth-card .subtitle {
  color: var(--text-muted);
  margin-bottom: 1.4rem;
  font-size: 0.9rem;
  line-height: 1.5;
}
.auth-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fca5a5;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.88rem;
}
.auth-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 32px;
}

/* ── Progress ───────────────────────────────────────────────────── */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.progress-bar {
  flex: 1;
  height: 10px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-blue), var(--primary));
  transition: width 0.4s ease;
}
.progress-fill.complete {
  background: linear-gradient(90deg, var(--success), #15803d);
}
.progress-label {
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 700;
  min-width: 82px;
  text-align: right;
}

/* ── Module list ────────────────────────────────────────────────── */
.module {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.85rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.module:hover { border-color: #c2dbf2; }
.module-head {
  padding: 1.05rem 1.3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
  gap: 12px;
}
.module-head:hover { background: rgba(232,244,253,0.5); }
.module-title { font-weight: 700; color: var(--text); font-size: 0.98rem; }
.module-cfr {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: inherit;
  font-style: italic;
  line-height: 1.45;
}
.module-status {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--border);
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.module-status.passed { background: var(--success-bg); color: var(--success); }
.module-status.in-progress { background: var(--primary-light); color: var(--primary); }
.module-body {
  padding: 0 1.3rem 1.3rem;
  border-top: 1px solid var(--border-soft);
  display: none;
}
.module.open .module-body { display: block; }
.module-body h3 { color: var(--primary); margin-top: 1.3rem; font-size: 1.02rem; }
.module-body h4 { color: var(--brand-charcoal); margin-top: 1.1rem; font-size: 0.95rem; }
.module-body p { margin: 0.5rem 0; font-size: 0.95rem; line-height: 1.6; }
.module-body ul, .module-body ol { margin: 0.6rem 0 0.6rem 1.4rem; font-size: 0.95rem; line-height: 1.6; }
.module-body li { margin: 0.2rem 0; }
.module-body strong { color: var(--text); font-weight: 700; }
.module-body em { color: inherit; }
.module-body table { margin: 0.75rem 0; }
.module-body th, .module-body td { font-size: 0.92rem; }
.module-body figure {
  margin: 1.2rem 0;
  text-align: center;
}
.module-body figure img,
.module-body img.module-figure {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.module-body figcaption,
.module-body .figure-caption {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Module references panel ─────────────────────────────────────── */
.module-refs {
  margin: 0.5rem 0 1.2rem;
  padding: 1rem 1.1rem 1.1rem;
  background: var(--primary-light);
  border: 1px solid #cfe5fa;
  border-radius: var(--radius);
}
.module-refs-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 0.6rem;
}
.module-refs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.6rem;
}
.module-ref-card {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s, transform .05s;
}
.module-ref-card:hover {
  border-color: var(--brand-blue);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.module-ref-card:active { transform: translateY(1px); }
.module-ref-icon {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}
.module-ref-body { min-width: 0; flex: 1; }
.module-ref-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--primary);
  line-height: 1.35;
  margin-bottom: 2px;
}
.module-ref-source {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 3px;
}
.module-ref-desc {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.45;
}
.module-body blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: var(--primary-light);
  border-left: 4px solid var(--brand-blue);
  border-radius: 4px;
  color: var(--text);
  font-style: italic;
}

/* ── Quiz ───────────────────────────────────────────────────────── */
.quiz {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--border);
}
.question { margin-bottom: 1.25rem; }
.question p { font-weight: 600; margin-bottom: 0.55rem; color: var(--text); }
.option {
  display: block;
  padding: 0.7rem 0.95rem;
  margin-bottom: 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  background: white;
}
.option:hover { border-color: var(--brand-blue); background: var(--primary-light); }
.option input { margin-right: 0.6rem; }
.option.correct { background: var(--success-bg); border-color: var(--success); }
.option.incorrect { background: var(--danger-bg); border-color: var(--danger); }
.quiz-result {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  border: 1px solid transparent;
}
.quiz-result.pass { background: var(--success-bg); color: var(--success); border-color: #86efac; }
.quiz-result.fail { background: var(--danger-bg); color: var(--danger); border-color: #fca5a5; }

/* ── Tables ─────────────────────────────────────────────────────── */
table.data {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  background: var(--card);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
table.data th, table.data td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.92rem;
  vertical-align: top;
}
table.data th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafbfd; }

/* ── Signature pad ──────────────────────────────────────────────── */
.sig-pad {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: white;
  width: 100%;
  height: 180px;
  touch-action: none;
  display: block;
  transition: border-color .2s;
}
.sig-pad:hover { border-color: var(--brand-blue); }
.sig-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; }

/* ── Certificate ───────────────────────────────────────────────── */
.certificate-wrap {
  background:
    radial-gradient(circle at top right, rgba(255,255,255,0.6) 0%, transparent 70%),
    linear-gradient(135deg, #fdf6e3 0%, #f5ecd0 100%);
  border: 8px double #b45309;
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem 2.5rem;
  margin: 1.5rem 0;
  text-align: center;
  color: #78350f;
  box-shadow: var(--shadow-md);
  position: relative;
}
.certificate-wrap::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(180, 83, 9, 0.4);
  border-radius: 10px;
  pointer-events: none;
}
.cert-logo {
  width: 140px;
  margin: 0 auto 14px;
  display: block;
  opacity: 0.95;
}
.certificate-wrap h2 {
  color: #92400e;
  font-size: 2.1rem;
  margin: 0 0 0.4rem;
  letter-spacing: 0.02em;
}
.certificate-wrap .cert-tagline {
  color: #a16207;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 1.4rem;
}
.certificate-wrap .cert-name {
  font-size: 1.85rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0.8rem 0;
  font-family: "Brush Script MT", "Lucida Handwriting", cursive;
}
.certificate-wrap .cert-course {
  font-size: 1.15rem;
  margin: 0.5rem 0;
  font-weight: 700;
  color: #111827;
}
.certificate-wrap .cert-meta {
  font-size: 0.9rem;
  color: #78350f;
  margin-top: 1.5rem;
  line-height: 1.7;
}
.cert-signature-line {
  display: inline-block;
  border-top: 1px solid #78350f;
  padding-top: 6px;
  min-width: 240px;
  margin: 1rem 1rem 0;
}
.cert-signature-line img { max-height: 70px; }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.modal h3 { margin-top: 0; color: var(--text); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.2rem;
}

/* ── Notifications ─────────────────────────────────────────────── */
.notice {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.93rem;
  border: 1px solid transparent;
}
.notice.info {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: #bfdbfe;
}
.notice.warning {
  background: var(--warning-bg);
  color: #92400e;
  border-color: #fcd34d;
}
.notice.error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fca5a5;
}
.notice.success {
  background: var(--success-bg);
  color: var(--success);
  border-color: #86efac;
}

/* ── Empty state ───────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}
.empty-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

/* ── Course header card (when viewing a course) ────────────────── */
.course-header {
  background:
    linear-gradient(135deg, rgba(30,110,180,0.95), rgba(90,180,250,0.95)),
    url('../../logo.png') no-repeat right -30px center / contain;
  background-blend-mode: normal;
  color: white;
  border-radius: var(--radius);
  padding: 1.6rem 1.8rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.course-header h2 {
  margin: 0 0 0.4rem;
  font-size: 1.45rem;
  color: white;
}
.course-header .course-meta {
  font-size: 0.9rem;
  opacity: 0.92;
  margin-top: 0.3rem;
}
.course-header .course-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.course-header .btn.secondary {
  background: rgba(255,255,255,0.15);
  color: white;
  border-color: rgba(255,255,255,0.4);
}
.course-header .btn.secondary:hover {
  background: rgba(255,255,255,0.25);
  border-color: white;
}

/* ── Footer ────────────────────────────────────────────────────── */
.app-footer {
  margin-top: auto;
  padding: 18px 24px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--card);
}
.app-footer strong { color: var(--text); }

/* ── Print ─────────────────────────────────────────────────────── */
@media print {
  .topbar, .tabs, .modal-overlay, .btn, .app-footer { display: none !important; }
  body { background: white; }
  .container { max-width: none; padding: 0; }
  .certificate-wrap { box-shadow: none; break-inside: avoid; }
}

/* ── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .topbar { padding: 0 14px; height: 56px; }
  .topbar-logo { height: 32px; }
  .topbar-app-label { display: none; }
  .topbar-user span:not(.role-badge) { display: none; }
  .tabs { padding: 0 14px; }
  .container { padding: 18px 14px; }
  .card { padding: 1rem; }
  table.data { font-size: 0.85rem; }
  .auth-card { padding: 24px 22px; }
  .stat-value { font-size: 22px; }
  .certificate-wrap { padding: 2rem 1.25rem; }
  .certificate-wrap h2 { font-size: 1.5rem; }
  .certificate-wrap .cert-name { font-size: 1.4rem; }
}
