/* Unified feedback panel */
.customer-review-panel {
  position: fixed;
  top: var(--topbar-height);
  right: 0;
  width: min(420px, 100vw);
  height: calc(100vh - var(--topbar-height));
  background: var(--qs-surface);
  border-left: 1px solid var(--qs-border);
  box-shadow: -6px 0 32px rgba(15, 23, 42, 0.12);
  z-index: 195;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.customer-review-panel.open { transform: translateX(0); }

.crv-header {
  padding: 1rem 1.15rem 0.85rem;
  border-bottom: 1px solid var(--qs-border);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--qs-primary-light) 0%, var(--qs-surface) 100%);
}
.crv-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.crv-header h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
}
.crv-header p {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--qs-muted);
  line-height: 1.4;
}
.crv-close-btn {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--qs-border);
  border-radius: 8px;
  background: var(--qs-surface);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--qs-muted);
}
.crv-close-btn:hover { border-color: var(--qs-primary); color: var(--qs-primary); }

.crv-identity-bar {
  margin-top: 0.65rem;
  padding: 0.55rem 0.65rem;
  background: var(--qs-bg);
  border: 1px solid var(--qs-border);
  border-radius: 8px;
  font-size: 0.75rem;
  line-height: 1.45;
}
.crv-identity-bar strong { color: var(--qs-text); }
.crv-identity-bar button {
  margin-left: 0.35rem;
  font-size: 0.7rem;
  color: var(--qs-primary);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

.crv-tabs {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.75rem;
}
.crv-tab {
  flex: 1;
  padding: 0.45rem 0.5rem;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--qs-border);
  border-radius: 8px;
  background: var(--qs-surface);
  color: var(--qs-muted);
  cursor: pointer;
}
.crv-tab:hover { border-color: var(--qs-primary); color: var(--qs-primary); }
.crv-tab.active {
  background: var(--qs-primary);
  border-color: var(--qs-primary);
  color: #fff;
}

.crv-tab-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.crv-tab-panel[hidden] { display: none !important; }

.crv-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: #f8fafc;
}

.crv-msg {
  max-width: 92%;
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.5;
  word-break: break-word;
}
.crv-msg--bot {
  align-self: flex-start;
  background: var(--qs-surface);
  border: 1px solid var(--qs-border);
  border-bottom-left-radius: 4px;
}
.crv-msg--user {
  align-self: flex-end;
  background: var(--qs-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.crv-msg--system {
  align-self: center;
  max-width: 100%;
  font-size: 0.75rem;
  color: var(--qs-muted);
  text-align: center;
  padding: 0.35rem 0.5rem;
}
.crv-msg--typing {
  align-self: flex-start;
  background: var(--qs-surface);
  border: 1px solid var(--qs-border);
  color: var(--qs-muted);
  font-style: italic;
}
.crv-msg--invalid {
  align-self: flex-start;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-bottom-left-radius: 4px;
}
.crv-msg--valid {
  align-self: flex-start;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  border-bottom-left-radius: 4px;
}
.crv-msg-meta {
  font-size: 0.65rem;
  opacity: 0.75;
  margin-top: 0.35rem;
}

.crv-compose {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--qs-border);
  flex-shrink: 0;
  background: var(--qs-surface);
}
.crv-section-hint {
  font-size: 0.7rem;
  color: var(--qs-muted);
  margin-bottom: 0.4rem;
}
.crv-section-hint span { font-weight: 600; color: var(--qs-primary-dark); }
.crv-compose textarea {
  width: 100%;
  min-height: 80px;
  max-height: 160px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--qs-border);
  border-radius: 12px;
  font-family: var(--font);
  font-size: 0.875rem;
  resize: vertical;
  line-height: 1.45;
}
.crv-compose textarea:focus {
  outline: none;
  border-color: var(--qs-primary);
  box-shadow: var(--focus-ring);
}
.crv-compose-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.crv-compose-actions .btn-primary { flex: 1; }
.crv-ai-note {
  margin-top: 0.45rem;
  font-size: 0.65rem;
  color: var(--qs-muted);
  text-align: center;
}

/* All reviews list */
.crv-reviews-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 1rem;
}
.crv-reviews-empty {
  text-align: center;
  color: var(--qs-muted);
  font-size: 0.875rem;
  padding: 2.5rem 1rem;
}
.crv-review-card {
  background: var(--qs-bg);
  border: 1px solid var(--qs-border);
  border-radius: 12px;
  padding: 0.85rem;
  margin-bottom: 0.65rem;
}
.crv-review-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.crv-review-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.crv-review-contact { flex: 1; min-width: 0; }
.crv-review-name {
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.25;
}
.crv-review-title {
  font-size: 0.75rem;
  color: var(--qs-muted);
}
.crv-review-whatsapp {
  font-size: 0.75rem;
  color: var(--qs-primary);
  font-weight: 600;
  margin-top: 0.15rem;
}
.crv-review-whatsapp a {
  color: inherit;
  text-decoration: none;
}
.crv-review-whatsapp a:hover { text-decoration: underline; }
.crv-review-time {
  font-size: 0.65rem;
  color: var(--qs-muted);
  flex-shrink: 0;
}
.crv-review-section {
  display: inline-flex;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--qs-primary-dark);
}
.crv-review-text {
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.crv-review-validity {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.45rem;
  padding: 0.2rem 0.45rem;
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 999px;
}
.crv-review-validity--valid {
  background: #d1fae5;
  color: #065f46;
}
.crv-review-validity--invalid {
  background: #fee2e2;
  color: #991b1b;
}

.crv-list-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--qs-border);
  flex-shrink: 0;
}
.crv-list-toolbar .btn { font-size: 0.7rem; padding: 0.35rem 0.55rem; flex-shrink: 0; }

.crv-reviewers-strip {
  flex-shrink: 0;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--qs-border);
  background: var(--qs-bg);
  max-height: 38%;
  overflow-y: auto;
}
.crv-reviewers-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--qs-muted);
  margin-bottom: 0.45rem;
}
.crv-reviewers-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.crv-reviewer-chip {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  background: var(--qs-surface);
  border: 1px solid var(--qs-border);
  border-radius: 10px;
}
.crv-reviewer-chip-avatar {
  width: 30px;
  height: 30px;
  font-size: 0.65rem;
}
.crv-reviewer-chip-meta { flex: 1; min-width: 0; }
.crv-reviewer-chip-name {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.25;
}
.crv-reviewer-chip-detail {
  font-size: 0.68rem;
  color: var(--qs-muted);
  line-height: 1.35;
}
.crv-reviewer-chip-wa {
  font-size: 0.68rem;
  font-weight: 600;
  margin-top: 0.1rem;
}
.crv-reviewer-chip-wa a {
  color: var(--qs-primary);
  text-decoration: none;
}
.crv-reviewer-chip-wa a:hover { text-decoration: underline; }
.crv-reviewer-chip-count {
  flex-shrink: 0;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--qs-primary-light);
  color: var(--qs-primary-dark);
  border-radius: 999px;
}

.crv-review-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}
.crv-review-page {
  display: inline-flex;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #e0e7ff;
  color: #3730a3;
}
.crv-reviews-empty--hint {
  padding-top: 0.5rem;
  font-size: 0.78rem;
}

/* Identity modal */
.crv-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.crv-modal {
  background: var(--qs-surface);
  border-radius: 14px;
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--qs-shadow);
  max-height: 90vh;
  overflow-y: auto;
}
.crv-modal h3 { margin: 0 0 0.35rem; font-size: 1.15rem; }
.crv-modal > p { margin: 0 0 1rem; font-size: 0.85rem; color: var(--qs-muted); line-height: 1.45; }
.crv-modal label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.crv-modal input,
.crv-modal select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--qs-border);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  font-family: var(--font);
  font-size: 0.9rem;
  background: var(--qs-surface);
  color: var(--qs-text);
}
.crv-modal select {
  cursor: pointer;
  appearance: auto;
}
.crv-modal input:focus,
.crv-modal select:focus {
  outline: none;
  border-color: var(--qs-primary);
  box-shadow: var(--focus-ring);
}
.crv-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

body.crv-panel-open .main-content {
  margin-right: min(420px, 100vw);
  transition: margin-right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 960px) {
  body.crv-panel-open .main-content { margin-right: 0; }
}

@media print {
  .customer-review-panel,
  .crv-modal-overlay { display: none !important; }
}
