/* ==========================================================================
   PRE-ATENDIMENTO — CSS autônomo. Não depende de agenda.css nem orcamentos.css.
   Todas as classes próprias têm prefixo "pre-" para evitar colisão.
   ========================================================================== */

#app-content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: #f1f5f9;
}


/* ----- Filtros ----- */
.pre-filters-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 14px 20px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
  flex-shrink: 0;
}
@media (min-width: 1280px) {
  .pre-filters-bar { flex-wrap: nowrap; }
}
.pre-filter { display: flex; flex-direction: column; gap: 4px; }
.pre-filter label {
  font-size: 10px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.pre-filter input,
.pre-filter select {
  padding: 6px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 12px;
  background: #fff;
  min-width: 140px;
}
.pre-filter-search input { width: 380px; min-width: 240px; }

.pre-btn-apply {
  width: auto;
  flex: 0 0 auto;
  height: 28px;
  padding: 0 14px;
  margin: 0;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #2563eb;
  color: #fff;
}
.pre-btn-apply:hover { background: #1d4ed8; }

.pre-counter {
  margin-left: auto;
  font-size: 11px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #b45309;
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.pre-counter #preCounterNum {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

/* ----- Split ----- */
.pre-split-container {
  display: flex;
  flex: 1;
  background: #f1f5f9;
  overflow: hidden;
  min-height: 0;
}
.pre-panel {
  background: #fff;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.pre-panel-left { width: 460px; border-right: 1px solid #e2e8f0; }
.pre-panel-right { flex: 1; }
.pre-panel .panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.pre-panel .panel-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

/* ----- Lista ----- */
.pre-list-wrapper { flex: 1; overflow-y: auto; }
.pre-list { list-style: none; margin: 0; padding: 0; }
.pre-list .pre-empty {
  padding: 30px 20px;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
}
.pre-item {
  border-bottom: 1px solid #f1f5f9;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.pre-item:hover { background: #f8fafc; }
.pre-item.active {
  background: #eff6ff;
  border-left: 3px solid #2563eb;
  padding-left: 13px;
}
.pre-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.pre-item-row:last-child { margin-bottom: 0; }
.pre-item-meta { font-size: 12px; color: #64748b; }
.pre-item-meta span { display: inline-flex; gap: 4px; align-items: center; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.badge-ac { background: #fef3c7; color: #92400e; }

.pre-item-hour {
  font-weight: 600;
  color: #2563eb;
  font-variant-numeric: tabular-nums;
  min-width: 48px;
}
.pre-item-name {
  font-weight: 500;
  color: #1e293b;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----- Painel direito ----- */
.panel-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #94a3b8;
  gap: 10px;
}
.panel-empty i { font-size: 48px; opacity: 0.5; }
.panel-empty p { margin: 0; font-size: 14px; }

.pre-detail {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}
.pre-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 18px;
}
.pre-detail-header h3 { margin: 0 0 6px 0; font-size: 18px; color: #1e293b; }
.pre-detail-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 13px;
  color: #64748b;
}
.pre-detail-sub span { display: inline-flex; gap: 5px; align-items: center; }
.pre-detail-actions { flex-shrink: 0; }

/* ----- Form ----- */
.pre-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 16px;
}
.pre-field { display: flex; flex-direction: column; gap: 4px; }
.pre-field-full { grid-column: 1 / -1; }
.pre-field label { font-size: 12px; font-weight: 600; color: #475569; }
.pre-field input,
.pre-field textarea {
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  font-family: inherit;
}
.pre-field input:focus,
.pre-field textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.pre-field-readonly input {
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
}

.pre-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}
.pre-form-actions button {
  padding: 9px 18px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.btn-primary { background: #16a34a; color: #fff; }
.btn-primary:hover { background: #15803d; }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background: #cbd5e1; }

/* Botão "Chamar no Painel" - destaque */
.btn-call-panel {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(234, 88, 12, 0.35);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}
.btn-call-panel:hover {
  filter: brightness(1.05);
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.45);
  transform: translateY(-1px);
}
.btn-call-panel:active { transform: translateY(0); }
.btn-call-panel i { font-size: 15px; }

/* Textarea de observação - altura mínima maior */
#dsObservacao {
  min-height: 110px;
  resize: vertical;
  line-height: 1.45;
}

/* Badges de status na lista */
.badge-triado { background: #dcfce7; color: #166534; }

.pre-item.triado {
  background: #f0fdf4;
}
.pre-item.triado:hover { background: #dcfce7; }
.pre-item.triado.active {
  background: #dcfce7;
  border-left-color: #16a34a;
}

.pre-item-triado-info {
  font-size: 11px;
  color: #16a34a;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ----- Modal (classes próprias com prefixo pre-) ----- */
.pre-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.pre-modal-overlay[hidden] { display: none; }

.pre-modal-window {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.pre-modal-header {
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e2e8f0;
}
.pre-modal-header h3 { margin: 0; font-size: 15px; color: #1e293b; }
.pre-modal-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #64748b;
  font-size: 16px;
}
.pre-modal-body { padding: 18px; }
.pre-form-control {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
}
.pre-muted { color: #94a3b8; }
.pre-modal-footer {
  padding: 12px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}
.pre-modal-footer button {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

/* ----- Toast ----- */
.pre-toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pre-toast {
  background: #1e293b;
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.18);
  transition: opacity 0.3s;
}
.pre-toast.success { background: #16a34a; }
.pre-toast.error   { background: #dc2626; }

/* ----- Checkbox field ----- */
.pre-field-checkbox {
  display: flex;
  align-items: center;
}
.pre-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
  white-space: nowrap;
}
.pre-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #f97316;
  cursor: pointer;
  flex-shrink: 0;
}
.pre-checkbox-label:has(input:checked) {
  border-color: #f97316;
  background: #fff7ed;
  color: #c2410c;
}

/* ----- Seção Oftalmologia ----- */
.pre-section-oftalmo {
  margin-top: 18px;
  border: 1.5px solid #bfdbfe;
  border-radius: 10px;
  overflow: hidden;
}
.pre-section-title {
  background: #eff6ff;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  color: #1d4ed8;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pre-section-oftalmo .pre-form-grid {
  padding: 14px 16px;
  background: #f8fafc;
}
.pre-section-oftalmo select,
.pre-section-oftalmo input[type="time"] {
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  font-family: inherit;
  color: #1e293b;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.pre-section-oftalmo select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.pre-section-oftalmo select:focus,
.pre-section-oftalmo input[type="time"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* ----- Botão Histórico ----- */
.btn-historico {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: #f1f5f9;
  color: #475569;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-historico:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

/* ----- Modal Histórico ----- */
.pre-modal-historico {
  max-width: 860px;
  width: 95vw;
}
.pre-hist-body {
  padding: 0 !important;
  max-height: 75vh;
  overflow-y: auto;
}
.pre-hist-loading {
  padding: 40px;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
}
.pre-hist-vazio {
  padding: 50px 20px;
  text-align: center;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.pre-hist-vazio i { font-size: 40px; opacity: 0.4; }
.pre-hist-vazio p { margin: 0; font-size: 14px; }

.pre-hist-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}
.pre-hist-chart-wrap {
  background: #fff;
  padding: 16px 20px 12px;
}
.pre-hist-chart-title {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pre-hist-table-wrap {
  overflow-x: auto;
  padding: 0 0 4px;
}
.pre-hist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.pre-hist-table thead th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.pre-hist-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: top;
}
.pre-hist-table tbody tr:last-child td { border-bottom: none; }
.pre-hist-table tbody tr:hover td { background: #f8fafc; }
.hist-badge-prior {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
}
.hist-obs {
  max-width: 200px;
  color: #475569;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ----- Responsivo ----- */
@media (max-width: 1100px) {
  .pre-form-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 800px) {
  .pre-split-container { flex-direction: column; }
  .pre-panel-left { width: 100%; max-height: 40vh; border-right: none; border-bottom: 1px solid #e2e8f0; }
  .pre-form-grid { grid-template-columns: 1fr; }
}
