/* contract-artifact-panel.css — Phase 9 Tier 2
 * Right-rail sticky panel for previewing contract artifacts (.docx) like Claude.
 * Slide-in from right, version dropdown, simple diff view.
 */

.cap-root {
  position: fixed;
  top: 0;
  right: 0;
  width: 0;
  height: 100vh;
  background: #ffffff;
  border-left: 1px solid #e3e3e3;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.06);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.cap-root.cap-open {
  width: min(560px, 48vw);
}

.cap-root[hidden] {
  display: none;
}

@media (max-width: 768px) {
  .cap-root.cap-open {
    width: 100vw;
  }
}

.cap-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid #efefef;
  background: linear-gradient(180deg, #fafafa 0%, #ffffff 100%);
  flex-shrink: 0;
}

.cap-header__icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #2563eb;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.cap-header__meta {
  flex: 1;
  min-width: 0;
}

.cap-header__title {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cap-header__subtitle {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cap-header__close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cap-header__close:hover {
  background: #f3f4f6;
  color: #111827;
}

.cap-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid #efefef;
  background: #ffffff;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.cap-toolbar__group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cap-toolbar__label {
  font-size: 11px;
  color: #6b7280;
  font-weight: 500;
}

.cap-version-select {
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
  cursor: pointer;
  min-width: 80px;
}

.cap-btn {
  font-size: 12px;
  padding: 5px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  color: #374151;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  transition: all 0.15s;
}

.cap-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.cap-btn--primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.cap-btn--primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.cap-btn--toggle.is-active {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
}

.cap-spacer {
  flex: 1;
}

.cap-body {
  flex: 1;
  overflow: auto;
  padding: 20px 24px 40px;
  background: #fafafa;
}

.cap-doc {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 28px 32px;
  white-space: pre-wrap;
  font-family: "Times New Roman", Georgia, serif;
  font-size: 13.5px;
  line-height: 1.65;
  color: #1f2937;
  word-wrap: break-word;
}

.cap-doc h1, .cap-doc h2, .cap-doc h3 {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 700;
  margin-top: 14px;
  margin-bottom: 6px;
  color: #111827;
}

.cap-doc h1 { font-size: 16px; text-align: center; text-transform: uppercase; }
.cap-doc h2 { font-size: 14.5px; }
.cap-doc h3 { font-size: 13.5px; }

.cap-doc__article-heading {
  font-weight: 700;
  color: #1d4ed8;
  margin-top: 18px;
  display: block;
}

.cap-doc__appendix-heading {
  font-weight: 700;
  color: #b45309;
  margin-top: 22px;
  display: block;
  border-top: 1px dashed #e5e7eb;
  padding-top: 14px;
}

.cap-empty {
  padding: 60px 24px;
  text-align: center;
  color: #9ca3af;
}

.cap-empty__icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.cap-empty__title {
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 4px;
}

.cap-empty__desc {
  font-size: 12px;
  color: #9ca3af;
}

/* Diff view */
.cap-diff {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px 20px;
  font-family: "SF Mono", Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.cap-diff__line {
  padding: 1px 8px;
  margin: 0 -8px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.cap-diff__line--add {
  background: #ecfdf5;
  color: #065f46;
  border-left: 3px solid #10b981;
}

.cap-diff__line--del {
  background: #fef2f2;
  color: #991b1b;
  border-left: 3px solid #ef4444;
}

.cap-diff__line--ctx {
  color: #6b7280;
}

.cap-diff__hunk {
  font-size: 11px;
  color: #2563eb;
  padding: 6px 0 2px;
  font-weight: 600;
  border-top: 1px dashed #e5e7eb;
  margin-top: 8px;
}

.cap-diff__hunk:first-child {
  border-top: none;
  margin-top: 0;
}

/* Backdrop on mobile */
@media (max-width: 768px) {
  .cap-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 8999;
    display: none;
  }
  .cap-root.cap-open ~ .cap-backdrop {
    display: block;
  }
}

/* Open-in-panel button injected next to "Tải file" */
.asst-cta-btn--open-panel {
  margin-left: 6px;
}
.asst-cta-btn--open-panel .asst-cta-btn__ic::before {
  content: "📑";
}
