/**
 * Repario — Ticket Detail Modal Styles
 *
 * Source: stitch-export/ticket_detail_modal
 * Scoped in .repario-admin-wrap
 * Depends on: tokens.css
 *
 * @package Repario_SaaS
 */

/* ═══════════════════════════════════════════════════════════════════════════
   OVERLAY
   ═══════════════════════════════════════════════════════════════════════════ */

.rep-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--rep-z-modal-backdrop);
  background: var(--rep-bg-overlay);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--rep-space-4);
  overflow-y: auto;
  animation: rep-modal-overlay-in var(--rep-transition-normal) ease forwards;
}

.rep-modal-overlay--closing {
  animation: rep-modal-overlay-out var(--rep-transition-normal) ease forwards;
}

.rep-modal-overlay[hidden] {
  display: none;
}

@keyframes rep-modal-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes rep-modal-overlay-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL CONTAINER
   ═══════════════════════════════════════════════════════════════════════════ */

.rep-modal {
  width: 100%;
  max-width: 87.5rem; /* 1400px */
  height: 95vh;
  background: var(--rep-card-bg);
  border-radius: var(--rep-radius-xl);
  box-shadow: var(--rep-shadow-2xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--rep-border-default);
  animation: rep-modal-in var(--rep-transition-normal) ease forwards;
}

.rep-modal-overlay--closing .rep-modal {
  animation: rep-modal-out var(--rep-transition-normal) ease forwards;
}

@keyframes rep-modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes rep-modal-out {
  from { opacity: 1; transform: scale(1) translateY(0); }
  to   { opacity: 0; transform: scale(0.96) translateY(8px); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════════════════ */

.rep-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--rep-space-4) var(--rep-space-6);
  border-bottom: 1px solid var(--rep-border-default);
  background: var(--rep-sidebar-bg);
  flex-shrink: 0;
}

.rep-modal__header-left {
  display: flex;
  align-items: center;
  gap: var(--rep-space-4);
}

.rep-modal__header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--rep-radius-lg);
  background: var(--rep-kpi-icon-primary-bg);
  color: var(--rep-color-primary-base);
  flex-shrink: 0;
}

.rep-modal__header-icon .material-symbols-outlined {
  font-size: 24px;
}

.rep-modal__header-title-row {
  display: flex;
  align-items: center;
  gap: var(--rep-space-3);
}

.rep-modal__title {
  font-size: var(--rep-font-size-xl);
  font-weight: var(--rep-font-weight-bold);
  color: var(--rep-text-primary);
  margin: 0;
  line-height: var(--rep-line-height-tight);
}

.rep-modal__subtitle {
  font-size: var(--rep-font-size-sm);
  color: var(--rep-text-muted);
  margin: var(--rep-space-0-5) 0 0;
}

/* Status Badge */
.rep-modal__status-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--rep-space-1) var(--rep-space-2);
  border-radius: var(--rep-radius-md);
  font-size: var(--rep-font-size-xs);
  font-weight: var(--rep-font-weight-medium);
}

.rep-modal__status-badge--pending      { background: color-mix(in srgb, var(--rep-color-status-pending) 10%, transparent); color: var(--rep-color-status-pending); border: 1px solid color-mix(in srgb, var(--rep-color-status-pending) 20%, transparent); }
.rep-modal__status-badge--diagnosing   { background: var(--rep-kpi-icon-purple-bg); color: var(--rep-badge-purple-text); border: 1px solid color-mix(in srgb, var(--rep-badge-purple-text) 20%, transparent); }
.rep-modal__status-badge--in_progress  { background: var(--rep-color-status-in-progress-bg);  color: var(--rep-badge-yellow-text); border: 1px solid color-mix(in srgb, var(--rep-badge-yellow-text) 20%, transparent); }
.rep-modal__status-badge--in_repair    { background: var(--rep-badge-orange-bg); color: var(--rep-badge-orange-text); border: 1px solid color-mix(in srgb, var(--rep-badge-orange-text) 20%, transparent); }
.rep-modal__status-badge--part_order   { background: var(--rep-kpi-icon-purple-bg); color: var(--rep-badge-purple-text); border: 1px solid color-mix(in srgb, var(--rep-badge-purple-text) 20%, transparent); }
.rep-modal__status-badge--ready_pickup { background: color-mix(in srgb, var(--rep-color-status-ready) 10%, transparent); color: var(--rep-color-status-ready); border: 1px solid color-mix(in srgb, var(--rep-color-status-ready) 20%, transparent); }
.rep-modal__status-badge--completed    { background: color-mix(in srgb, var(--rep-color-semantic-success-base) 10%, transparent); color: var(--rep-color-status-ready); border: 1px solid color-mix(in srgb, var(--rep-color-semantic-success-base) 20%, transparent); }
.rep-modal__status-badge--cancelled    { background: color-mix(in srgb, var(--rep-text-secondary) 10%, transparent); color: var(--rep-text-secondary); border: 1px solid color-mix(in srgb, var(--rep-text-secondary) 20%, transparent); }

/* Header Actions */
.rep-modal__header-actions {
  display: flex;
  align-items: center;
  gap: var(--rep-space-3);
}

.rep-modal__header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--rep-radius-lg);
  background: none;
  border: none;
  color: var(--rep-text-muted);
  cursor: pointer;
  transition: all var(--rep-transition-fast);
}

.rep-modal__header-btn:hover {
  background: var(--rep-bg-hover);
  color: var(--rep-text-primary);
}

.rep-modal__header-divider {
  width: 1px;
  height: 1.5rem;
  background: var(--rep-border-default);
  margin: 0 var(--rep-space-1);
}

.rep-modal__btn {
  display: inline-flex;
  align-items: center;
  gap: var(--rep-space-2);
  padding: 0 var(--rep-space-5);
  height: 2.5rem;
  border-radius: var(--rep-radius-lg);
  font-size: var(--rep-font-size-sm);
  font-weight: var(--rep-font-weight-bold);
  cursor: pointer;
  transition: all var(--rep-transition-fast);
  border: none;
}

.rep-modal__btn .material-symbols-outlined {
  font-size: 18px;
}

.rep-modal__btn--ghost {
  background: none;
  border: 1px solid var(--rep-border-default);
  color: var(--rep-text-primary);
}

.rep-modal__btn--ghost:hover {
  background: var(--rep-bg-hover);
}

.rep-modal__btn--primary {
  background: var(--rep-color-primary-base);
  color: var(--rep-text-inverse);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--rep-color-primary-base) 25%, transparent);
}

.rep-modal__btn--primary:hover {
  background: var(--rep-color-primary-hover);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BODY (GRID)
   ═══════════════════════════════════════════════════════════════════════════ */

.rep-modal__body {
  flex: 1;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
  height: 100%;
}

@media (min-width: 1024px) {
  .rep-modal__body {
    grid-template-columns: 2fr 1fr;
  }
}

/* ── Left Panel ── */

.rep-modal__left {
  overflow-y: auto;
  padding: var(--rep-space-6) var(--rep-space-8);
  display: flex;
  flex-direction: column;
  gap: var(--rep-space-8);
}

.rep-modal__left::-webkit-scrollbar {
  width: 6px;
}

.rep-modal__left::-webkit-scrollbar-track {
  background: transparent;
}

.rep-modal__left::-webkit-scrollbar-thumb {
  background: var(--rep-scrollbar-thumb);
  border-radius: 20px;
}

/* ── Right Panel ── */

.rep-modal__right {
  background: var(--rep-sidebar-bg);
  border-left: 1px solid var(--rep-border-default);
  padding: var(--rep-space-6) var(--rep-space-8);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SECTIONS (Left Panel)
   ═══════════════════════════════════════════════════════════════════════════ */

.rep-modal__section {
  display: flex;
  flex-direction: column;
}

.rep-modal__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--rep-space-4);
}

.rep-modal__section-title {
  display: flex;
  align-items: center;
  gap: var(--rep-space-2);
  font-size: var(--rep-font-size-lg);
  font-weight: var(--rep-font-weight-bold);
  color: var(--rep-text-primary);
  margin: 0 0 var(--rep-space-4);
}

.rep-modal__section-header .rep-modal__section-title {
  margin-bottom: 0;
}

.rep-modal__section-title .material-symbols-outlined {
  color: var(--rep-color-primary-base);
}

.rep-modal__section-action {
  display: inline-flex;
  align-items: center;
  gap: var(--rep-space-1);
  background: none;
  border: none;
  color: var(--rep-color-primary-base);
  font-size: var(--rep-font-size-xs);
  font-weight: var(--rep-font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color var(--rep-transition-fast);
}

.rep-modal__section-action:hover {
  color: var(--rep-color-primary-hover);
}

.rep-modal__section-action .material-symbols-outlined {
  font-size: 14px;
}

/* ── Description ── */

.rep-modal__section-card {
  padding: var(--rep-space-5);
  border-radius: var(--rep-radius-xl);
  background: var(--rep-sidebar-bg);
  border: 1px solid var(--rep-border-default);
}

.rep-modal__description {
  font-size: var(--rep-font-size-base);
  line-height: var(--rep-line-height-relaxed);
  color: var(--rep-text-secondary);
  margin: 0;
}

/* ── Details Grid ── */

.rep-modal__details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--rep-space-4);
}

.rep-modal__detail-card {
  display: flex;
  flex-direction: column;
  gap: var(--rep-space-1);
  padding: var(--rep-space-4);
  border-radius: var(--rep-radius-xl);
  background: var(--rep-sidebar-bg);
  border: 1px solid var(--rep-border-default);
}

.rep-modal__detail-label {
  font-size: var(--rep-font-size-xs);
  font-weight: var(--rep-font-weight-semibold);
  color: var(--rep-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rep-modal__detail-value {
  font-weight: var(--rep-font-weight-medium);
  color: var(--rep-text-primary);
}

.rep-modal__detail-value--mono {
  font-family: var(--rep-font-family-mono);
}

.rep-modal__detail-client {
  display: flex;
  align-items: center;
  gap: var(--rep-space-2);
}

.rep-modal__detail-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--rep-radius-full);
  background: color-mix(in srgb, var(--rep-color-primary-base) 20%, transparent);
  color: var(--rep-color-primary-base);
  font-size: var(--rep-font-size-xs);
  font-weight: var(--rep-font-weight-bold);
}

.rep-modal__detail-contact {
  display: flex;
  flex-direction: column;
}

.rep-modal__detail-phone {
  font-size: var(--rep-font-size-sm);
  color: var(--rep-text-muted);
}

/* ── Parts Table ── */

.rep-modal__table-wrap {
  border: 1px solid var(--rep-border-default);
  border-radius: var(--rep-radius-xl);
  overflow: hidden;
}

.rep-modal__table {
  width: 100%;
  text-align: left;
  font-size: var(--rep-font-size-sm);
  border-collapse: collapse;
}

.rep-modal__table thead {
  background: var(--rep-sidebar-bg);
  border-bottom: 1px solid var(--rep-border-default);
}

.rep-modal__table th {
  padding: var(--rep-space-3) var(--rep-space-5);
  color: var(--rep-text-muted);
  font-weight: var(--rep-font-weight-semibold);
  font-size: var(--rep-font-size-sm);
}

.rep-modal__table tbody {
  background: var(--rep-card-bg);
}

.rep-modal__table-row {
  border-bottom: 1px solid var(--rep-border-default);
  transition: background var(--rep-transition-fast);
}

.rep-modal__table-row:hover {
  background: var(--rep-bg-hover);
}

.rep-modal__table td {
  padding: var(--rep-space-3) var(--rep-space-5);
}

.rep-modal__table-center { text-align: center; }
.rep-modal__table-right  { text-align: right; }

.rep-modal__table-desc {
  font-weight: var(--rep-font-weight-medium);
  color: var(--rep-text-primary);
}

.rep-modal__table-bold {
  font-weight: var(--rep-font-weight-bold);
  color: var(--rep-text-primary);
}

.rep-modal__table-action-col {
  width: 2.5rem;
}

.rep-modal__table-delete {
  background: none;
  border: none;
  color: var(--rep-text-muted);
  cursor: pointer;
  opacity: 0;
  transition: all var(--rep-transition-fast);
}

.rep-modal__table-row:hover .rep-modal__table-delete {
  opacity: 1;
}

.rep-modal__table-delete:hover {
  color: var(--rep-color-semantic-error-base);
}

.rep-modal__table-delete .material-symbols-outlined {
  font-size: 18px;
}

.rep-modal__table tfoot {
  background: var(--rep-sidebar-bg);
  border-top: 1px solid var(--rep-border-default);
}

.rep-modal__table-subtotal {
  font-size: var(--rep-font-size-lg);
  font-weight: var(--rep-font-weight-bold);
  color: var(--rep-text-primary);
}

/* ── Gallery ── */

.rep-modal__gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--rep-space-4);
}

.rep-modal__gallery-placeholder {
  aspect-ratio: 1;
  border-radius: var(--rep-radius-xl);
  background: var(--rep-sidebar-bg);
  border: 2px dashed var(--rep-border-default);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--rep-space-1);
  color: var(--rep-text-muted);
  cursor: pointer;
  transition: all var(--rep-transition-fast);
}

.rep-modal__gallery-placeholder:hover {
  color: var(--rep-color-primary-base);
  border-color: var(--rep-color-primary-base);
  background: color-mix(in srgb, var(--rep-color-primary-base) 5%, transparent);
}

.rep-modal__gallery-placeholder .material-symbols-outlined {
  font-size: 2rem;
}

.rep-modal__gallery-placeholder span:last-child {
  font-size: var(--rep-font-size-xs);
  font-weight: var(--rep-font-weight-semibold);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RIGHT PANEL
   ═══════════════════════════════════════════════════════════════════════════ */

.rep-modal__panel-title {
  font-size: var(--rep-font-size-sm);
  font-weight: var(--rep-font-weight-bold);
  text-transform: uppercase;
  color: var(--rep-text-muted);
  letter-spacing: 0.04em;
  margin: 0 0 var(--rep-space-4);
}

/* ── Management Fields ── */

.rep-modal__management {
  margin-bottom: var(--rep-space-8);
}

.rep-modal__fields {
  display: flex;
  flex-direction: column;
  gap: var(--rep-space-4);
}

.rep-modal__field {
  display: flex;
  flex-direction: column;
  gap: var(--rep-space-1-5);
}

.rep-modal__field-label {
  font-size: var(--rep-font-size-xs);
  font-weight: var(--rep-font-weight-semibold);
  color: var(--rep-text-muted);
}

.rep-modal__input {
  width: 100%;
  padding: var(--rep-space-2-5) var(--rep-space-3);
  background: var(--rep-bg-surface);
  border: 1px solid var(--rep-border-default);
  border-radius: var(--rep-radius-lg);
  color: var(--rep-text-primary);
  font-size: var(--rep-font-size-sm);
  font-family: var(--rep-font-family-base);
  transition: border-color var(--rep-transition-fast);
  box-sizing: border-box;
}

.rep-modal__input::placeholder {
  color: var(--rep-text-muted);
}

.rep-modal__input:focus {
  outline: none;
  border-color: var(--rep-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--rep-accent) 20%, transparent);
}

.rep-modal__select-wrap {
  position: relative;
}

.rep-modal__select {
  width: 100%;
  padding: var(--rep-space-2-5);
  padding-right: var(--rep-space-8);
  background: var(--rep-card-bg);
  border: 1px solid var(--rep-border-default);
  border-radius: var(--rep-radius-lg);
  color: var(--rep-text-primary);
  font-size: var(--rep-font-size-sm);
  font-family: var(--rep-font-family-base);
  appearance: none;
  cursor: pointer;
  transition: border-color var(--rep-transition-fast);
}

.rep-modal__select:focus {
  outline: none;
  border-color: var(--rep-color-primary-base);
  box-shadow: var(--rep-shadow-ring);
}

.rep-modal__select-arrow {
  position: absolute;
  right: var(--rep-space-2);
  top: 50%;
  transform: translateY(-50%);
  color: var(--rep-text-muted);
  pointer-events: none;
  font-size: 18px;
}

/* ── Technician Picker ── */

.rep-modal__tech-picker {
  display: flex;
  align-items: center;
  gap: var(--rep-space-3);
  padding: var(--rep-space-2);
  background: var(--rep-card-bg);
  border: 1px solid var(--rep-border-default);
  border-radius: var(--rep-radius-lg);
  cursor: pointer;
  transition: border-color var(--rep-transition-fast);
}

.rep-modal__tech-picker:hover {
  border-color: color-mix(in srgb, var(--rep-color-primary-base) 50%, transparent);
}

.rep-modal__tech-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--rep-radius-full);
  background: var(--rep-color-primary-base);
  color: var(--rep-text-inverse);
  font-size: var(--rep-font-size-xs);
  font-weight: var(--rep-font-weight-bold);
  flex-shrink: 0;
}

.rep-modal__tech-info {
  flex: 1;
}

.rep-modal__tech-name {
  font-size: var(--rep-font-size-sm);
  font-weight: var(--rep-font-weight-bold);
  color: var(--rep-text-primary);
  margin: 0;
}

.rep-modal__tech-level {
  font-size: var(--rep-font-size-xs);
  color: var(--rep-text-muted);
  margin: 0;
}

.rep-modal__tech-edit {
  color: var(--rep-text-muted);
  font-size: 18px;
}

/* ── Date Display ── */

.rep-modal__date-display {
  display: flex;
  align-items: center;
  gap: var(--rep-space-2);
  padding: var(--rep-space-2-5);
  background: var(--rep-card-bg);
  border: 1px solid var(--rep-border-default);
  border-radius: var(--rep-radius-lg);
  font-size: var(--rep-font-size-sm);
  font-weight: var(--rep-font-weight-medium);
  color: var(--rep-text-primary);
}

.rep-modal__date-display .material-symbols-outlined {
  color: var(--rep-color-primary-base);
  font-size: 18px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TIMELINE
   ═══════════════════════════════════════════════════════════════════════════ */

.rep-modal__timeline-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rep-modal__timeline {
  flex: 1;
  overflow-y: auto;
  padding-right: var(--rep-space-2);
  padding-left: var(--rep-space-4);
  border-left: 1px solid var(--rep-border-default);
  display: flex;
  flex-direction: column;
  gap: var(--rep-space-6);
}

.rep-modal__timeline::-webkit-scrollbar {
  width: 6px;
}

.rep-modal__timeline::-webkit-scrollbar-thumb {
  background: var(--rep-scrollbar-thumb);
  border-radius: 20px;
}

.rep-modal__timeline-item {
  position: relative;
}

.rep-modal__timeline-dot {
  position: absolute;
  left: calc(-1 * var(--rep-space-4) - 5px);
  top: var(--rep-space-1);
  width: 10px;
  height: 10px;
  border-radius: var(--rep-radius-full);
  background: var(--rep-text-muted);
  border: 4px solid var(--rep-sidebar-bg);
}

.rep-modal__timeline-dot--active {
  background: var(--rep-color-primary-base);
}

.rep-modal__timeline-content {
  display: flex;
  flex-direction: column;
  gap: var(--rep-space-1);
}

.rep-modal__timeline-text {
  font-size: var(--rep-font-size-sm);
  font-weight: var(--rep-font-weight-medium);
  color: var(--rep-text-primary);
  margin: 0;
}

.rep-modal__timeline-text strong {
  color: var(--rep-color-primary-base);
}

.rep-modal__timeline-date {
  font-size: var(--rep-font-size-xs);
  color: var(--rep-text-muted);
  margin: 0;
}

.rep-modal__timeline-ref {
  margin-top: var(--rep-space-1);
  padding: var(--rep-space-2);
  background: var(--rep-card-bg);
  border: 1px solid var(--rep-border-default);
  border-radius: var(--rep-radius-sm);
  font-family: var(--rep-font-family-mono);
  font-size: var(--rep-font-size-xs);
  color: var(--rep-text-muted);
}

.rep-modal__timeline-note {
  font-size: var(--rep-font-size-xs);
  color: var(--rep-text-muted);
  font-style: italic;
  margin: var(--rep-space-1) 0 0;
}

/* ── Note Input ── */

.rep-modal__note-input-wrap {
  position: relative;
  margin-top: var(--rep-space-4);
  padding-top: var(--rep-space-4);
  border-top: 1px solid var(--rep-border-default);
}

.rep-modal__note-input {
  width: 100%;
  padding: var(--rep-space-2-5) var(--rep-space-10) var(--rep-space-2-5) var(--rep-space-3);
  background: var(--rep-card-bg);
  border: 1px solid var(--rep-border-default);
  border-radius: var(--rep-radius-lg);
  font-size: var(--rep-font-size-sm);
  font-family: var(--rep-font-family-base);
  color: var(--rep-text-primary);
  transition: border-color var(--rep-transition-fast);
  box-sizing: border-box;
}

.rep-modal__note-input::placeholder {
  color: var(--rep-text-muted);
}

.rep-modal__note-input:focus {
  outline: none;
  border-color: var(--rep-color-primary-base);
  box-shadow: var(--rep-shadow-ring);
}

.rep-modal__note-send {
  position: absolute;
  right: var(--rep-space-2);
  top: 50%;
  transform: translateY(-25%);
  background: none;
  border: none;
  color: var(--rep-color-primary-base);
  cursor: pointer;
  transition: color var(--rep-transition-fast);
}

.rep-modal__note-send:hover {
  color: var(--rep-color-primary-hover);
}

.rep-modal__note-send .material-symbols-outlined {
  font-size: 20px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .rep-modal {
    height: auto;
    max-height: 95vh;
  }

  .rep-modal__details-grid {
    grid-template-columns: 1fr;
  }

  .rep-modal__gallery {
    grid-template-columns: repeat(2, 1fr);
  }

  .rep-modal__header-btn {
    display: none;
  }
}

@media (max-width: 768px) {
  .rep-modal {
    border-radius: var(--rep-radius-lg);
  }

  .rep-modal__left {
    padding: var(--rep-space-4);
  }

  .rep-modal__right {
    padding: var(--rep-space-4);
  }
}
