/* ============================================================
   Clínica Manager — Design System
   Light theme by default, dark mode via data-theme="dark"
   ============================================================ */

/* =================== Variables (Light Theme) =================== */
:root {
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f8f9fb;
  --bg-hover: #e8eaef;
  --border: #d1d5db;
  --border-focus: #3b82f6;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --accent: #3b82f6;
  --accent-light: #2563eb;
  --accent-bg: rgba(59, 130, 246, 0.08);
  --success: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.08);
  --warning: #d97706;
  --warning-bg: rgba(217, 119, 6, 0.08);
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.08);
  --info: #0891b2;
  --info-bg: rgba(8, 145, 178, 0.08);
  --primary: var(--accent);
  --primary-bg: var(--accent-bg);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --font: 'Inter', -apple-system, sans-serif;
  --sidebar-bg: #ffffff;
  --sidebar-text: #111827;
  --sidebar-text-muted: #6b7280;
  --sidebar-hover: #f3f4f6;
  --sidebar-active-bg: rgba(59, 130, 246, 0.08);
  --sidebar-active-text: #2563eb;
  --sidebar-border: #e5e7eb;
  --sidebar-brand-text: #111827;
}

/* =================== Dark Theme =================== */
[data-theme="dark"] {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a2035;
  --bg-input: #0f1629;
  --bg-hover: #1e2a45;
  --border: #2a3550;
  --text-primary: #f0f4ff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-light: #60a5fa;
  --accent-bg: rgba(59, 130, 246, 0.12);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --sidebar-bg: #0d1117;
  --sidebar-text: #e5e7eb;
  --sidebar-text-muted: #64748b;
  --sidebar-hover: #161b22;
  --sidebar-active-bg: rgba(59, 130, 246, 0.15);
  --sidebar-active-text: #60a5fa;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-brand-text: #f0f4ff;
}

/* =================== Reset =================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

input,
select,
textarea,
button {
  font-family: inherit;
  font-size: inherit;
}

::selection {
  background: var(--accent);
  color: white;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* =================== Layout =================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar — themed */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.25s ease;
  color: var(--sidebar-text);
}

.sidebar-brand {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-icon {
  font-size: 1.75rem;
  color: var(--accent);
}

.brand-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--sidebar-brand-text);
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.5rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  color: var(--sidebar-text-muted);
  font-weight: 500;
  transition: all 0.15s ease;
  margin-bottom: 2px;
  font-size: 0.9rem;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.nav-item .material-icons-round {
  font-size: 1.25rem;
}

.nav-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 0.75rem 1rem;
}

.sidebar-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
  color: var(--sidebar-text-muted);
  font-size: 0.75rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--sidebar-border);
  margin-top: auto;
}

.sidebar-user-info {
  flex: 1;
  overflow: hidden;
}

.sidebar-user-name {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--sidebar-text);
}

.sidebar-user-role {
  display: block;
  font-size: 0.7rem;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* =================== Login Screen =================== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a0e1a 0%, #111827 50%, #0f172a 100%);
}

.login-card {
  background: #1a2035;
  border: 1px solid #2a3550;
  border-radius: var(--radius-lg);
  padding: 2rem 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  color: #f0f4ff;
}

.login-card .form-label {
  color: #94a3b8;
}

.login-card .form-input {
  background: #0f1629;
  border-color: #2a3550;
  color: #f0f4ff;
}

.login-card .form-input:focus {
  border-color: var(--accent);
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-top: 0.5rem;
  letter-spacing: -0.5px;
  color: #f0f4ff;
}

.login-brand p {
  margin-top: 0.25rem;
  color: #64748b;
}

.login-error {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 0.75rem;
  font-size: 0.95rem;
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.top-bar {
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar-title {
  font-weight: 700;
  font-size: 1.1rem;
  flex: 1;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
}

.content-area {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

/* =================== Cards =================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-header h3 .material-icons-round {
  font-size: 1.2rem;
  color: var(--accent);
}

.card-body {}

/* =================== Buttons =================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  font-size: 0.85rem;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-light);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  opacity: 0.85;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.btn-sm .material-icons-round {
  font-size: 1rem;
}

.btn .material-icons-round {
  font-size: 1.1rem;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.btn-icon:hover {
  color: var(--accent);
  background: var(--accent-bg);
}

.btn-icon--danger:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

/* =================== Forms =================== */
.form-group {
  margin-bottom: 1rem;
}

.form-group--wide {
  flex: 2;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

select.form-input {
  cursor: pointer;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.form-card {
  max-width: 800px;
  padding: 1.5rem;
}

/* =================== Tables =================== */
.data-table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.clickable-row {
  cursor: pointer;
  transition: background 0.15s;
}

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

.row-actions {
  display: flex;
  gap: 0.25rem;
}

.fw-600 {
  font-weight: 600;
}

.text-center {
  text-align: center;
}

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

.text-danger {
  color: var(--danger);
}

/* =================== Page Header =================== */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header h2 {
  font-size: 1.2rem;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 250px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem;
}

.search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.search-bar .material-icons-round {
  color: var(--text-muted);
  font-size: 1.2rem;
}

/* =================== Patient Avatar =================== */
.patient-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.patient-avatar--lg {
  width: 56px;
  height: 56px;
  font-size: 1.3rem;
}

.patient-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

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

.patient-row:last-child {
  border-bottom: none;
}

.patient-info {
  flex: 1;
}

.patient-name {
  font-weight: 600;
  font-size: 0.9rem;
  display: block;
}

.patient-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* =================== Badges =================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-primary {
  background: var(--primary-bg);
  color: var(--accent);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-agendado {
  background: var(--primary-bg);
  color: var(--accent);
}

.badge-confirmado {
  background: var(--success-bg);
  color: var(--success);
}

.badge-em_atendimento {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-concluido {
  background: var(--success-bg);
  color: var(--success);
}

.badge-cancelado {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-faltou {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-rascunho {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-finalizado {
  background: var(--success-bg);
  color: var(--success);
}

/* =================== Dashboard =================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--accent-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon .material-icons-round {
  font-size: 1.5rem;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  display: block;
  letter-spacing: -1px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.dashboard-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.schedule-list {}

.schedule-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.schedule-item:hover {
  background: var(--bg-hover);
}

.schedule-time {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
  min-width: 45px;
}

.schedule-patient {
  flex: 1;
  font-weight: 500;
  font-size: 0.9rem;
}

.schedule-type {
  font-size: 0.7rem;
}

/* =================== Agenda =================== */
.agenda-calendar-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.mini-calendar {
  width: 280px;
  flex-shrink: 0;
  padding: 1rem;
}

.mini-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.mini-cal-month {
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: capitalize;
}

.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.mini-cal-dow {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.25rem 0;
  text-transform: uppercase;
}

.mini-cal-day {
  font-size: 0.8rem;
  padding: 0.35rem 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

.mini-cal-day:hover {
  background: var(--bg-hover);
}

.mini-cal-day--empty {
  visibility: hidden;
}

.mini-cal-day--today {
  color: var(--accent);
  font-weight: 800;
}

.mini-cal-day--selected {
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.mini-cal-day--selected:hover {
  background: var(--accent-light);
}

.agenda-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.agenda-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.agenda-date-label {
  font-weight: 700;
  font-size: 1rem;
  text-transform: capitalize;
  margin-left: 0.5rem;
}

.agenda-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.agenda-view-toggle {
  display: flex;
  gap: 0.25rem;
}

/* Day View */
.agenda-day {}

.agenda-slot {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  min-height: 52px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.agenda-slot:hover {
  background: var(--bg-hover);
}

.agenda-slot-time {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 50px;
}

.agenda-slot-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.agenda-slot-patient {
  font-weight: 600;
  font-size: 0.9rem;
}

.agenda-slot-type {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.agenda-slot-insurance {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.agenda-slot-empty {
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.15s;
}

.agenda-slot:hover .agenda-slot-empty {
  opacity: 1;
}

.agenda-slot--filled {
  background: var(--bg-card);
}

.agenda-slot--primary {
  border-left-color: var(--accent);
}

.agenda-slot--success {
  border-left-color: var(--success);
}

.agenda-slot--warning {
  border-left-color: var(--warning);
}

/* Week View */
.agenda-week {
  overflow-x: auto;
}

.agenda-week-header {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  gap: 1px;
  margin-bottom: 1px;
}

.agenda-week-day-col {
  text-align: center;
  padding: 0.6rem 0.25rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}

.agenda-week-day-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
}

.agenda-week-day-num {
  font-size: 1.1rem;
  font-weight: 800;
  display: block;
}

.agenda-week-today {
  background: var(--accent-bg);
}

.agenda-week-today .agenda-week-day-num {
  color: var(--accent);
}

.agenda-week-time-col {}

.agenda-week-body {}

.agenda-week-row {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  gap: 1px;
}

.agenda-week-time {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.4rem 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.agenda-week-cell {
  min-height: 36px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 2px;
}

.agenda-week-cell:hover {
  background: var(--bg-hover);
}

.agenda-week-cell--filled {
  font-size: 0.7rem;
  font-weight: 600;
}

.agenda-week-cell--consulta {
  background: var(--accent-bg);
  color: var(--accent);
}

.agenda-week-cell--exame {
  background: var(--success-bg);
  color: var(--success);
}

.agenda-week-cell--procedimento {
  background: var(--warning-bg);
  color: var(--warning);
}

.agenda-week-cell-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Autocomplete */
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.autocomplete-item {
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.autocomplete-item:hover {
  background: var(--bg-hover);
}

.autocomplete-item strong {
  display: block;
  font-size: 0.9rem;
}

.autocomplete-item small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.quick-register {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 1rem;
}

/* Appointment detail */
.appt-detail {
  margin-bottom: 1rem;
}

.appt-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.appt-detail-row .material-icons-round {
  color: var(--text-muted);
  margin-top: 2px;
}

.appt-detail-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.appt-status-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* =================== Timeline (Prontuário) =================== */
.prontuario-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.prontuario-patient-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.prontuario-patient-info h2 {
  font-size: 1.3rem;
}

.prontuario-meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.prontuario-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.prontuario-actions {
  display: flex;
  gap: 0.5rem;
}

.timeline {
  position: relative;
  padding-left: 2.5rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 17px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
}

.timeline-item--primary {
  border-left: 3px solid var(--accent);
}

.timeline-item--success {
  border-left: 3px solid var(--success);
}

.timeline-item--warning {
  border-left: 3px solid var(--warning);
}

.timeline-item--danger {
  border-left: 3px solid var(--danger);
}

.timeline-item--info {
  border-left: 3px solid var(--info);
}

.timeline-marker {
  position: absolute;
  left: -2.5rem;
  top: 1rem;
  width: 32px;
  height: 32px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.timeline-marker .material-icons-round {
  font-size: 1rem;
  color: var(--accent);
}

.timeline-item--success .timeline-marker {
  border-color: var(--success);
}

.timeline-item--success .timeline-marker .material-icons-round {
  color: var(--success);
}

.timeline-item--warning .timeline-marker {
  border-color: var(--warning);
}

.timeline-item--warning .timeline-marker .material-icons-round {
  color: var(--warning);
}

.timeline-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.timeline-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.timeline-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.timeline-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.timeline-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.timeline-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* =================== Prontuário Landing =================== */
.prontuario-landing {
  max-width: 800px;
  margin: 0 auto;
}

.prontuario-search-box {
  text-align: center;
  padding: 2rem 1rem;
  margin-bottom: 1rem;
}

.prontuario-search-icon .material-icons-round {
  font-size: 3rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.prontuario-search-box h2 {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

.prontuario-search-box p {
  margin-bottom: 1.25rem;
}

.prontuario-search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1.25rem;
  transition: border-color 0.2s;
}

.prontuario-search-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.prontuario-search-input-wrapper .material-icons-round {
  color: var(--text-muted);
  font-size: 1.3rem;
}

.prontuario-search-input-wrapper .form-input {
  border: none;
  background: none;
  padding: 0;
  font-size: 1rem;
}

.prontuario-search-input-wrapper .form-input:focus {
  box-shadow: none;
}

/* =================== Prontuário Stats =================== */
.prontuario-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.prontuario-stat {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  text-align: center;
}

.prontuario-stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  display: block;
  color: var(--accent);
}

.prontuario-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Timeline Section */
.timeline-section {}

.timeline-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.timeline-section-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.timeline-section-header h3 .material-icons-round {
  color: var(--accent);
}

.timeline-filters {
  display: flex;
  gap: 0.25rem;
}

.timeline-filter.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent);
}

/* Medical Record Fields */
.record-fields {
  margin-top: 0.75rem;
}

.record-field {
  margin-bottom: 0.65rem;
}

.record-field:last-child {
  margin-bottom: 0;
}

.record-field-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
}

.record-field-label .material-icons-round {
  font-size: 0.85rem;
  color: var(--accent);
}

.record-field-value {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  padding-left: 1.2rem;
  border-left: 2px solid var(--border);
}

/* Consulta Form Header */
.consulta-form-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

/* Badge for registrado */
.badge-registrado {
  background: var(--success-bg);
  color: var(--success);
}

/* =================== Settings =================== */
.settings-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  padding-bottom: 0.25rem;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border: none;
  background: var(--bg-card);
  color: var(--text-muted);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: all 0.15s;
  border: 1px solid var(--border);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent);
}

.tab-btn .material-icons-round {
  font-size: 1.1rem;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.settings-header h3 {
  font-size: 1.1rem;
}

.settings-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 1.25rem 0 0.5rem;
}

.settings-list {}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.settings-item:hover {
  background: var(--bg-hover);
}

.settings-item--inactive {
  opacity: 0.45;
}

.settings-item-info {
  flex: 1;
}

.settings-item-name {
  font-weight: 600;
  display: block;
}

.settings-item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.settings-item-actions {
  display: flex;
  gap: 0.25rem;
}

/* =================== Report Editor =================== */
.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.report-section {
  margin-bottom: 1rem;
}

.report-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.report-section-header h4 {
  font-size: 0.95rem;
  font-weight: 700;
}

.report-section-header .material-icons-round {
  font-size: 1.2rem;
  color: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.measurement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}

.measurement-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.measurement-item label {
  font-weight: 600;
  font-size: 0.8rem;
  min-width: 30px;
  color: var(--text-secondary);
}

.measurement-item input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.9rem;
  min-width: 50px;
}

.measurement-item .unit {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.phrase-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.phrase-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.phrase-item:hover {
  color: var(--accent);
}

/* =================== Modal =================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

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

.modal-body {
  padding: 1.25rem;
}

/* =================== Toast =================== */
.toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  color: white;
  font-weight: 500;
  font-size: 0.85rem;
  transform: translateX(120%);
  transition: transform 0.25s ease;
  min-width: 250px;
  box-shadow: var(--shadow-lg);
}

.toast-show {
  transform: translateX(0);
}

.toast-success {
  background: var(--success);
}

.toast-error {
  background: var(--danger);
}

.toast-warning {
  background: var(--warning);
  color: #1a1a1a;
}

.toast-info {
  background: var(--accent);
}

.toast .material-icons-round {
  font-size: 1.2rem;
}

/* =================== Loading / Empty State =================== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state .material-icons-round {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  display: block;
}

.empty-state h3 {
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}

/* =================== Settings Mode Toggle =================== */
.settings-mode-toggle {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

/* =================== Theme Preview =================== */
.theme-options {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  padding: 1rem 0;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  transition: all 0.2s;
  font-weight: 600;
  font-size: 0.9rem;
}

.theme-option:hover {
  border-color: var(--accent);
}

.theme-option--active {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.theme-preview {
  width: 120px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  border: 1px solid var(--border);
}

.theme-preview-sidebar {
  width: 30px;
  flex-shrink: 0;
}

.theme-preview-content {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.theme-preview-content div {
  border-radius: 3px;
  height: 10px;
}

.theme-preview--light {
  background: #f0f2f5;
}

.theme-preview--light .theme-preview-sidebar {
  background: #111827;
}

.theme-preview--light .theme-preview-content div {
  background: #d1d5db;
}

.theme-preview--dark {
  background: #0a0e1a;
}

.theme-preview--dark .theme-preview-sidebar {
  background: #0d1117;
}

.theme-preview--dark .theme-preview-content div {
  background: #2a3550;
}

/* =================== Schedule Grid =================== */
.schedule-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.schedule-day {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.schedule-day-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 120px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.schedule-day-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.schedule-day-times {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.schedule-day-times .form-input {
  width: 110px;
}

/* =================== Agenda Doctor Select =================== */
.agenda-doctor-select {
  width: auto;
  min-width: 180px;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
}

/* =================== Responsive =================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: block;
  }

  .dashboard-panels {
    grid-template-columns: 1fr;
  }

  .report-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .agenda-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .prontuario-header {
    flex-direction: column;
  }

  .prontuario-stats {
    flex-direction: column;
  }

  .agenda-calendar-row {
    flex-direction: column;
  }

  .mini-calendar {
    width: 100%;
  }

  .settings-mode-toggle {
    flex-direction: column;
  }

  .theme-options {
    flex-direction: column;
    align-items: center;
  }

  .schedule-day {
    flex-direction: column;
    align-items: flex-start;
  }

  .agenda-split-view {
    flex-direction: column;
  }

  .agenda-walkin-panel {
    width: 100%;
    min-width: 0;
  }
}

/* =================== Agenda Split View =================== */
.agenda-split-view {
  display: flex;
  gap: 1rem;
}

.agenda-walkin-panel {
  width: 300px;
  min-width: 280px;
  flex-shrink: 0;
}

.walkin-list {
  max-height: 500px;
  overflow-y: auto;
}

.walkin-item {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.walkin-item:hover {
  background: var(--bg-input);
}

.walkin-item-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.85rem;
}

.walkin-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* =================== Procedure Rows =================== */
.procedure-row {
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.btn-icon--danger {
  color: var(--danger);
}

.btn-icon--danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* =================== Financial Stat Grid =================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.stat-card .material-icons-round {
  font-size: 1.5rem;
  color: var(--accent);
}

.stat-card .stat-value {
  font-size: 1.2rem;
  font-weight: 700;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-card--accent {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.stat-card--accent .material-icons-round {
  color: white;
}

.stat-card--accent .stat-label {
  color: rgba(255, 255, 255, 0.8);
}

/* =================== Table Footer =================== */
.table tfoot td {
  border-top: 2px solid var(--border);
  padding-top: 0.75rem;
}

.badge-info {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

/* =================== Table Responsive (Financeiro) =================== */
.table-responsive {
  overflow-x: auto;
  width: 100%;
}

.table-responsive .table {
  width: 100%;
  min-width: 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: 0.65rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.table tbody tr:hover {
  background: var(--bg-hover);
}

/* ============================================================
   CHAT INTERNO
   ============================================================ */
#chat-bubble {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 9999;
  transition: transform 0.2s, box-shadow 0.2s;
}

#chat-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

#chat-bubble .material-icons-round {
  font-size: 1.6rem;
}

.chat-bubble-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.chat-popup {
  position: fixed;
  bottom: 5rem;
  right: 1.5rem;
  width: 360px;
  max-height: 500px;
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--primary);
  color: #fff;
}

.chat-header h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-close-btn,
.chat-back-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
}

.chat-close-btn:hover,
.chat-back-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  min-height: 250px;
  max-height: 350px;
}

.chat-loading,
.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  gap: 0.5rem;
}

.chat-empty .material-icons-round {
  font-size: 2.5rem;
  opacity: 0.4;
}

.chat-empty p {
  font-size: 0.85rem;
  margin: 0;
}

/* Conversation list */
.chat-conv-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-conv-item:hover {
  background: var(--bg-hover);
}

.chat-conv-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.chat-conv-info {
  flex: 1;
  min-width: 0;
}

.chat-conv-name {
  font-weight: 600;
  font-size: 0.85rem;
  display: block;
}

.chat-conv-role {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.7rem;
}

.chat-conv-preview {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-conv-preview--empty {
  font-style: italic;
}

.chat-conv-unread {
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

/* Messages */
.chat-msg {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.5rem;
}

.chat-msg--mine {
  align-items: flex-end;
}

.chat-msg--theirs {
  align-items: flex-start;
}

.chat-msg-bubble {
  max-width: 80%;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-word;
}

.chat-msg--mine .chat-msg-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg--theirs .chat-msg-bubble {
  background: var(--bg-hover);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
  padding: 0 4px;
}

/* Chat input */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.chat-input:focus {
  border-color: var(--primary);
}

.chat-send-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  opacity: 0.9;
}

.chat-send-btn .material-icons-round {
  font-size: 1.1rem;
}

/* Badge for 'chegou' status */
.badge-chegou {
  background: rgba(var(--info-rgb, 59, 130, 246), 0.15);
  color: var(--info, #3b82f6);
}

/* ============================================================
   WHATSAPP ATENDIMENTO
   ============================================================ */
.wa-layout {
  display: flex;
  gap: 1rem;
  height: calc(100vh - 130px);
  min-height: 500px;
}

.wa-sidebar {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wa-sidebar-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.wa-sidebar-header h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.wa-sidebar-filters {
  display: flex;
  gap: 0.25rem;
}

.wa-contact-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem;
}

.wa-contact-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}

.wa-contact-item:hover {
  background: var(--bg-hover);
}

.wa-contact-item.active {
  background: var(--bg-hover);
  border-left-color: #25D366;
}

.wa-contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.wa-contact-info {
  flex: 1;
  min-width: 0;
}

.wa-contact-name {
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.wa-contact-patient {
  font-weight: 400;
  color: var(--primary);
  font-size: 0.7rem;
}

.wa-contact-phone {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.wa-contact-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  flex-shrink: 0;
}

.wa-contact-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.wa-contact-unread {
  background: #25D366;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.wa-empty-contacts {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  gap: 0.5rem;
}

.wa-empty-contacts .material-icons-round {
  font-size: 2.5rem;
  opacity: 0.3;
}

.wa-empty-contacts p {
  font-size: 0.85rem;
  margin: 0;
}

.wa-conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wa-empty-conv {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 0.5rem;
}

.wa-conv-header {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
}

.wa-conv-header-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wa-conv-header-info h4 {
  margin: 0;
  font-size: 0.95rem;
}

.wa-conv-header-actions {
  display: flex;
  gap: 0.35rem;
}

.wa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--bg);
}

.wa-msg {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.5rem;
}

.wa-msg--in {
  align-items: flex-start;
}

.wa-msg--out {
  align-items: flex-end;
}

.wa-msg-bubble {
  max-width: 75%;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-word;
}

.wa-msg--in .wa-msg-bubble {
  background: var(--bg-card);
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}

.wa-msg--out .wa-msg-bubble {
  background: #dcf8c6;
  color: #1a1a1a;
  border-bottom-right-radius: 4px;
}

[data-theme="dark"] .wa-msg--out .wa-msg-bubble {
  background: #005c4b;
  color: #e9edef;
}

.wa-msg-sender {
  font-size: 0.7rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 2px;
}

.wa-msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
  padding: 0 4px;
}

.wa-input-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.wa-msg-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.wa-msg-input:focus {
  border-color: #25D366;
}

.wa-send-btn {
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.wa-send-btn:hover {
  background: #128C7E;
}

.wa-send-btn .material-icons-round {
  font-size: 1.2rem;
}

.wa-patient-result:hover {
  background: var(--bg-hover);
}

.wa-bot-badge {
  font-size: 0.6rem;
  background: #6366f1;
  color: #fff;
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 0.25rem;
}

.wa-attach-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}

.wa-attach-btn:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

.wa-msg-media {
  margin-bottom: 0.35rem;
}

.wa-msg-media img {
  display: block;
}

.wa-msg-media audio {
  display: block;
}

.wa-kanban-card {
  transition: transform 0.15s, box-shadow 0.15s;
}

.wa-kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.wa-kanban-card:active {
  cursor: grabbing;
  transform: scale(0.98);
}

.wa-kanban-col {
  transition: outline 0.2s;
}

/* ============================================================
   SETTINGS TAB GROUPS (dropdown)
   ============================================================ */
.settings-tab-group {
  position: relative;
}

.tab-group-toggle {
  cursor: default !important;
}

.tab-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  min-width: 230px;
  padding: 0.35rem 0;
  overflow: hidden;
}

[data-theme="dark"] .tab-dropdown {
  background: #1e1e2e;
}

.settings-tab-group:hover .tab-dropdown {
  display: block;
}

.tab-dropdown .tab-btn {
  width: 100%;
  border-radius: 0;
  border: none;
  justify-content: flex-start;
  padding: 0.6rem 1rem;
  font-size: 0.84rem;
  background: transparent;
  color: var(--text);
  white-space: nowrap;
}

.tab-dropdown .tab-btn:hover {
  background: var(--bg-hover);
}

.tab-dropdown .tab-btn.active {
  background: rgba(var(--primary-rgb), 0.12);
  color: var(--primary);
  font-weight: 600;
}

/* ============================================================
   API DOCUMENTATION VIEWER
   ============================================================ */
/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 26px;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked+.toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(22px);
}

/* Collapsible sections */
.api-doc-section.collapsed .api-doc-body {
  display: none;
}

.api-doc-section.collapsed .api-doc-arrow {
  transform: rotate(-90deg);
}

.api-doc-arrow {
  transition: transform 0.2s;
  color: var(--text-muted);
}

/* Method badges */
.api-method-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  min-width: 42px;
  text-align: center;
  font-family: monospace;
}

.api-get {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
}

.api-post {
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
}

.api-put {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}

.api-delete {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

.api-label {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Code blocks */
.api-code-block {
  background: #1e1e2e;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin-top: 0.4rem;
}

.api-code-block pre {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.6;
  color: #cdd6f4;
  font-family: 'Fira Code', 'Consolas', monospace;
  white-space: pre-wrap;
}

/* Endpoint rows */
.api-endpoint-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.4rem;
  overflow: hidden;
}

.api-endpoint-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
}

.api-endpoint-head:hover {
  background: var(--bg-hover);
}

.api-path {
  font-size: 0.8rem;
  color: var(--text);
  font-weight: 500;
}

.api-endpoint-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.api-endpoint-details {
  display: none;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.api-endpoint-row.expanded .api-endpoint-details {
  display: block;
}

.api-endpoint-row.expanded .api-doc-arrow {
  transform: rotate(180deg);
}

/* ============================================================
   REPORT SECTIONS (exam form)
   ============================================================ */
.report-section {
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.report-section-title {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.percentile-bar-container {
  margin-bottom: 0.25rem;
}