/*
 * Sesizari: the report button, its panel and the screenshot annotator (_docs/sesizari/contract.md §5).
 * Identical copy in ECommerceCMS_FE/css/sesizari.css and in AppzBizzCMS/css/sesizari.css
 * (byte for byte); change both.
 *
 * Every class starts with "sz-". Colours and radii come from the app's theme variables
 * (--main-color and its family, set per agency); the literal values below are only neutral
 * fallbacks (white, greys) and the annotator's tool colours, never a brand colour.
 * Phone (<= 480px): the panel takes the whole screen. Wider: a ~420px card left of the
 * floating buttons.
 */

.sz-trigger,
.sz-panel,
.sz-annot {
  --sz-accent: var(--main-color, #4b5563);
  --sz-accent-hover: var(--main-color-hover, var(--main-color, #374151));
  --sz-accent-rgb: var(--main-color-rgb, 75, 85, 99);
  --sz-radius: var(--border-radius, 12px);
  --sz-bg: var(--bg-white, #ffffff);
  --sz-text: var(--text-color, #1f2933);
  --sz-muted: var(--text-muted, #6b7280);
  --sz-border: var(--border-color-light, #e5e7eb);
  --sz-error: var(--error-color, #b91c1c);
  --sz-soft: rgba(var(--sz-accent-rgb), 0.08);
  box-sizing: border-box;
}

.sz-trigger *,
.sz-panel *,
.sz-annot * {
  box-sizing: border-box;
}

.sz-trigger[hidden],
.sz-panel[hidden],
.sz-panel [hidden],
.sz-annot [hidden] {
  display: none !important;
}

.sz-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ the floating button */
.sz-trigger {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--sz-accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(var(--sz-accent-rgb), 0.35);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.sz-trigger:hover {
  background: var(--sz-accent-hover);
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(var(--sz-accent-rgb), 0.45);
}

.sz-trigger svg {
  display: block;
}

.sz-dot {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--sz-error);
  border: 2px solid var(--sz-bg);
}

.sz-trigger.sz-has-unseen .sz-dot {
  display: block;
}

/* ------------------------------------------------------------------ the panel */
.sz-panel {
  position: fixed;
  right: 76px;
  bottom: 18px;
  z-index: 2147483647;
  width: 420px;
  max-width: calc(100vw - 92px);
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  background: var(--sz-bg);
  color: var(--sz-text);
  border: 1px solid var(--sz-border);
  border-radius: var(--sz-radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
  overflow: hidden;
}

.sz-panel:focus {
  outline: none;
}

.sz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 8px 16px;
  flex-shrink: 0;
}

.sz-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--sz-text);
}

.sz-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--sz-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.sz-close:hover {
  background: var(--sz-soft);
  color: var(--sz-text);
}

.sz-tabs {
  display: flex;
  gap: 4px;
  padding: 0 12px;
  border-bottom: 1px solid var(--sz-border);
  flex-shrink: 0;
}

.sz-tab {
  position: relative;
  padding: 10px 12px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--sz-muted);
  font-weight: 500;
  cursor: pointer;
}

.sz-tab.sz-tab-on {
  color: var(--sz-accent);
  border-bottom-color: var(--sz-accent);
}

.sz-tab-dot {
  display: none;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--sz-error);
  vertical-align: middle;
}

.sz-tab-dot.sz-on {
  display: inline-block;
}

.sz-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px 16px;
}

.sz-types {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
  border: none;
  min-width: 0;
}

.sz-legend {
  width: 100%;
  margin: 0 0 6px;
  padding: 0;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--sz-muted);
}

.sz-type {
  position: relative;
  margin: 0;
  font-weight: normal;
  cursor: pointer;
}

.sz-type input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.sz-type-label {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--sz-border);
  border-radius: 999px;
  background: var(--sz-bg);
  color: var(--sz-text);
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s;
}

.sz-type input:checked + .sz-type-label {
  border-color: var(--sz-accent);
  background: var(--sz-soft);
  color: var(--sz-accent);
  font-weight: 500;
}

.sz-type input:focus-visible + .sz-type-label {
  outline: 2px solid var(--sz-accent);
  outline-offset: 2px;
}

.sz-desc {
  display: block;
  width: 100%;
  min-height: 120px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--sz-border);
  border-radius: calc(var(--sz-radius) * 0.6);
  background: var(--sz-bg);
  color: var(--sz-text);
  font: inherit;
}

.sz-desc:focus {
  border-color: var(--sz-accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--sz-accent-rgb), 0.2);
}

.sz-counter {
  margin-top: 4px;
  text-align: right;
  font-size: 12px;
  color: var(--sz-muted);
}

.sz-note {
  margin: 6px 0 12px;
  font-size: 12px;
  color: var(--sz-muted);
}

.sz-note p {
  margin: 0 0 4px;
}

.sz-captures {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.sz-capture-count {
  font-size: 12px;
  color: var(--sz-muted);
}

.sz-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sz-thumbs:empty {
  display: none;
}

.sz-thumb {
  position: relative;
  width: 96px;
  height: 64px;
  border: 1px solid var(--sz-border);
  border-radius: calc(var(--sz-radius) * 0.5);
  overflow: hidden;
  background: var(--sz-soft);
}

.sz-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sz-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 16px;
  line-height: 24px;
  cursor: pointer;
}

.sz-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--sz-border);
  border-radius: calc(var(--sz-radius) * 0.6);
  background: var(--sz-bg);
  color: var(--sz-text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.sz-btn:hover:not(:disabled) {
  border-color: var(--sz-accent);
  color: var(--sz-accent);
}

.sz-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.sz-btn-primary {
  border-color: var(--sz-accent);
  background: var(--sz-accent);
  color: #fff;
}

.sz-btn-primary:hover:not(:disabled) {
  background: var(--sz-accent-hover);
  border-color: var(--sz-accent-hover);
  color: #fff;
}

.sz-msg {
  min-height: 0;
  margin-bottom: 10px;
  font-size: 13px;
}

.sz-msg:empty {
  margin: 0;
}

.sz-msg.sz-msg-error {
  color: var(--sz-error);
}

.sz-actions {
  display: flex;
  justify-content: flex-end;
}

.sz-actions .sz-send {
  min-width: 120px;
}

.sz-thanks {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: calc(var(--sz-radius) * 0.6);
  background: var(--sz-soft);
  color: var(--sz-text);
}

/* a Send without an answer: it may have arrived (check the list before sending again) */
.sz-thanks.sz-thanks-warn {
  border-left: 3px solid var(--sz-error);
}

.sz-muted {
  color: var(--sz-muted);
}

.sz-retry {
  margin-top: 8px;
}

.sz-items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sz-item {
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--sz-border);
  border-radius: calc(var(--sz-radius) * 0.6);
}

.sz-item.sz-item-unseen {
  border-color: var(--sz-accent);
  box-shadow: inset 3px 0 0 var(--sz-accent);
}

.sz-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--sz-muted);
}

.sz-item-type {
  font-weight: 600;
  color: var(--sz-text);
}

.sz-item-status {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--sz-soft);
  color: var(--sz-accent);
}

.sz-item-date {
  margin-left: auto;
}

.sz-item-preview {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.sz-answer {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: calc(var(--sz-radius) * 0.5);
  background: var(--sz-soft);
}

.sz-answer-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--sz-accent);
}

.sz-answer-text {
  margin: 2px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* accessible focus everywhere in the widget */
.sz-trigger:focus-visible,
.sz-panel button:focus-visible,
.sz-annot button:focus-visible {
  outline: 2px solid var(--sz-accent);
  outline-offset: 2px;
}

.sz-trigger:focus-visible {
  outline-color: var(--sz-text);
}

/* Phone: the whole screen */
@media (max-width: 480px) {
  .sz-panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  body.sz-open {
    overflow: hidden;
  }
}

/* ------------------------------------------------------------------ the annotator */
.sz-annot {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2147483647;
  display: flex;
  flex-direction: column;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 14px;
}

.sz-annot:focus {
  outline: none;
}

.sz-annot-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  flex-shrink: 0;
}

.sz-annot-tools,
.sz-annot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sz-annot-btn {
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: calc(var(--sz-radius) * 0.6);
  background: transparent;
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.sz-annot-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.sz-annot-btn[aria-pressed="true"] {
  background: #fff;
  color: #111827;
  border-color: #fff;
}

.sz-annot-btn.sz-btn-primary {
  background: var(--sz-accent);
  border-color: var(--sz-accent);
  color: #fff;
}

.sz-annot-stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0 12px 12px;
  overflow: hidden;
}

.sz-annot-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 100%;
  line-height: 0;
}

.sz-annot-canvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 80px);
  border-radius: 4px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  background: #fff;
}

.sz-annot-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}
