/* VIPER V1 — Atendimento design system and three-pane UX only.
   Scope is intentionally limited to #tab-atendimento. */

#tab-atendimento {
  --v1-font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --v1-bg: #f5f7fb;
  --v1-surface: #ffffff;
  --v1-surface-soft: #f8fafc;
  --v1-surface-subtle: #f1f5f9;
  --v1-text: #101828;
  --v1-muted: #667085;
  --v1-subtle: #98a2b3;
  --v1-line: #e4e7ec;
  --v1-line-strong: #d0d5dd;
  --v1-brand: #0d5f7a;
  --v1-brand-strong: #0b4f66;
  --v1-brand-soft: #e6f3f7;
  --v1-success: #16794f;
  --v1-success-soft: #e7f6ef;
  --v1-warning: #b54708;
  --v1-warning-soft: #fff4e5;
  --v1-danger: #b42318;
  --v1-danger-soft: #feeceb;
  --v1-neutral-soft: #f2f4f7;
  --v1-radius-xs: 6px;
  --v1-radius-sm: 8px;
  --v1-radius-md: 10px;
  --v1-radius-lg: 14px;
  --v1-shadow-focus: 0 0 0 3px rgba(13, 95, 122, .16);
  --v1-space-1: 4px;
  --v1-space-2: 8px;
  --v1-space-3: 12px;
  --v1-space-4: 16px;
  --v1-space-5: 20px;
  font-family: var(--v1-font);
  color: var(--v1-text);
  background: var(--v1-bg);
}

#tab-atendimento button,
#tab-atendimento input,
#tab-atendimento textarea,
#tab-atendimento select {
  font-family: var(--v1-font);
}

#tab-atendimento button {
  border-radius: var(--v1-radius-md);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 650;
  box-shadow: none;
}

#tab-atendimento button:hover {
  transform: none;
  box-shadow: none;
}

#tab-atendimento button.ghost {
  background: var(--v1-surface-soft);
  color: var(--v1-brand-strong);
  border: 1px solid var(--v1-line);
}

#tab-atendimento button.ghost:hover {
  background: var(--v1-brand-soft);
  border-color: #b8dce5;
}

#tab-atendimento button.ok {
  background: var(--v1-brand);
  color: #fff;
}

#tab-atendimento button:disabled {
  background: var(--v1-neutral-soft);
  color: var(--v1-subtle);
  border: 1px solid var(--v1-line);
  opacity: 1;
}

#tab-atendimento input,
#tab-atendimento textarea,
#tab-atendimento select {
  border: 1px solid var(--v1-line-strong);
  border-radius: var(--v1-radius-md);
  background: #fff;
  color: var(--v1-text);
  font-size: 14px;
  padding: 9px 10px;
  box-shadow: none;
}

#tab-atendimento input:focus,
#tab-atendimento textarea:focus,
#tab-atendimento select:focus,
#tab-atendimento button:focus-visible,
#tab-atendimento a:focus-visible {
  border-color: var(--v1-brand);
  outline: none;
  box-shadow: var(--v1-shadow-focus);
}

#tab-atendimento label {
  margin: 0 0 5px;
  color: var(--v1-muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

#tab-atendimento .empty {
  background: var(--v1-surface-soft);
  border: 1px dashed var(--v1-line-strong);
  border-radius: var(--v1-radius-lg);
  color: var(--v1-muted);
}

#tab-atendimento.tab-panel.active {
  background: var(--v1-bg);
  border-color: var(--v1-line);
  border-radius: 18px;
}

#tab-atendimento .atendimento-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 132px 150px 132px auto;
  gap: 8px;
  padding: 8px 10px;
  background: var(--v1-surface);
  border-bottom: 1px solid var(--v1-line);
}

#tab-atendimento .atendimento-filters input,
#tab-atendimento .atendimento-filters select,
#tab-atendimento .atendimento-filters button {
  min-height: 36px;
  font-size: 13px;
}

#tab-atendimento .service-workspace {
  grid-template-columns: 320px minmax(520px, 1.35fr) 336px;
  height: 100%;
  min-height: 0;
  background: var(--v1-bg);
  overflow: hidden;
}

#tab-atendimento .service-queue,
#tab-atendimento .service-conversation,
#tab-atendimento .context-rail {
  background: var(--v1-surface);
}

#tab-atendimento .service-queue {
  border-right: 1px solid var(--v1-line);
}

#tab-atendimento .service-queue-head {
  padding: 11px 12px 8px;
  background: var(--v1-surface);
  border-bottom: 1px solid var(--v1-line);
}

#tab-atendimento .service-queue-head h3 {
  color: var(--v1-text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

#tab-atendimento .service-queue-head p {
  color: var(--v1-muted);
  font-size: 12px;
  line-height: 1.35;
}

#tab-atendimento .service-list {
  padding: 6px 0;
  background: var(--v1-surface);
}

#tab-atendimento .ticket.queue-ticket {
  margin: 0;
  padding: 10px 12px;
  border: 0;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--v1-line);
  border-radius: 0;
  background: var(--v1-surface);
  box-shadow: none;
}

#tab-atendimento .ticket.queue-ticket:hover {
  background: var(--v1-surface-soft);
  transform: none;
  box-shadow: none;
}

#tab-atendimento .ticket.queue-ticket.selected {
  outline: none;
  border-left-color: var(--v1-brand);
  background: var(--v1-brand-soft);
}

#tab-atendimento .queue-ticket.needs-answer {
  background: var(--v1-surface);
  border-left-color: transparent;
}

#tab-atendimento .queue-ticket.needs-answer.selected {
  border-left-color: var(--v1-brand);
}

#tab-atendimento .queue-ticket.stale {
  box-shadow: none;
}

#tab-atendimento .queue-ticket .title {
  color: var(--v1-text);
  font-size: 14px;
  font-weight: 700;
}

#tab-atendimento .queue-ticket .last-line {
  margin-top: 4px;
  color: #475467;
  font-size: 13px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#tab-atendimento .queue-ticket .quick-meta {
  margin-top: 7px;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px;
}

#tab-atendimento .queue-ticket .queue-name,
#tab-atendimento .channel-pill,
#tab-atendimento .queue-ticket .age,
#tab-atendimento .pill {
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
}

#tab-atendimento .queue-ticket .queue-name,
#tab-atendimento .pill {
  background: var(--v1-neutral-soft);
  color: #344054;
}

#tab-atendimento .channel-pill {
  background: var(--v1-brand-soft);
  color: var(--v1-brand-strong);
}

#tab-atendimento .queue-ticket .age {
  background: transparent;
  color: var(--v1-muted);
  padding-left: 0;
  margin-left: auto;
}

#tab-atendimento .queue-ticket .answer-dot {
  width: 8px;
  height: 8px;
  background: var(--v1-danger);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, .10);
}

#tab-atendimento .detail.service-conversation {
  min-width: 0;
  background: var(--v1-bg);
}

#tab-atendimento .detail-layout {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--v1-bg);
}

#tab-atendimento .chat-shell {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--v1-surface);
  border-right: 1px solid var(--v1-line);
}

#tab-atendimento .chat-header {
  flex: 0 0 auto;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255,255,255,.98);
  border-bottom: 1px solid var(--v1-line);
}

#tab-atendimento .chat-name {
  color: var(--v1-text);
  font-size: 20px;
  font-weight: 720;
  letter-spacing: -.02em;
}

#tab-atendimento .chat-meta {
  margin-top: 2px;
  color: var(--v1-muted);
  font-size: 13px;
  line-height: 1.3;
}

#tab-atendimento .channel-line {
  color: var(--v1-muted);
}

#tab-atendimento .chat-actions {
  flex: 0 0 auto;
  align-items: center;
  flex-wrap: nowrap;
}

#tab-atendimento .chat-actions button {
  padding: 7px 10px;
  font-size: 12px;
  white-space: nowrap;
}

#tab-atendimento #activeWorkBanner {
  margin: 0;
  border-radius: 0;
  border-width: 0 0 1px;
  border-color: #f6d7a8;
  padding: 8px 14px !important;
  background: var(--v1-warning-soft);
}

#tab-atendimento #activeWorkBanner p,
#tab-atendimento #activeWorkBanner small {
  font-size: 12px;
  line-height: 1.25;
}

#tab-atendimento .messages {
  flex: 1 1 auto;
  min-height: 160px;
  max-height: none;
  overflow-y: auto;
  padding: 16px 18px;
  background: #f7f9fc;
  scrollbar-width: thin;
}

#tab-atendimento .msg {
  max-width: min(76%, 680px);
  margin: 8px 0;
  padding: 9px 11px;
  border: 1px solid var(--v1-line);
  border-radius: 14px;
  box-shadow: none;
  color: var(--v1-text);
  font-size: 14px;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

#tab-atendimento .msg small {
  margin-bottom: 4px;
  color: var(--v1-muted);
  font-size: 12px;
  font-weight: 500;
}

#tab-atendimento .msg.inbound {
  background: #fff;
  border-top-left-radius: 5px;
}

#tab-atendimento .msg.outbound {
  margin-left: auto;
  background: #e9f6ee;
  border-color: #cdebd9;
  border-top-right-radius: 5px;
}

#tab-atendimento .msg.internal-note {
  max-width: 88%;
  background: #fffbeb;
  border: 1px dashed #f0c36d;
  color: #533b04;
}

#tab-atendimento .link-button {
  color: var(--v1-brand);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}

#tab-atendimento .link-button:hover {
  text-decoration: underline;
}

#tab-atendimento .quoted-preview,
#tab-atendimento .selected-quote {
  border-left: 3px solid var(--v1-brand);
  background: var(--v1-surface-soft);
  border-radius: var(--v1-radius-md);
  color: #344054;
  font-size: 12px;
  padding: 7px 9px;
}

#tab-atendimento .quoted-selected {
  outline: 2px solid rgba(13, 95, 122, .22);
}

#tab-atendimento .msg-media img {
  max-width: min(320px, 100%);
  border-radius: var(--v1-radius-md);
}

#tab-atendimento .chat-composer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid var(--v1-line);
  position: relative;
  z-index: 0;
}

#tab-atendimento .composer-feedback {
  order: 0;
  flex: 1 0 100%;
  margin: 0;
  padding: 7px 9px;
  border-radius: var(--v1-radius-sm);
  font-size: 12px;
  font-weight: 600;
}

#tab-atendimento .selected-quote {
  order: 1;
  flex: 1 0 100%;
  margin: 0;
}

#tab-atendimento .composer-mode {
  order: 3;
  display: flex;
  flex-direction: row;
  gap: 6px;
  min-width: 0;
  align-self: auto;
  justify-content: flex-start;
}

#tab-atendimento .composer-mode button {
  padding: 7px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--v1-surface-soft);
  color: #344054;
  border: 1px solid var(--v1-line);
}

#tab-atendimento .composer-mode button.active {
  background: var(--v1-brand-soft);
  color: var(--v1-brand-strong);
  border-color: #b8dce5;
}

#tab-atendimento .chat-composer textarea {
  order: 2;
  flex: 1 0 100%;
  min-height: 48px;
  max-height: 88px;
  resize: vertical;
  line-height: 1.35;
}

#tab-atendimento .chat-composer > input[type="file"] {
  display: none !important;
}

#tab-atendimento .chat-composer > button {
  order: 4;
  flex: 0 0 auto;
}

#tab-atendimento .chat-composer #sendReplyButton {
  margin-left: auto;
  background: var(--v1-brand);
}

#tab-atendimento .quick-replies-placeholder {
  order: 4;
}

#tab-atendimento .context-rail.v1-rail {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  background: var(--v1-surface);
  border-left: 1px solid var(--v1-line);
}

#tab-atendimento .v1-person-head {
  padding: 2px 2px 12px;
  border-bottom: 1px solid var(--v1-line);
  margin-bottom: 12px;
}

#tab-atendimento .v1-person-head h3 {
  margin: 0;
  color: var(--v1-text);
  font-size: 18px;
  line-height: 1.2;
  font-weight: 720;
}

#tab-atendimento .v1-person-head p {
  margin: 4px 0 0;
  color: var(--v1-muted);
  font-size: 13px;
}

#tab-atendimento .v1-control-panel {
  display: grid;
  gap: 9px;
  padding: 12px;
  background: var(--v1-surface-soft);
  border: 1px solid var(--v1-line);
  border-radius: var(--v1-radius-lg);
  margin-bottom: 12px;
}

#tab-atendimento .v1-control-grid {
  display: grid;
  gap: 9px;
}

#tab-atendimento .v1-control-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

#tab-atendimento .v1-control-row label {
  margin: 0;
  color: var(--v1-muted);
  font-size: 12px;
  font-weight: 650;
}

#tab-atendimento .v1-control-row select,
#tab-atendimento .v1-control-row .v1-static-value {
  min-height: 34px;
}

#tab-atendimento .v1-static-value {
  display: flex;
  align-items: center;
  padding: 7px 9px;
  color: #344054;
  background: #fff;
  border: 1px solid var(--v1-line);
  border-radius: var(--v1-radius-md);
  font-size: 13px;
}

#tab-atendimento .v1-rail-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 10px;
  padding: 3px;
  background: var(--v1-neutral-soft);
  border-radius: 999px;
}

#tab-atendimento .v1-rail-tab {
  flex: 1 1 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--v1-muted);
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 650;
  text-align: center;
}

#tab-atendimento .v1-rail-tab.active {
  background: #fff;
  color: var(--v1-brand-strong);
  box-shadow: 0 1px 2px rgba(16,24,40,.06);
}

#tab-atendimento .rail-block,
#tab-atendimento details.rail-block {
  border: 1px solid var(--v1-line);
  border-radius: var(--v1-radius-lg);
  background: #fff;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: none;
}

#tab-atendimento .rail-block h4,
#tab-atendimento details.rail-block > summary {
  margin: 0 0 8px;
  color: var(--v1-text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

#tab-atendimento details.rail-block > summary {
  cursor: pointer;
  list-style: none;
  margin: 0;
}

#tab-atendimento details.rail-block[open] > summary {
  margin-bottom: 10px;
}

#tab-atendimento details.rail-block > summary::-webkit-details-marker {
  display: none;
}

#tab-atendimento .field-list {
  gap: 6px;
  font-size: 13px;
}

#tab-atendimento .field-list div {
  align-items: flex-start;
  border-bottom: 1px solid var(--v1-line);
  padding-bottom: 6px;
}

#tab-atendimento .field-list span {
  color: var(--v1-muted);
}

#tab-atendimento .field-list strong {
  color: var(--v1-text);
  font-weight: 650;
  text-align: right;
}

#tab-atendimento .decision-alert {
  border: 1px solid #fedf89;
  background: var(--v1-warning-soft);
  border-radius: var(--v1-radius-lg);
  padding: 10px 12px;
  color: #7a2e0e;
}

#tab-atendimento .decision-value {
  color: var(--v1-text);
  font-weight: 650;
}

#tab-atendimento .contact-card,
#tab-atendimento .task-card {
  border: 1px solid var(--v1-line);
  border-radius: var(--v1-radius-md);
  box-shadow: none;
}

@media (min-width: 1500px) {
  #tab-atendimento .service-workspace {
    grid-template-columns: 340px minmax(680px, 1.45fr) 360px;
  }
}

@media (max-width: 1366px) {
  #tab-atendimento .service-workspace {
    grid-template-columns: 300px minmax(450px, 1fr) 310px;
  }
  #tab-atendimento .chat-name { font-size: 18px; }
  #tab-atendimento .messages { padding: 14px; }
}

@media (max-width: 1280px) {
  #tab-atendimento .service-workspace {
    grid-template-columns: 292px minmax(420px, 1fr) 300px;
  }
  #tab-atendimento .atendimento-filters {
    grid-template-columns: minmax(180px, 1fr) 120px 132px 120px auto;
  }
  #tab-atendimento .chat-header { padding: 8px 12px; }
  #tab-atendimento .messages { min-height: 150px; padding: 12px; }
  #tab-atendimento .context-rail.v1-rail { padding: 10px; }
}

@media (max-height: 650px) and (min-width: 1161px) {
  #tab-atendimento .atendimento-filters { padding-top: 6px; padding-bottom: 6px; }
  #tab-atendimento .service-queue-head { padding: 8px 10px 6px; }
  #tab-atendimento .service-queue-head p { display: none; }
  #tab-atendimento .chat-header { padding: 7px 12px; }
  #tab-atendimento .chat-name { font-size: 17px; }
  #tab-atendimento .chat-meta { font-size: 12px; }
  #tab-atendimento .messages { min-height: 180px; padding: 10px 12px; }
  #tab-atendimento .chat-composer { padding: 8px 10px; gap: 6px; }
  #tab-atendimento .chat-composer textarea { min-height: 42px; max-height: 70px; }
  #tab-atendimento .composer-mode button,
  #tab-atendimento .chat-composer > button { padding: 6px 8px; font-size: 12px; }
  #tab-atendimento .v1-person-head { padding-bottom: 8px; margin-bottom: 8px; }
  #tab-atendimento .v1-control-panel { padding: 9px; gap: 7px; }
  #tab-atendimento .rail-block,
  #tab-atendimento details.rail-block { padding: 10px; margin-bottom: 8px; }
}

@media (max-width: 1160px) {
  #tab-atendimento.tab-panel.active { overflow: auto; }
  #tab-atendimento .service-workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }
  #tab-atendimento .service-queue {
    max-height: 280px;
    border-right: 0;
    border-bottom: 1px solid var(--v1-line);
  }
  #tab-atendimento .context-rail.v1-rail {
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--v1-line);
  }
}


/* Viper V1 refinement: compact ops controls, real tabs, smaller bubbles/media */
#tab-atendimento .v1-control-panel.compact {
  padding: 9px 10px;
  gap: 7px;
  margin-bottom: 10px;
}
#tab-atendimento .v1-control-panel.compact h4 {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--v1-text);
}
#tab-atendimento .v1-control-panel.compact .v1-control-grid { gap: 6px; }
#tab-atendimento .v1-control-panel.compact .v1-control-row {
  grid-template-columns: 86px minmax(0,1fr);
  gap: 7px;
}
#tab-atendimento .v1-control-panel.compact select { min-height: 30px; padding: 5px 8px; font-size: 13px; }
#tab-atendimento .v1-rail-tabs button.v1-rail-tab {
  cursor: pointer;
  border: 0;
  box-shadow: none;
}
#tab-atendimento .msg { max-width: min(72%, 560px); }
#tab-atendimento .msg.internal-note { max-width: min(78%, 620px); }
#tab-atendimento .msg small .link-button,
#tab-atendimento .link-button.reply-link {
  opacity: .72;
  font-size: 11px;
  padding: 1px 3px;
}
#tab-atendimento .msg:hover small .link-button,
#tab-atendimento .link-button:focus-visible { opacity: 1; }
#tab-atendimento .msg-media img,
#tab-atendimento .msg-media video {
  max-width: min(220px, 100%);
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--v1-radius-md);
}
#tab-atendimento .chat-composer textarea { min-height: 44px; }
#tab-atendimento .composer-mode button { padding: 6px 10px; }
@media (max-width: 1280px) {
  #tab-atendimento .msg { max-width: 74%; }
  #tab-atendimento .msg-media img,
  #tab-atendimento .msg-media video { max-width: min(190px, 100%); max-height: 150px; }
}


/* Identidade 360 + financeiro seguro + polimento final */
#tab-atendimento .unlinked-contact { border-style:dashed; background:#fffaf1; }
#tab-atendimento .student-link-card { border-left:4px solid var(--brand); }
#tab-atendimento .academic-simple .student-name { display:block; font-size:15px; margin-bottom:3px; }
#tab-atendimento .v1-student-enrollment { display:grid; grid-template-columns:1fr auto; gap:4px 10px; padding:9px 0; border-bottom:1px solid #f0e6d9; font-size:13px; }
#tab-atendimento .v1-student-enrollment strong { grid-column:1 / -1; }
#tab-atendimento .v1-student-enrollment .pill { justify-self:start; padding:2px 8px; font-size:11px; }
#tab-atendimento .task-card.compact-next { padding:10px; margin-bottom:0; }
#tab-atendimento .task-card.compact-next strong { font-size:13px; }
#tab-atendimento .task-card.compact-next small { display:block; margin-top:4px; }
#tab-atendimento .finance-safe strong { color:#123f50; }
#tab-atendimento .finance-safe small { line-height:1.4; }
