/*
 * Sesizări: the super admin page #sesizari (js/views/Sesizari.js, js/templates/sesizari/*.html,
 * _docs/sesizari/contract.md §6). Admin only (not one of the files shared with the POS).
 *
 * Every class starts with "sza-". Colours and radii come from the theme variables (css/style.scss,
 * overridden per agency); the literal values are only neutral fallbacks, never a brand colour.
 * Below 1024px the list and the detail are shown one at a time ("Înapoi" goes back to the list);
 * from 1024px they stand side by side, the detail sticky next to the list.
 */

.sza-page {
  --sza-accent: var(--main-color, #4b5563);
  --sza-accent-rgb: var(--main-color-rgb, 75, 85, 99);
  --sza-text: var(--text-color, #333333);
  --sza-muted: var(--text-light, #666666);
  --sza-border: var(--border-color-light, #eaeaea);
  --sza-bg: var(--bg-white, #ffffff);
  --sza-soft: var(--bg-grey-light, #f9f9f9);
  --sza-ok: var(--success-color, #3c763d);
  --sza-bad: var(--error-color, #b91c1c);
  --sza-warn: var(--warning-color, #8a6d3b);
  --sza-radius: var(--border-radius, 2px);
  color: var(--sza-text);
}

.sza,
.sza * {
  box-sizing: border-box;
}

.sza-title {
  margin: 0 0 12px;
}

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

.sza-mono {
  font-family: Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.sza-break {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.sza-nowrap {
  white-space: nowrap;
}

.sza-card {
  background: var(--sza-bg);
  border: 1px solid var(--sza-border);
  border-radius: var(--sza-radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  min-width: 0;
}

.sza-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
}

.sza-card-head h4 {
  margin: 0 0 8px;
}

.sza-msg {
  margin: 6px 0 0;
  min-height: 0;
}

.sza-msg:empty {
  display: none;
}

.sza-msg.is-ok {
  color: var(--sza-ok);
}

.sza-msg.is-bad {
  color: var(--sza-bad);
}

.sza-msg.is-warn {
  color: var(--sza-warn);
}

.sza-loading {
  margin: 8px 0;
}

/* ------------------------------------------------------------------ no access */

.sza-noaccess {
  border: 1px solid var(--sza-border);
  border-radius: var(--sza-radius);
  background: var(--sza-bg);
  padding: 24px 16px;
  text-align: center;
}

.sza-noaccess .fa {
  font-size: 28px;
  color: var(--sza-muted);
}

/* ------------------------------------------------------------------ switches */

.sza-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
}

.sza-switch {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  font-weight: normal;
  cursor: pointer;
  flex: 1 1 220px;
  min-width: 0;
  position: relative;
}

.sza-switch-input {
  position: absolute;
  opacity: 0;
  width: 40px;
  height: 22px;
  margin: 0;
}

.sza-switch-track {
  flex: 0 0 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--sza-border);
  position: relative;
  transition: background 0.15s ease;
  margin-top: 1px;
}

.sza-switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--sza-bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

.sza-switch-input:checked + .sza-switch-track {
  background: var(--sza-accent);
}

.sza-switch-input:checked + .sza-switch-track::after {
  transform: translateX(18px);
}

.sza-switch-input:focus-visible + .sza-switch-track {
  outline: 2px solid var(--sza-accent);
  outline-offset: 2px;
}

.sza-switch-input:disabled + .sza-switch-track {
  opacity: 0.5;
}

.sza-switch-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ------------------------------------------------------------------ layout */

.sza-split {
  display: block;
}

.sza-list-pane,
.sza-detail-pane {
  min-width: 0;
}

/* Below 1024px: one at a time (the config card goes with the list). */
@media (max-width: 1023px) {
  .sza.has-detail .sza-list-pane,
  .sza.has-detail .sza-config {
    display: none;
  }

  .sza:not(.has-detail) .sza-detail-pane {
    display: none;
  }
}

@media (min-width: 1024px) {
  .sza-split {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 14px;
    align-items: start;
  }

  .sza-detail-pane {
    position: sticky;
    top: 60px;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
  }

  .sza-back {
    display: none;
  }
}

/* ------------------------------------------------------------------ list */

.sza-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.sza-chip {
  border: 1px solid var(--sza-border);
  background: var(--sza-bg);
  color: var(--sza-text);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}

.sza-chip:hover {
  border-color: var(--sza-accent);
}

.sza-chip.is-active {
  background: var(--sza-accent);
  border-color: var(--sza-accent);
  color: var(--sza-bg);
}

.sza-chip-count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: rgba(var(--sza-accent-rgb), 0.12);
  font-size: 11px;
  text-align: center;
}

.sza-chip.is-active .sza-chip-count {
  background: rgba(255, 255, 255, 0.25);
}

.sza-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.sza-filters .form-control {
  width: auto;
  flex: 1 1 140px;
  min-width: 0;
}

.sza-filters .sza-filter-search {
  flex: 2 1 200px;
}

.sza-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sza-rows.is-loading {
  opacity: 0.6;
}

.sza-rows > li + li {
  border-top: 1px solid var(--sza-border);
}

.sza-row {
  display: block;
  padding: 8px 6px;
  color: var(--sza-text);
  text-decoration: none;
  border-left: 3px solid transparent;
}

.sza-row:hover,
.sza-row:focus {
  background: var(--sza-soft);
  color: var(--sza-text);
  text-decoration: none;
}

.sza-row.is-selected {
  border-left-color: var(--sza-accent);
  background: rgba(var(--sza-accent-rgb), 0.06);
}

.sza-row-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}

.sza-row-date {
  margin-left: auto;
  font-size: 12px;
}

.sza-row-who {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.sza-row-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  margin-top: 2px;
  color: var(--sza-muted);
  font-size: 13px;
}

.sza-row-icons {
  display: flex;
  gap: 10px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--sza-muted);
}

.sza-row-icons:empty {
  display: none;
}

.sza-icon.is-ok {
  color: var(--sza-ok);
}

.sza-icon.is-bad {
  color: var(--sza-bad);
}

.sza-icon.is-warn {
  color: var(--sza-warn);
}

.sza-type,
.sza-status,
.sza-kind {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.6;
  border: 1px solid var(--sza-border);
  white-space: nowrap;
}

.sza-type {
  background: rgba(var(--sza-accent-rgb), 0.1);
  border-color: transparent;
}

.sza-type-bug {
  background: var(--error-color-light, rgba(185, 28, 28, 0.1));
}

.sza-status-new {
  border-color: var(--sza-accent);
  color: var(--sza-accent);
  font-weight: 600;
}

.sza-status-resolved {
  color: var(--sza-ok);
}

.sza-status-wont_fix,
.sza-status-duplicate {
  color: var(--sza-muted);
}

.sza-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.sza-empty {
  margin: 12px 0;
}

/* ------------------------------------------------------------------ detail */

.sza-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--sza-border);
}

.sza-detail-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
}

.sza-detail-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sza-detail-status label {
  margin: 0;
  font-weight: normal;
}

.sza-detail-status .form-control {
  width: auto;
}

.sza-detail-head .sza-msg {
  flex: 1 0 100%;
  margin: 0;
}

.sza-section {
  padding: 10px 0;
  border-bottom: 1px solid var(--sza-border);
}

.sza-section:last-child {
  border-bottom: 0;
}

.sza-section h5 {
  margin: 4px 0 8px;
  font-weight: 600;
}

.sza-section h5 label {
  margin: 0;
  font-weight: inherit;
}

.sza-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--sza-soft);
  border-radius: var(--sza-radius);
  padding: 8px 10px;
}

.sza-masked {
  margin-top: 6px;
  border-left: 3px solid var(--sza-border);
}

.sza-masked-label {
  display: block;
  font-size: 12px;
}

.sza-pii-badge {
  font-weight: normal;
  font-size: 12px;
  margin-left: 6px;
}

.sza-facts {
  margin: 0;
}

.sza-facts > div {
  display: grid;
  grid-template-columns: minmax(110px, 30%) minmax(0, 1fr);
  gap: 8px;
  padding: 3px 0;
}

.sza-facts dt {
  font-weight: normal;
  color: var(--sza-muted);
}

.sza-facts dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.sza-facts-inline {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-size: 12px;
}

.sza-facts-inline > div {
  display: flex;
  gap: 6px;
  padding: 0;
  min-width: 0;
}

.sza-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sza-thumb {
  width: 132px;
  height: 92px;
  border: 1px solid var(--sza-border);
  border-radius: var(--sza-radius);
  background: var(--sza-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-align: center;
  font-size: 11px;
}

.sza-thumb-open {
  border: 0;
  padding: 0;
  background: none;
  width: 100%;
  height: 100%;
  cursor: zoom-in;
}

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

.sza-thumb-msg {
  padding: 4px;
}

.sza-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 8px;
}

.sza-table {
  font-size: 12px;
  margin-bottom: 0;
}

.sza-table td {
  vertical-align: top;
}

.sza-table td.sza-break {
  min-width: 140px;
}

.sza-raw {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 240px;
  overflow: auto;
  font-size: 11px;
  margin: 4px 0 0;
}

.sza-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.sza-counter {
  font-size: 12px;
  margin-right: auto;
}

.sza-reply-state {
  margin: 6px 0 0;
  font-size: 12px;
}

.sza-reply-seen {
  color: var(--sza-ok);
}

.sza-prompt-text {
  margin-top: 8px;
  resize: vertical;
}

/* ------------------------------------------------------------------ capture overlay (on <body>) */

.sza-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  cursor: zoom-out;
}

.sza-lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #ffffff;
  cursor: default;
}

.sza-lightbox-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #222222;
  font-size: 18px;
  cursor: pointer;
}

/* ------------------------------------------------------------------ phone */

@media (max-width: 767px) {
  .sza-card {
    padding: 10px;
  }

  .sza-filters .form-control,
  .sza-filters .sza-filter-search {
    flex: 1 1 100%;
  }

  .sza-facts > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .sza-detail-status {
    flex: 1 1 100%;
  }

  .sza-detail-status .form-control {
    flex: 1 1 auto;
  }

  .sza-thumb {
    width: calc(50% - 4px);
  }
}
