:root {
  /* #ff811b é a cor pedida — o destaque vivo (topo, foco, bordas, hover).
     #ff811b puro com texto branco por cima tem contraste baixo (~2.6:1,
     abaixo do mínimo de acessibilidade), então --brand-dark/--brand-darker
     são a mesma cor mais escurecida, usadas onde há texto claro em cima. */
  --brand: #ff811b;
  --brand-dark: #b8530a;
  --brand-darker: #7a3607;
  --brand-light: #fff1e2;
  --brand-light-border: #ffd6ac;
  --brand-text-on: #331a04;
  --bg: #faf7f5;
  --card-bg: #ffffff;
  --text: #1a1f2b;
  --muted: #736a62;
  --border: #ece4dc;
  --danger: #d92d20;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--brand-darker), var(--brand-text-on));
  box-shadow: 2px 0 14px rgba(255, 129, 27, 0.2);
}

.sidebar-brand {
  padding: 22px 24px;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.sidebar-brand span {
  display: block;
  margin-top: 2px;
  font-weight: 400;
  font-size: 0.8rem;
  opacity: 0.75;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-link .icon {
  width: 20px;
  text-align: center;
  font-size: 1.05rem;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-link.active {
  background: rgba(255, 129, 27, 0.22);
  color: #fff;
  font-weight: 600;
  border-left-color: var(--brand);
}

.sidebar-submenu {
  display: flex;
  flex-direction: column;
  padding-bottom: 6px;
}

.sidebar-sublink {
  padding: 8px 24px 8px 52px;
  color: rgba(255, 255, 255, 0.62);
  text-decoration: none;
  font-size: 0.84rem;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-sublink:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-sublink.active {
  background: rgba(255, 129, 27, 0.16);
  color: #fff;
  font-weight: 600;
  border-left-color: var(--brand);
}

.main-content {
  flex: 1;
  min-width: 0;
}

.container {
  max-width: 1000px;
  padding: 40px 32px 80px;
}

.placeholder-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 64px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.placeholder-icon {
  font-size: 2.5rem;
}

@media (max-width: 720px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    box-shadow: 0 2px 14px rgba(255, 129, 27, 0.2);
  }

  .sidebar-brand {
    border-bottom: none;
    padding: 14px 16px;
    white-space: nowrap;
  }

  .sidebar-brand span {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 0;
  }

  .sidebar-link {
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 14px 16px;
    white-space: nowrap;
  }

  .sidebar-link.active {
    border-left-color: transparent;
    border-bottom-color: var(--brand);
  }
}

h1 {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 28px;
}

.filter-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

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

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.field input[type="date"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  min-width: 170px;
}

.field select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  min-width: 170px;
  max-width: 220px;
  background: #fff;
  color: var(--text);
}

.field input[type="date"]:focus,
.field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 129, 27, 0.2);
}

.source-toggle {
  display: flex;
  gap: 14px;
  height: 42px;
  align-items: center;
}

.radio-option {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 400 !important;
  color: var(--text) !important;
  text-transform: none !important;
  cursor: pointer;
  white-space: nowrap;
}

.radio-option input {
  cursor: pointer;
  accent-color: var(--brand);
  width: 16px;
  height: 16px;
}

.sync-info {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.sync-info.sync-error {
  color: var(--danger);
}

#submit-btn {
  background: var(--brand);
  color: var(--brand-text-on);
  border: none;
  padding: 11px 24px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(122, 54, 7, 0.25);
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

#submit-btn:hover {
  background: var(--brand-dark);
  color: #fff;
  box-shadow: 0 2px 10px rgba(184, 83, 10, 0.4);
}

#submit-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 129, 27, 0.35);
}

#submit-btn:disabled {
  background: var(--brand-light-border);
  color: var(--muted);
  box-shadow: none;
  cursor: wait;
}

.result-area {
  margin-top: 32px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: stretch;
}

.result-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}

.result-label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.result-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--brand-dark);
}

.result-breakdown {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-msg {
  margin-top: 20px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #fef3f2;
  color: var(--danger);
  border: 1px solid #fda29b;
  font-size: 0.9rem;
}

.status-msg.info {
  background: var(--brand-light);
  color: var(--brand-dark);
  border-color: var(--brand-light-border);
}

.tickets-section {
  margin-top: 28px;
}

.tickets-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.tickets-header h2 {
  font-size: 1.1rem;
  margin: 0;
}

.truncated-note {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand-dark);
  background: var(--brand-light);
  border: 1px solid var(--brand-light-border);
  padding: 3px 10px;
  border-radius: 999px;
}

.tickets-scroll {
  max-height: 480px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg);
}

.tickets-scroll::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.tickets-scroll::-webkit-scrollbar-track {
  background: var(--brand-light);
}

.tickets-scroll::-webkit-scrollbar-thumb {
  background: var(--brand);
  border-radius: 8px;
}

.tickets-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.tickets-table thead th {
  position: sticky;
  top: 0;
  background: var(--brand-light);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--brand);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--brand-dark);
  white-space: nowrap;
  z-index: 1;
}

.tickets-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.tickets-table tbody tr:last-child td {
  border-bottom: none;
}

.tickets-table tbody tr:hover {
  background: var(--brand-light);
}

.tickets-table .subject-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tickets-empty {
  padding: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-msg.success {
  background: #eaf7ea;
  color: #1e7a34;
  border: 1px solid #b7e3bd;
}

.origins-form {
  margin-top: 8px;
}

.ramais-update-form {
  margin: 16px 0 20px;
}

.secondary-btn {
  display: inline-block;
  background: #fff;
  color: var(--brand-dark);
  border: 1px solid var(--brand-light-border);
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.secondary-btn:hover {
  background: var(--brand-light);
  border-color: var(--brand);
}

.secondary-btn.small-btn {
  padding: 5px 12px;
  font-size: 0.82rem;
}

.inline-form {
  display: inline-block;
  margin: 0;
}

.status-msg-inline {
  color: var(--danger);
  font-size: 0.8rem;
  margin-left: 6px;
  cursor: help;
}

.chat-conversation {
  display: flex;
  flex-direction: column;
  gap: 6px;
  word-break: break-word;
  background: #efe9e1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  max-height: 55vh;
  overflow-y: auto;
}

.chat-bubble-row {
  display: flex;
}

.chat-bubble-row-agent {
  justify-content: flex-end;
}

.chat-bubble-row-client,
.chat-bubble-row-bot {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 78%;
  padding: 7px 11px;
  border-radius: 10px;
  font-size: 0.86rem;
  line-height: 1.45;
  box-shadow: 0 1px 1px rgba(26, 31, 43, 0.08);
}

.chat-bubble-client {
  background: #ffffff;
  color: var(--text);
  border-top-left-radius: 2px;
}

.chat-bubble-agent {
  background: var(--brand-light);
  color: var(--brand-text-on);
  border-top-right-radius: 2px;
}

.chat-bubble-bot {
  background: #eef0f2;
  color: var(--muted);
  border: 1px solid #dfe3e7;
  border-top-left-radius: 2px;
}

.chat-bubble-author {
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.chat-bubble-client .chat-bubble-author {
  color: #2f6f66;
}

.chat-bubble-agent .chat-bubble-author {
  color: var(--brand-dark);
  text-align: right;
}

.chat-bubble-bot .chat-bubble-author {
  color: var(--muted);
  font-weight: 600;
}

.chat-bubble-text {
  white-space: pre-wrap;
}

.chat-attachment {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-attachment-size {
  font-weight: 400;
  opacity: 0.75;
}

.chat-bubble-time {
  font-size: 0.68rem;
  color: var(--muted);
  text-align: right;
  margin-top: 3px;
}

.chat-bubble-agent .chat-bubble-time {
  color: var(--brand-dark);
  opacity: 0.75;
}

.chat-bubble-system {
  align-self: center;
  background: rgba(26, 31, 43, 0.06);
  color: var(--muted);
  font-size: 0.72rem;
  padding: 3px 12px;
  border-radius: 10px;
  margin: 2px 0;
  text-align: center;
}

.origins-scroll {
  max-height: 560px;
  margin-bottom: 20px;
}

.origins-form select,
.origins-form input[type="text"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  min-width: 200px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}

.origins-form select:focus,
.origins-form input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 129, 27, 0.2);
}

.origins-form input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--brand);
}


.clear-filter-link {
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: underline;
}

.clear-filter-link:hover {
  color: var(--brand-dark);
}

.agent-breakdown {
  margin-bottom: 28px;
}

.agent-scroll {
  max-height: 320px;
  max-width: 960px;
}

.evaluation-count {
  color: var(--muted);
  font-size: 0.78rem;
}

.agent-scroll .tickets-table td:not(:first-child),
.agent-scroll .tickets-table th:not(:first-child) {
  text-align: right;
}

.modal-trigger {
  color: var(--brand-dark);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.modal-trigger:hover {
  color: var(--brand);
}

/* Modal em CSS puro via :target — sem JS. O link de fechar aponta pra "#",
   que limpa o :target atual e esconde o overlay de novo. */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 31, 43, 0.55);
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-overlay:target {
  display: flex;
}

.modal-content {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px;
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(26, 31, 43, 0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.modal-close {
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 6px;
}

.modal-close:hover {
  color: var(--text);
  background: var(--bg);
}

.chat-evaluation {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.chat-evaluation h4 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: var(--brand-dark);
}

.chat-evaluation-checklist {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checklist-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 10px;
  font-weight: 400 !important;
  text-transform: none !important;
  cursor: pointer;
  font-size: 0.87rem;
  line-height: 1.4;
}

.checklist-item input[type="checkbox"] {
  margin-top: 2px;
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--brand);
}

.chat-evaluation-observacoes {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
}

.chat-evaluation-observacoes:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 129, 27, 0.2);
}
