/* ============================================================================
 * POS NHÀ LÀM · KING'S GRILL — ROLE & PERMISSION-BASED SOP ACADEMY
 * Modern Professional Minimalism · WCAG 2.2 AA · Responsive 320px–1920px
 * ============================================================================ */

.sop-academy-backdrop {
  position: fixed;
  inset: 0;
  z-index: 13500;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  font-family: var(--font-sans, "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  color: #0f172a;
  opacity: 1;
  transition: opacity 160ms ease;
}

.sop-academy-backdrop.hidden {
  display: none !important;
}

.sop-academy-dialog {
  width: min(1080px, 100%);
  max-height: min(88vh, 840px);
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.24);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

/* Header & Role/Permission Identity Banner */
.sop-academy-header {
  padding: 16px 20px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.sop-academy-toprow {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sop-academy-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sop-academy-badge-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sop-academy-heading {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.sop-academy-subheading {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: #475569;
  line-height: 1.4;
}

.sop-academy-close-btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.sop-academy-close-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.sop-academy-close-btn:focus-visible,
.sop-cat-chip:focus-visible,
.sop-nav-card:focus-visible,
.sop-quiz-opt:focus-visible,
.sop-action-btn:focus-visible,
.sop-search-input:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Role & Progress Bar Strip */
.sop-identity-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 11px;
}

.sop-identity-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.sop-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  border: 1px solid transparent;
}

.sop-tag-role {
  background: #eff6ff;
  color: #1e40af;
  border-color: #bfdbfe;
}

.sop-tag-dept {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}

.sop-tag-scope {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

.sop-tag-strict {
  background: #f8fafc;
  color: #334155;
  border-color: #cbd5e1;
  font-weight: 600;
}

.sop-progress-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
}

.sop-progress-lbl {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.sop-progress-track {
  width: 96px;
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  flex-shrink: 0;
}

.sop-progress-fill {
  height: 100%;
  background: #16a34a;
  border-radius: 999px;
  transition: width 200ms ease;
}

/* Filter & Search Toolbar */
.sop-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sop-search-wrap {
  position: relative;
  flex: 1 1 220px;
  min-width: 180px;
  max-width: 300px;
}

.sop-search-input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px 8px 34px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #ffffff;
  color: #0f172a;
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
}

.sop-search-ico {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  pointer-events: none;
}

.sop-cat-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  flex: 2 1 320px;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.sop-cat-chip {
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.sop-cat-chip:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.sop-cat-chip.is-selected {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #ffffff;
}

.sop-cat-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  font-variant-numeric: tabular-nums;
}

.sop-cat-chip.is-selected .sop-cat-count {
  background: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

/* Split Body: Left SOP List + Right Micro-Lesson Reader */
.sop-body-split {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
}

.sop-list-pane {
  border-right: 1px solid #e2e8f0;
  background: #f8fafc;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sop-nav-card {
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 11px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #0f172a;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 56px;
  transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.sop-nav-card:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.sop-nav-card.is-selected {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: inset 3px 0 0 #2563eb;
}

.sop-nav-status {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  color: #64748b;
  font-size: 11.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.sop-nav-card.is-completed .sop-nav-status {
  background: #dcfce7;
  border-color: #16a34a;
  color: #15803d;
}

.sop-nav-main {
  min-width: 0;
  flex: 1;
}

.sop-nav-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
  margin-bottom: 4px;
}

.sop-nav-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11.5px;
  color: #64748b;
}

.sop-prio-pill {
  background: #dbeafe;
  color: #1e40af;
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 10.5px;
}

/* Reader Pane */
.sop-reader-pane {
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sop-reader-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.sop-reader-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.sop-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #1d4ed8;
  background: #eff6ff;
  padding: 3px 9px;
  border-radius: 6px;
}

.sop-time-badge {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.sop-reader-title {
  margin: 2px 0 0;
  font-size: 19px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.3;
}

.sop-reader-goal {
  margin: 0;
  font-size: 13.5px;
  color: #334155;
  line-height: 1.5;
  background: #f8fafc;
  padding: 9px 12px;
  border-radius: 9px;
  border-left: 3px solid #2563eb;
}

/* Numbered Micro-Steps */
.sop-steps-section-title {
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
}

.sop-steps-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sop-step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
}

.sop-step-num {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #1d4ed8;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.sop-step-text {
  font-size: 14px;
  line-height: 1.5;
  color: #1e293b;
}

.sop-step-text strong {
  color: #0f172a;
  font-weight: 700;
}

.sop-step-text code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #0f172a;
}

/* Do & Avoid Callout Grid */
.sop-callouts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.sop-callout {
  padding: 11px 13px;
  border-radius: 11px;
  font-size: 13px;
  line-height: 1.48;
  border: 1px solid transparent;
}

.sop-callout-title {
  font-weight: 800;
  font-size: 12.5px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sop-callout-do {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #14532d;
}

.sop-callout-avoid {
  background: #fffbeb;
  border-color: #fde68a;
  color: #78350f;
}

/* Quick 1-Question Comprehension Check */
.sop-quiz-card {
  padding: 14px 16px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sop-quiz-q {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.45;
}

.sop-quiz-opts {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sop-quiz-opt {
  min-height: 44px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.sop-quiz-opt:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.sop-quiz-opt.is-correct {
  background: #dcfce7;
  border-color: #16a34a;
  color: #14532d;
  font-weight: 700;
}

.sop-quiz-opt.is-wrong {
  background: #fef2f2;
  border-color: #dc2626;
  color: #7f1d1d;
}

.sop-quiz-feedback {
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 8px;
  line-height: 1.4;
}

.sop-quiz-feedback.ok {
  background: #dcfce7;
  color: #14532d;
}

.sop-quiz-feedback.err {
  background: #fef2f2;
  color: #991b1b;
}

/* Reader Footer Navigation */
.sop-reader-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
  margin-top: auto;
}

.sop-action-btn {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.sop-action-btn:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.sop-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sop-action-btn.primary {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #ffffff;
}

.sop-action-btn.primary:hover:not(:disabled) {
  background: #1e40af;
  border-color: #1e40af;
}

.sop-action-btn.completed {
  background: #15803d;
  border-color: #15803d;
  color: #ffffff;
}

.sop-empty-state {
  padding: 28px 16px;
  text-align: center;
  color: #64748b;
  font-size: 13.5px;
}

.sop-mobile-back-btn {
  display: none;
}

/* Mobile Responsive (< 780px): Master-Detail Toggle */
@media (max-width: 780px) {
  .sop-academy-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .sop-academy-dialog {
    width: 100%;
    height: 94vh;
    max-height: 94vh;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
  }

  .sop-academy-header {
    padding: 12px 14px 10px;
    gap: 9px;
  }

  .sop-academy-heading {
    font-size: 15.5px;
  }

  .sop-body-split {
    grid-template-columns: 1fr;
  }

  .sop-body-split.mobile-reading .sop-list-pane {
    display: none;
  }

  .sop-body-split:not(.mobile-reading) .sop-reader-pane {
    display: none;
  }

  .sop-reader-pane {
    padding: 14px 15px 22px;
  }

  .sop-mobile-back-btn {
    display: inline-flex;
    align-self: flex-start;
    min-height: 40px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #0f172a;
    font-size: 12.5px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    align-items: center;
    gap: 6px;
  }

  .sop-search-wrap {
    max-width: none;
    flex: 1 1 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sop-academy-backdrop,
  .sop-progress-fill,
  .sop-nav-card,
  .sop-cat-chip,
  .sop-action-btn,
  .sop-academy-close-btn {
    transition: none !important;
  }
}
