:root {
  --brand: #15365F;
  --brand-700: #0F2848;
  --brand-600: #1D4677;
  --brand-100: #DCE6F2;
  --brand-50: #EEF3F9;
  --accent: #E31E26;
  --accent-50: #FDEDEE;
  --bg: #F3F5F9;
  --card: #FFFFFF;
  --ink: #0F1E33;
  --graphite: #455468;
  --muted: #7B8798;
  --faint: #B9C2CE;
  --line: #E6EAF0;
  --line2: #D6DDE7;
  --ok: #1A7F4E;
  --ok-bg: #E7F6EE;
  --warn: #B4610A;
  --warn-bg: #FFF4E2;
  --sh-1: 0 1px 3px rgba(15, 30, 51, 0.08), 0 1px 2px rgba(15, 30, 51, 0.05);
  --sh-2: 0 10px 30px rgba(15, 30, 51, 0.15);
  --sh-float: 0 8px 24px rgba(21, 54, 95, 0.22);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ========================================================
   1. PORTAL HEADER
   ======================================================== */
.portal-header {
  height: 52px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.vpic-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 28px;
  height: 28px;
  flex: none;
}

.vpic-logo b {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.1;
  letter-spacing: 0.04em;
}

.vpic-logo span {
  display: block;
  font-size: 9.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.active-screen-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-600);
}

.active-screen-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-guide, .btn-admin-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-guide {
  background: #fff;
  border: 1px solid var(--line2);
  color: var(--graphite);
}
.btn-guide:hover {
  background: var(--brand-50);
  color: var(--brand);
  border-color: var(--brand-100);
}

.btn-admin-link {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #fff;
}
.btn-admin-link:hover {
  background: var(--brand-600);
  border-color: var(--brand-600);
}

/* ========================================================
   2. IFRAME HOST WRAPPER
   ======================================================== */
.iframe-wrapper {
  flex: 1;
  position: relative;
  width: 100%;
  height: calc(100vh - 52px);
}

.iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ========================================================
   3. FLOATING TOOLBAR
   ======================================================== */
.floating-toolbar {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9990;
  background: #fff;
  border: 1px solid var(--brand-100);
  border-radius: 999px;
  box-shadow: var(--sh-float);
  display: flex;
  align-items: center;
  padding: 5px;
  gap: 4px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--graphite);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.tool-btn:hover {
  background: var(--brand-50);
  color: var(--brand);
}

.inspect-btn.active {
  background: var(--brand);
  color: #fff;
}

.inspect-btn .status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #CBD5E1;
  transition: all 0.2s;
}

.inspect-btn.active .status-indicator {
  background: #10B981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
}

.tool-divider {
  width: 1px;
  height: 22px;
  background: var(--line2);
  margin: 0 2px;
}

.markers-btn .badge-count {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}

.markers-btn.active {
  color: var(--brand);
  background: var(--brand-50);
}

/* ========================================================
   4. MODAL DIALOGS
   ======================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 51, 0.55);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: none;
  place-items: center;
  padding: 16px;
}

.modal-overlay.open {
  display: grid;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--sh-2);
  border: 1px solid var(--line);
  overflow: hidden;
  animation: modal-pop 0.18s ease-out;
}

@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.title-wrap h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand);
  margin-top: 4px;
}

.modal-badge-kind {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 0.06em;
}

.element-preview {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.btn-close-modal {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.btn-close-modal:hover {
  background: var(--brand-50);
  color: var(--ink);
}

.modal-form {
  padding: 18px 20px 20px;
}

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.flex-1 { flex: 1; }

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--graphite);
  margin-bottom: 6px;
}

.form-group .req {
  color: var(--accent);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line2);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px var(--brand-50);
}

.form-group textarea {
  resize: vertical;
  line-height: 1.5;
}

.context-info-box {
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--graphite);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.context-info-box code {
  font-family: ui-monospace, monospace;
  color: var(--brand-600);
  word-break: break-all;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.btn-secondary, .btn-primary {
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary {
  background: #fff;
  border: 1px solid var(--line2);
  color: var(--graphite);
}
.btn-secondary:hover {
  background: var(--brand-50);
  color: var(--brand);
}

.btn-primary {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #fff;
}
.btn-primary:hover {
  background: var(--brand-600);
  border-color: var(--brand-600);
}

/* ========================================================
   5. POPOVER XEM LỊCH SỬ COMMENT
   ======================================================== */
.popover-container {
  display: none;
  position: fixed;
  z-index: 9995;
  width: 340px;
  max-height: 420px;
  background: #fff;
  border: 1px solid var(--line2);
  border-radius: 12px;
  box-shadow: var(--sh-2);
  flex-direction: column;
  overflow: hidden;
  font-size: 12.5px;
}

.popover-container.open {
  display: flex;
}

.popover-header {
  padding: 12px 14px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.popover-header b {
  font-size: 12.5px;
  font-weight: 600;
}

.popover-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

.popover-list {
  padding: 10px;
  overflow-y: auto;
  max-height: 290px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popover-item {
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  border-radius: 8px;
  padding: 10px;
}

.popover-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.popover-author {
  font-weight: 600;
  color: var(--brand);
}

.popover-kind-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.kind-question { background: #E0F2FE; color: #0369A1; }
.kind-issue { background: #FEE2E2; color: #B91C1C; }
.kind-suggestion { background: #FEF3C7; color: #B45309; }
.kind-logic { background: #EDE9FE; color: #6D28D9; }

.popover-body {
  color: var(--ink);
  line-height: 1.45;
  margin-bottom: 6px;
  white-space: pre-wrap;
}

.popover-detail {
  font-size: 11px;
  color: var(--muted);
  border-top: 1px dashed var(--brand-100);
  padding-top: 4px;
  margin-top: 4px;
}

.popover-footer {
  padding: 8px 10px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.btn-add-more {
  width: 100%;
  padding: 7px;
  background: var(--brand-50);
  color: var(--brand);
  border: 1px dashed var(--brand-100);
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}
.btn-add-more:hover {
  background: var(--brand-100);
}

/* ========================================================
   6. HELP GUIDE & TOAST NOTIFICATIONS
   ======================================================== */
.help-card {
  max-width: 580px;
}

.help-content {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.help-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 13px;
  flex: none;
}

.step-body b {
  display: block;
  font-size: 13.5px;
  color: var(--brand);
  margin-bottom: 3px;
}

.step-body p {
  font-size: 12.5px;
  color: var(--graphite);
  line-height: 1.5;
}

.toast-container {
  position: fixed;
  top: 64px;
  right: 20px;
  z-index: 10005;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #fff;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  box-shadow: var(--sh-2);
  border-left: 4px solid var(--brand);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.2s ease-out;
}
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--accent); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
