/* ============================================
   Review Widget — Websalia Client Feedback
   ============================================
   Widget flotante para feedback guiado en entregables.
   Se activa con data-review-project en el <body>.
   ============================================ */

/* --- CSS Custom Properties (overridable per deliverable theme) --- */
:root {
  --rw-primary: #2563eb;
  --rw-primary-hover: #1d4ed8;
  --rw-success: #16a34a;
  --rw-warning: #f59e0b;
  --rw-danger: #dc2626;
  --rw-bg: #ffffff;
  --rw-bg-secondary: #f8fafc;
  --rw-text: #1e293b;
  --rw-text-secondary: #64748b;
  --rw-border: #e2e8f0;
  --rw-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  --rw-radius: 12px;
  --rw-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --rw-panel-width: 400px;
  --rw-z-index: 99999;
}

/* --- Floating Button --- */
.rw-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--rw-z-index);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--rw-primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-family: var(--rw-font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--rw-shadow);
  transition: background 0.2s, transform 0.15s;
  line-height: 1;
}

.rw-fab:hover {
  background: var(--rw-primary-hover);
  transform: translateY(-1px);
}

.rw-fab:active {
  transform: translateY(0);
}

.rw-fab--complete {
  background: var(--rw-success);
}

.rw-fab--complete:hover {
  background: #15803d;
}

.rw-fab--sent {
  background: var(--rw-text-secondary);
  cursor: default;
  pointer-events: none;
}

.rw-fab__icon {
  font-size: 18px;
  line-height: 1;
}

.rw-fab__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 11px;
  font-size: 12px;
  font-weight: 700;
}

/* Saved indicator (ephemeral toast) */
.rw-toast {
  position: fixed;
  bottom: 80px;
  right: 24px;
  z-index: var(--rw-z-index);
  padding: 8px 16px;
  background: var(--rw-success);
  color: #fff;
  border-radius: 8px;
  font-family: var(--rw-font);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.rw-toast--visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Overlay --- */
.rw-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--rw-z-index) + 1);
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.rw-overlay--open {
  opacity: 1;
  pointer-events: auto;
}

/* --- Panel (slide-in from right) --- */
.rw-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: calc(var(--rw-z-index) + 2);
  width: var(--rw-panel-width);
  max-width: 90vw;
  background: var(--rw-bg);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  font-family: var(--rw-font);
  color: var(--rw-text);
}

.rw-panel--open {
  transform: translateX(0);
}

/* Panel header */
.rw-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rw-border);
  flex-shrink: 0;
}

.rw-panel__section-label {
  font-size: 13px;
  color: var(--rw-text-secondary);
  margin: 0;
}

.rw-panel__section-name {
  font-size: 17px;
  font-weight: 700;
  margin: 4px 0 0;
}

.rw-panel__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--rw-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  color: var(--rw-text-secondary);
  transition: background 0.15s;
  flex-shrink: 0;
}

.rw-panel__close:hover {
  background: var(--rw-bg-secondary);
}

/* Panel body (scrollable) */
.rw-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Rationale block */
.rw-rationale {
  padding: 14px 16px;
  background: var(--rw-bg-secondary);
  border-left: 3px solid var(--rw-primary);
  border-radius: 0 8px 8px 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--rw-text);
  margin-bottom: 20px;
}

/* Change notice (for round 2+) */
.rw-change-notice {
  padding: 12px 16px;
  background: #fef3c7;
  border-left: 3px solid var(--rw-warning);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  line-height: 1.5;
  color: #92400e;
  margin-bottom: 20px;
}

/* Response options */
.rw-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rw-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--rw-bg);
  border: 2px solid var(--rw-border);
  border-radius: var(--rw-radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.rw-option:hover {
  border-color: var(--rw-primary);
  background: #f0f5ff;
}

.rw-option--selected {
  border-color: var(--rw-primary);
  background: #eff6ff;
}

.rw-option--approve.rw-option--selected {
  border-color: var(--rw-success);
  background: #f0fdf4;
}

.rw-option--reject.rw-option--selected {
  border-color: var(--rw-danger);
  background: #fef2f2;
}

.rw-option__radio {
  width: 20px;
  height: 20px;
  border: 2px solid var(--rw-border);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
}

.rw-option--selected .rw-option__radio {
  border-color: var(--rw-primary);
}

.rw-option--approve.rw-option--selected .rw-option__radio {
  border-color: var(--rw-success);
}

.rw-option--reject.rw-option--selected .rw-option__radio {
  border-color: var(--rw-danger);
}

.rw-option--selected .rw-option__radio::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rw-primary);
}

.rw-option--approve.rw-option--selected .rw-option__radio::after {
  background: var(--rw-success);
}

.rw-option--reject.rw-option--selected .rw-option__radio::after {
  background: var(--rw-danger);
}

.rw-option__content {
  flex: 1;
}

.rw-option__label {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.rw-option__note {
  display: none;
  margin-top: 10px;
}

.rw-option--selected .rw-option__note {
  display: block;
}

.rw-option__note textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1px solid var(--rw-border);
  border-radius: 8px;
  font-family: var(--rw-font);
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  color: var(--rw-text);
  background: var(--rw-bg);
}

.rw-option__note textarea:focus {
  outline: none;
  border-color: var(--rw-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.rw-option__note-label {
  display: block;
  font-size: 12px;
  color: var(--rw-text-secondary);
  margin-bottom: 6px;
}

/* Panel footer */
.rw-panel__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--rw-border);
  flex-shrink: 0;
}

.rw-nav-btn {
  padding: 8px 16px;
  background: var(--rw-bg);
  border: 1px solid var(--rw-border);
  border-radius: 8px;
  font-family: var(--rw-font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--rw-text);
  transition: background 0.15s;
}

.rw-nav-btn:hover {
  background: var(--rw-bg-secondary);
}

.rw-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Progress bar */
.rw-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--rw-text-secondary);
  font-weight: 600;
}

.rw-progress__bar {
  width: 80px;
  height: 6px;
  background: var(--rw-border);
  border-radius: 3px;
  overflow: hidden;
}

.rw-progress__fill {
  height: 100%;
  background: var(--rw-primary);
  border-radius: 3px;
  transition: width 0.3s;
}

.rw-progress--complete .rw-progress__fill {
  background: var(--rw-success);
}

/* --- Section highlight (active section indicator) --- */
[data-review].rw-section--active {
  outline: 2px dashed rgba(37, 99, 235, 0.3);
  outline-offset: 8px;
  border-radius: 4px;
  transition: outline-color 0.3s;
}

/* --- Section chooser (when between sections) --- */
.rw-chooser {
  margin-bottom: 20px;
}

.rw-chooser__title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}

.rw-chooser__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rw-chooser__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--rw-bg);
  border: 1px solid var(--rw-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}

.rw-chooser__item:hover {
  border-color: var(--rw-primary);
  background: #f0f5ff;
}

.rw-chooser__status {
  font-size: 14px;
  flex-shrink: 0;
}

/* --- Submit confirmation --- */
.rw-submit-view {
  text-align: center;
  padding: 40px 20px;
}

.rw-submit-view__icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.rw-submit-view__title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.rw-submit-view__text {
  font-size: 14px;
  color: var(--rw-text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

.rw-submit-btn {
  padding: 12px 32px;
  background: var(--rw-success);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--rw-font);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.rw-submit-btn:hover {
  background: #15803d;
}

.rw-submit-btn:disabled {
  background: var(--rw-text-secondary);
  cursor: not-allowed;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .rw-panel {
    width: 100vw;
    max-width: 100vw;
  }

  .rw-fab {
    bottom: 16px;
    right: 16px;
    padding: 10px 16px;
    font-size: 14px;
  }
}
