/* ============================================================
   SAÚDE+ - Sistema de Gestão Integrado
   Arquivo: css/style.css
   Descrição: Estilos principais do protótipo SaaS
   ============================================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Poppins:wght@400;500;600;700&display=swap');

/* ---- CSS Custom Properties (Tema Claro) ---- */
:root {
  --font-primary: 'Inter', sans-serif;
  --font-heading: 'Poppins', sans-serif;

  /* Cores principais */
  --primary: #0d6efd;
  --primary-dark: #0a58ca;
  --primary-light: #e8f0fe;
  --secondary: #6c757d;
  --success: #198754;
  --warning: #ffc107;
  --danger: #dc3545;
  --info: #0dcaf0;

  /* Sidebar */
  --sidebar-bg: #1a2035;
  --sidebar-text: #a9b3c1;
  --sidebar-active-bg: rgba(13,110,253,0.15);
  --sidebar-active-text: #4d9fff;
  --sidebar-hover-bg: rgba(255,255,255,0.05);
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 70px;

  /* Layout */
  --topbar-height: 60px;
  --bg-body: #f0f2f5;
  --bg-card: #ffffff;
  --bg-card-header: #f8f9fa;
  --border-color: #dee2e6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

  /* Text */
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;

  /* Transitions */
  --transition: all 0.25s ease;
}

/* ---- Tema Escuro ---- */
body.dark-mode {
  --bg-body: #0f1117;
  --bg-card: #1a1d2e;
  --bg-card-header: #222539;
  --border-color: #2d3154;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  --sidebar-bg: #0d0f1a;
  --primary-light: #1e2a4a;
}

/* ---- Reset e Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-primary);
  background-color: var(--bg-body);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
  margin: 0;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-primary);
}

a { text-decoration: none; }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a2035 0%, #0d6efd 100%);
  position: relative;
  overflow: hidden;
}

#login-screen::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: rgba(255,255,255,0.03);
  border-radius: 50%;
  top: -100px; right: -150px;
}

#login-screen::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  bottom: -80px; left: -80px;
}

.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  position: relative;
  z-index: 1;
}

.login-logo {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 0.25rem;
}

.login-logo-img {
  height: 42px;
  width: auto;
  object-fit: contain;
}

.login-logo > span > span { color: #1a2035; }

.login-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 2rem;
  color: rgba(255,255,255,0.55);
  font-size: 0.78rem;
}

.login-footer strong { color: rgba(255,255,255,0.8); }

.login-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

.login-card .form-control {
  border-radius: 10px;
  padding: 0.75rem 1rem;
  border: 1.5px solid #e0e0e0;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.login-card .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}

.login-card .input-group-text {
  border-radius: 10px 0 0 10px;
  background: #f8f9fa;
  border: 1.5px solid #e0e0e0;
  border-right: none;
  color: var(--text-secondary);
}

.login-card .input-group .form-control {
  border-radius: 0 10px 10px 0;
}

.btn-login {
  width: 100%;
  padding: 0.75rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1rem;
  background: linear-gradient(135deg, #0d6efd, #0a58ca);
  border: none;
  color: #fff;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(13,110,253,0.3);
}

.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(13,110,253,0.4);
  background: linear-gradient(135deg, #0a58ca, #084298);
}

.login-hint {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: #f8f9fa;
  padding: 0.75rem;
  border-radius: 8px;
}

/* ============================================================
   TENANT SELECTOR (Multi-tenancy)
   ============================================================ */
#tenant-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a2035 0%, #0d6efd 100%);
}

.tenant-selector-card {
  background: #fff;
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.tenant-option {
  border: 2px solid #e0e0e0;
  border-radius: 15px;
  padding: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  background: #fff;
}

.tenant-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.tenant-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.tenant-option .tenant-icon {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, #0d6efd, #0a58ca);
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  color: #fff;
  font-size: 1.5rem;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
#app {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 1000;
  transition: width 0.3s ease, transform 0.3s ease;
  overflow-x: hidden;
}

#sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 1.2rem 1.5rem;
  min-height: var(--topbar-height);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  gap: 0.75rem;
}

.sidebar-logo {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-logo span { color: #4d9fff; }

.sidebar-logo-img {
  height: 36px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #0d6efd, #16a8c9);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(169,179,193,0.5);
  padding: 1rem 1.5rem 0.4rem;
  white-space: nowrap;
  overflow: hidden;
}

#sidebar.collapsed .sidebar-section-label,
#sidebar.collapsed .sidebar-logo,
#sidebar.collapsed .nav-label,
#sidebar.collapsed .sidebar-badge {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 1.5rem;
  color: var(--sidebar-text);
  border-radius: 0;
  transition: var(--transition);
  font-size: 0.875rem;
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}

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

.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.sidebar-nav a .nav-icon {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 0.5rem 0;
}

/* ---- Main Content Area ---- */
#main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

#main-content.expanded {
  margin-left: var(--sidebar-collapsed-width);
}

.app-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.75rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.app-footer strong { color: var(--text-primary); }

/* ---- Topbar ---- */
#topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 999;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.3s ease;
}

#topbar .topbar-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-btn {
  width: 38px; height: 38px;
  border: none;
  background: transparent;
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  position: relative;
}

.topbar-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.notification-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: 10px;
  transition: var(--transition);
}

.topbar-user:hover { background: var(--primary-light); }

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #0d6efd, #16a8c9);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
}

.user-info .user-name {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.user-info .user-clinic {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* ---- Page Content ---- */
.page-content {
  padding: 1.75rem;
  flex: 1;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin: 0.25rem 0 0;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.card-header {
  background: var(--bg-card-header);
  border-bottom: 1px solid var(--border-color);
  border-radius: 12px 12px 0 0 !important;
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  transition: background-color 0.3s ease;
}

/* Metric Cards */
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  right: 0; height: 3px;
  border-radius: 12px 12px 0 0;
}

.metric-card.blue::after { background: var(--primary); }
.metric-card.green::after { background: var(--success); }
.metric-card.orange::after { background: var(--warning); }
.metric-card.red::after { background: var(--danger); }
.metric-card.cyan::after { background: var(--info); }

.metric-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

.metric-icon.blue { background: rgba(13,110,253,0.12); color: var(--primary); }
.metric-icon.green { background: rgba(25,135,84,0.12); color: var(--success); }
.metric-icon.orange { background: rgba(255,193,7,0.15); color: #e6a000; }
.metric-icon.red { background: rgba(220,53,69,0.12); color: var(--danger); }
.metric-icon.cyan { background: rgba(13,202,240,0.12); color: #0dcaf0; }

.metric-value {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.metric-trend {
  font-size: 0.75rem;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.metric-trend.up { color: var(--success); }
.metric-trend.down { color: var(--danger); }

/* ============================================================
   TABLES
   ============================================================ */
.table {
  color: var(--text-primary);
}

.table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 2px solid var(--border-color);
  background: var(--bg-card-header);
}

.table td {
  vertical-align: middle;
  border-color: var(--border-color);
  font-size: 0.875rem;
}

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

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-agendado { background: rgba(13,110,253,0.12); color: var(--primary); }
.status-confirmado { background: rgba(25,135,84,0.12); color: var(--success); }
.status-cancelado { background: rgba(220,53,69,0.12); color: var(--danger); }
.status-realizado { background: rgba(108,117,125,0.12); color: var(--secondary); }
.status-pendente { background: rgba(255,193,7,0.15); color: #b38600; }
.status-pago { background: rgba(25,135,84,0.12); color: var(--success); }
.status-vencido { background: rgba(220,53,69,0.12); color: var(--danger); }

/* ============================================================
   FORMS
   ============================================================ */
.form-label {
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.form-control, .form-select {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-color);
  border-radius: 8px;
  font-size: 0.875rem;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}

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

.input-group-text {
  background-color: var(--bg-card-header);
  color: var(--text-secondary);
  border-color: var(--border-color);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
}

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

.btn-primary {
  background: linear-gradient(135deg, #0d6efd, #0a58ca);
  border: none;
  box-shadow: 0 2px 8px rgba(13,110,253,0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0a58ca, #084298);
  transform: translateY(-1px);
}

.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  color: var(--text-primary);
}

.modal-header {
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
}

.modal-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
}

.modal-footer {
  border-top: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
}

.btn-close {
  filter: var(--close-btn-filter, none);
}

body.dark-mode .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* ============================================================
   CALENDAR (FullCalendar overrides)
   ============================================================ */
.fc {
  font-family: var(--font-primary);
}

.fc-theme-standard .fc-scrollgrid,
.fc-theme-standard td,
.fc-theme-standard th {
  border-color: var(--border-color) !important;
}

.fc-col-header-cell-cushion,
.fc-daygrid-day-number {
  color: var(--text-primary) !important;
  text-decoration: none;
}

.fc-button-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  border-radius: 8px !important;
  font-size: 0.8rem !important;
}

.fc-button-primary:hover {
  background: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
}

.fc-button-primary:disabled {
  background: var(--secondary) !important;
  border-color: var(--secondary) !important;
}

.fc-toolbar-title {
  font-family: var(--font-heading) !important;
  font-size: 1.1rem !important;
  font-weight: 600 !important;
  color: var(--text-primary) !important;
}

.fc-event {
  border-radius: 6px !important;
  border: none !important;
  font-size: 0.75rem !important;
  padding: 2px 6px !important;
  cursor: pointer !important;
}

.fc-daygrid-body {
  background: var(--bg-card);
}

.fc-scrollgrid-sync-inner {
  background: var(--bg-card);
}

.fc .fc-daygrid-day.fc-day-today {
  background: var(--primary-light) !important;
}

body.dark-mode .fc-col-header {
  background: var(--bg-card-header) !important;
}

/* ============================================================
   DRAG & DROP ANAMNESE EDITOR
   ============================================================ */
.anamnese-toolbox {
  background: var(--bg-card-header);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  min-height: 300px;
}

.anamnese-field-item {
  background: var(--bg-card);
  border: 1.5px dashed var(--border-color);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  margin-bottom: 0.5rem;
  cursor: grab;
  font-size: 0.825rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
  user-select: none;
}

.anamnese-field-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.anamnese-field-item:active { cursor: grabbing; }

.anamnese-canvas {
  background: var(--bg-card);
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  min-height: 400px;
  transition: border-color 0.2s;
  position: relative;
}

.anamnese-canvas.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.anamnese-canvas-empty {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-muted);
  pointer-events: none;
}

.anamnese-canvas-empty i {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.5rem;
}

.form-field-block {
  background: var(--bg-card-header);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.65rem;
  position: relative;
  cursor: move;
  transition: var(--transition);
}

.form-field-block:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.form-field-block .field-actions {
  position: absolute;
  top: 0.5rem; right: 0.5rem;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.form-field-block:hover .field-actions { opacity: 1; }

/* Label editável dentro do canvas de anamnese */
.anamnese-label-input {
  font-weight: 600;
  font-size: 0.85rem;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.anamnese-label-input:hover,
.anamnese-label-input:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: none;
}
.anamnese-label-input.text-primary {
  color: var(--primary) !important;
  font-size: 0.95rem;
}

/* ============================================================
   FINANCIAL CHARTS
   ============================================================ */
.chart-placeholder {
  background: linear-gradient(135deg, var(--primary-light), var(--bg-card));
  border-radius: 8px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  border: 1px dashed var(--border-color);
}

/* ============================================================
   PATIENT TREE (Genealogia)
   ============================================================ */
.patient-tree {
  background: var(--bg-card-header);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  transition: var(--transition);
}

.tree-node:hover { background: var(--primary-light); }

.tree-node-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.tree-children {
  margin-left: 2rem;
  border-left: 2px solid var(--border-color);
  padding-left: 1rem;
}

/* ============================================================
   NOTIFICATIONS PANEL
   ============================================================ */
.notifications-list .notification-item {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
}

.notifications-list .notification-item:hover {
  background: var(--primary-light);
}

.notifications-list .notification-item.unread {
  background: rgba(13,110,253,0.04);
}

.notification-type-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
}

.notif-lembrete { background: rgba(13,110,253,0.12); color: var(--primary); }
.notif-alerta { background: rgba(255,193,7,0.15); color: #b38600; }
.notif-info { background: rgba(25,135,84,0.12); color: var(--success); }

.notif-content .notif-msg {
  font-size: 0.825rem;
  color: var(--text-primary);
  font-weight: 500;
}

.notif-content .notif-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.unread-dot {
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  margin-left: auto;
  align-self: center;
  flex-shrink: 0;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.app-toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 380px;
  animation: slideInRight 0.3s ease;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
}

.app-toast.success { background: linear-gradient(135deg, #198754, #157347); }
.app-toast.error { background: linear-gradient(135deg, #dc3545, #b02a37); }
.app-toast.warning { background: linear-gradient(135deg, #ffc107, #e6a000); color: #212529; }
.app-toast.info { background: linear-gradient(135deg, #0d6efd, #0a58ca); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
  position: relative;
}

.search-bar .fa-magnifying-glass {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.search-bar .form-control {
  padding-left: 2.25rem;
}

/* ============================================================
   PROFILE / SETTINGS
   ============================================================ */
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.settings-section h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--bg-card-header);
  border: 1px solid var(--border-color);
}

.form-switch .form-check-input {
  width: 2.5em;
  height: 1.35em;
  cursor: pointer;
}

/* ============================================================
   MINI CALENDAR / APPOINTMENT QUICK VIEW
   ============================================================ */
.quick-appointment {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-color);
}

.quick-appointment:last-child { border-bottom: none; }

.appt-time {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  min-width: 50px;
  text-align: right;
}

.appt-bar {
  width: 3px;
  height: 36px;
  border-radius: 3px;
  background: var(--primary);
  flex-shrink: 0;
}

.appt-bar.confirmado { background: var(--success); }
.appt-bar.agendado { background: var(--primary); }
.appt-bar.cancelado { background: var(--danger); }

.appt-info .appt-patient {
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--text-primary);
}

.appt-info .appt-detail {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
  #sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }

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

  #main-content,
  #main-content.expanded {
    margin-left: 0 !important;
  }

  #sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
  }

  #sidebar-overlay.show { display: block; }

  .page-content { padding: 1rem; }

  .metric-value { font-size: 1.3rem; }
}

@media (max-width: 575.98px) {
  .login-card { margin: 1rem; padding: 1.75rem; }
  .tenant-selector-card { margin: 1rem; padding: 1.5rem; }
  .page-content { padding: 0.75rem; }
}

/* ---- Dark mode table / form overrides ---- */
body.dark-mode .table {
  --bs-table-bg: var(--bg-card);
  --bs-table-striped-bg: var(--bg-card-header);
  --bs-table-hover-bg: rgba(13,110,253,0.1);
  --bs-table-border-color: var(--border-color);
  color: var(--text-primary);
}

body.dark-mode .modal-backdrop { opacity: 0.7; }

body.dark-mode .dropdown-menu {
  background: var(--bg-card);
  border-color: var(--border-color);
}

body.dark-mode .dropdown-item {
  color: var(--text-primary);
}

body.dark-mode .dropdown-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Utility ---- */
.text-primary-custom { color: var(--primary) !important; }
.fw-600 { font-weight: 600; }
.cursor-pointer { cursor: pointer; }
.rounded-xl { border-radius: 12px; }
.border-start-primary { border-left: 3px solid var(--primary) !important; }
.border-start-success { border-left: 3px solid var(--success) !important; }
.border-start-warning { border-left: 3px solid var(--warning) !important; }
.border-start-danger { border-left: 3px solid var(--danger) !important; }

/* ============================================================
   NEW MODULES: Prontuário, Relatórios, Usuários, Materiais, Planos
   ============================================================ */

/* Status badges — new statuses */
.status-badge.status-faltou { background: rgba(253,126,20,.12); color: #fd7e14; }
.status-badge.status-em_andamento { background: rgba(13,110,253,.12); color: var(--primary); }
.status-badge.status-finalizado { background: rgba(25,135,84,.12); color: var(--success); }
.status-badge.status-rascunho { background: rgba(108,117,125,.12); color: var(--secondary); }

/* Prontuário timeline */
.prontuario-card { border-left: 4px solid var(--primary); }
.prontuario-card .card-header { background: var(--bg-card-header); padding: 0.75rem 1rem; }
.rx-item { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.5rem 0.75rem;
  background: var(--bg-card-header); border-radius: 8px; margin-bottom: 0.35rem; }

/* Relatórios / KPI cards — metric-card colored variants */
.metric-card.blue  { --mc-clr:#0d6efd; --mc-bg:rgba(13,110,253,.08); }
.metric-card.green { --mc-clr:#198754; --mc-bg:rgba(25,135,84,.08); }
.metric-card.orange{ --mc-clr:#fd7e14; --mc-bg:rgba(253,126,20,.08); }
.metric-card.cyan  { --mc-clr:#0dcaf0; --mc-bg:rgba(13,202,240,.08); }
.metric-card { background: var(--mc-bg, var(--bg-card-header)); border: 1px solid var(--border-color);
  border-radius: 12px; padding: 1.25rem; position: relative; overflow: hidden; }
.metric-icon { width: 44px; height: 44px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; font-size: 1.2rem; margin-bottom: 0.75rem;
  background: var(--mc-bg, rgba(13,110,253,.1)); color: var(--mc-clr, var(--primary)); }
.metric-icon.blue  { background: rgba(13,110,253,.12); color:#0d6efd; }
.metric-icon.green { background: rgba(25,135,84,.12); color:#198754; }
.metric-icon.orange{ background: rgba(253,126,20,.12); color:#fd7e14; }
.metric-icon.cyan  { background: rgba(13,202,240,.12); color:#0dcaf0; }
.metric-value { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); line-height: 1.1; }
.metric-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }
.metric-trend { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.4rem; }
.metric-trend.up { color: var(--success); }
.metric-trend.down { color: var(--danger); }

/* Usuários — perfil badges */
.badge.bg-danger-subtle   { background: rgba(220,53,69,.12)!important; }
.badge.bg-primary-subtle  { background: rgba(13,110,253,.12)!important; }
.badge.bg-success-subtle  { background: rgba(25,135,84,.12)!important; }
.badge.bg-info-subtle     { background: rgba(13,202,240,.12)!important; }
.badge.bg-warning-subtle  { background: rgba(255,193,7,.12)!important; }
.badge.bg-secondary-subtle{ background: rgba(108,117,125,.12)!important; }
.text-danger   { color:#dc3545!important; }
.text-primary  { color:var(--primary)!important; }
.text-success  { color:var(--success)!important; }
.text-info     { color:#0dcaf0!important; }
.text-warning  { color:#ffc107!important; }
.text-secondary{ color:#6c757d!important; }

/* Materiais — stock warning row */
tr:has(.text-danger) { background: rgba(220,53,69,.04); }
tr:has(.text-warning) { background: rgba(255,193,7,.04); }

/* Plano tratamento procedimentos */
.plano-proc-item { display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0.75rem; background: var(--bg-card-header); border-radius: 8px; margin-bottom: 0.35rem; }

/* Parcelas preview table */
#parc-preview .table { font-size: 0.8rem; }

/* Pill / chip items in lists */
.badge.bg-info-subtle.text-info { background: rgba(13,202,240,.12)!important; color:#0dcaf0!important; }

/* Paciente status badges */
.status-badge.status-ativo    { background: rgba(25,135,84,.12); color: var(--success); }
.status-badge.status-inativo  { background: rgba(108,117,125,.12); color: #6c757d; }
.status-badge.status-arquivado{ background: rgba(255,193,7,.12); color: #ffc107; }

/* fs-sm utility */
.fs-sm { font-size: 0.8rem !important; }
.fw-500 { font-weight: 500; }
