/* ==========================================================
   PRONTUÃRIO MÃDICO ELETRÃNICO - APPLE HUMAN INTERFACE DESIGN SYSTEM
   Inspirado na precisÃ£o, fluidez e estÃ©tica do macOS & iOS
   ========================================================== */

:root {
  /* Apple Palette */
  --apple-bg: #f5f5f7;
  --apple-card: #ffffff;
  --apple-card-subtle: #fafafc;
  --apple-sidebar: rgba(246, 246, 248, 0.94);
  
  --primary: #0071e3;
  --primary-hover: #0077ed;
  --primary-light: #47a3ff;
  --primary-subtle: #eef7ff;
  
  --secondary: #00c7be;
  --secondary-hover: #00b3ab;
  --secondary-subtle: #e6faf9;
  
  --success: #34c759;
  --success-bg: #eaf9ed;
  --warning: #ff9500;
  --warning-bg: #fff5e6;
  --danger: #ff3b30;
  --danger-bg: #ffebeb;
  --purple: #af52de;
  --purple-bg: #f7edfc;
  
  --text-main: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  
  --sidebar-width: 275px;
  
  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-pill: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.07), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 25px 60px -15px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);

  /* Easing */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  background-color: var(--apple-bg);
  color: var(--text-main);
  line-height: 1.47059;
  font-size: 14px;
  letter-spacing: -0.016em;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================================
   APP CONTAINER & MACOS-STYLE SIDEBAR
   ========================================================== */
.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--apple-sidebar);
  backdrop-filter: blur(25px) saturate(180%);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  transition: width 0.25s var(--ease-spring), min-width 0.25s var(--ease-spring), padding 0.25s var(--ease-spring);
}

.app-container.sidebar-collapsed .sidebar {
  width: 0 !important;
  min-width: 0 !important;
  border-right: none !important;
  overflow: hidden !important;
  padding: 0 !important;
}

/* macOS Window Traffic Lights Decoration & Brand */
.brand-section {
  padding: 18px 20px 14px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.macos-traffic-lights {
  display: flex;
  align-items: center;
  gap: 8px;
}

.traffic-light {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

.traffic-light.red { background-color: #ff5f56; border: 1px solid #e0443e; }
.traffic-light.yellow { background-color: #ffbd2e; border: 1px solid #dea123; }
.traffic-light.green { background-color: #27c93f; border: 1px solid #1aab29; }

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #0071e3, #00c7be);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.28);
}

.brand-text h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-text span {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Sidebar Menu */
.nav-menu {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 12px 4px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease-spring);
}

.nav-item:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.nav-item.active {
  background-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

.nav-item .nav-icon {
  width: 17px;
  height: 17px;
  opacity: 0.8;
  flex-shrink: 0;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-tertiary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ==========================================================
   MACOS-STYLE TOP NAVBAR
   ========================================================= */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--apple-bg);
  height: 100vh;
  overflow-y: auto;
}

.top-navbar {
  height: 60px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.top-navbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.page-title-badge {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-navbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Control Pill Selector for Active Doctor */
.active-doctor-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: rgba(0, 0, 0, 0.04);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
}

.active-doctor-selector label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.active-doctor-selector select {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  border: none;
  background: transparent;
  outline: none;
  cursor: pointer;
}

.content-body {
  padding: 24px 28px 48px 28px;
  max-width: 100%;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
}

/* ==========================================================
   PANEL SYSTEM (TABS)
   ========================================================== */
.app-panel {
  display: none;
  animation: appleFadeIn 0.2s var(--ease-spring);
}

.app-panel.active {
  display: block;
}

@keyframes appleFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================
   CARDS & DASHBOARD WIDGETS (APPLE HIG)
   ========================================================== */
.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-header-title h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.025em;
}

.page-header-title p {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--apple-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s var(--ease-spring);
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.stat-icon.blue { background-color: var(--primary-subtle); color: var(--primary); }
.stat-icon.green { background-color: var(--success-bg); color: var(--success); }
.stat-icon.teal { background-color: var(--secondary-subtle); color: #0f766e; }
.stat-icon.purple { background-color: var(--purple-bg); color: var(--purple); }

.stat-info .stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.stat-info .stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 2px;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

@media (max-width: 1024px) {
  .dashboard-columns {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--apple-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--apple-card);
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-main);
}

.card-body {
  padding: 20px;
}

/* ==========================================================
   BUTTONS & APPLE-STYLE CONTROLS
   ========================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s var(--ease-spring);
  border: 1px solid transparent;
  outline: none;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 113, 227, 0.28);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.35);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-main);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background-color: #f5f5f7;
  border-color: rgba(0, 0, 0, 0.2);
}

.btn-teal {
  background-color: var(--secondary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 199, 190, 0.28);
}

.btn-teal:hover {
  background-color: var(--secondary-hover);
}

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

.btn-danger:hover {
  background-color: #e03228;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-icon-only {
  padding: 6px 9px;
  border-radius: 8px;
}

/* ==========================================================
   DATA TABLES (CLEAN MACOS STYLE)
   ========================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  background-color: #fbfbfd;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background-color 0.1s ease;
}

.data-table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.patient-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.patient-avatar-thumb {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-color);
  background-color: #e5e5ea;
}

.patient-name-title {
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.015em;
}

.patient-sub-details {
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* Apple Pills / Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.badge-info { background-color: var(--primary-subtle); color: var(--primary); }
.badge-success { background-color: var(--success-bg); color: var(--success); }
.badge-warning { background-color: var(--warning-bg); color: #c07000; }
.badge-purple { background-color: var(--purple-bg); color: var(--purple); }
.badge-danger { background-color: var(--danger-bg); color: var(--danger); }
.badge-teal { background-color: var(--secondary-subtle); color: #0f766e; }

/* ==========================================================
   SEARCH & FILTERS
   ========================================================== */
.search-filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input-box {
  flex: 1;
  min-width: 260px;
  position: relative;
}

.search-input-box input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  outline: none;
  background-color: #fbfbfd;
  color: var(--text-main);
  transition: all 0.15s ease;
}

.search-input-box input:focus {
  background-color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18);
}

.search-icon-pos {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ==========================================================
   BANNER DO PACIENTE (APPLE HEALTH PROFILE CARD)
   ========================================================== */
.clinical-patient-banner {
  background: linear-gradient(135deg, #0071e3 0%, #0056b3 100%);
  color: #ffffff;
  border-radius: var(--radius-xl);
  padding: 22px 28px;
  margin-bottom: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 25px rgba(0, 113, 227, 0.25);
  flex-wrap: wrap;
  gap: 18px;
}

.clinical-patient-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.clinical-patient-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  object-fit: cover;
  background-color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.clinical-patient-meta h2 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.clinical-age-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.clinical-patient-sub {
  font-size: 12.5px;
  opacity: 0.92;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ==========================================================
   SEGMENTED CONTROL APPLE (SUB-ABAS DO PRONTUÃRIO)
   O clÃ¡ssico seletor deslizado do iOS / macOS
   ========================================================== */
.clinical-subtabs-nav {
  display: inline-flex;
  background: #e5e5ea;
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 22px;
  gap: 4px;
  overflow-x: auto;
  max-width: 100%;
}

.subtab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #636366;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s var(--ease-spring);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.subtab-btn:hover {
  color: var(--text-main);
}

.subtab-btn.active {
  background: #ffffff;
  color: var(--text-main);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.subtab-panel {
  display: none;
  animation: appleFadeIn 0.2s var(--ease-spring);
}

.subtab-panel.active {
  display: block;
}

/* ==========================================================
   FORM CONTROLS & APPLE DESIGN
   ========================================================== */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .form-grid-2, .form-grid-3, .form-grid-4 {
    grid-template-columns: 1fr;
  }
}

.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background-color: #fbfbfd;
  color: var(--text-main);
  outline: none;
  font-family: inherit;
  transition: all 0.15s var(--ease-spring);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  background-color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18);
}

.form-group small {
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.calculated-age-box {
  background-color: #f5f5f7;
  border: 1px solid var(--border-color);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary);
}

/* Photo capture section in form */
.photo-upload-container {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px;
  background-color: #fbfbfd;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.photo-preview-box {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid #e5e5ea;
  flex-shrink: 0;
  background-color: #ffffff;
}

.photo-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-actions-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==========================================================
   MODAL DIALOGS (APPLE SHEET STYLE)
   ========================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(25px) saturate(180%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: appleBackdropFade 0.2s ease-out;
}

@keyframes appleBackdropFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-overlay.hidden,
.hidden {
  display: none !important;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: appleModalPop 0.25s var(--ease-spring);
}

@keyframes appleModalPop {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fbfbfd;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.modal-close-btn {
  background: #e5e5ea;
  border: none;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
  color: #636366;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: #d1d1d6;
  color: #1d1d1f;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background-color: #fbfbfd;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Modal Maximizado Ã  Tela */
.modal-dialog.modal-maximized {
  width: 98vw !important;
  max-width: 98vw !important;
  height: 94vh !important;
  max-height: 94vh !important;
  border-radius: var(--radius-lg) !important;
}

.modal-dialog.modal-maximized .modal-body {
  padding: 20px 26px;
  overflow-y: auto;
  flex: 1;
}

.modal-dialog.modal-maximized .exam-order-modal-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 26px;
}

@media (max-width: 992px) {
  .modal-dialog.modal-maximized .exam-order-modal-grid {
    grid-template-columns: 1fr;
  }
}

.modal-dialog.modal-maximized #order-exams-available-container,
.modal-dialog.modal-maximized #rx-order-available-container {
  max-height: calc(94vh - 360px) !important;
  min-height: 300px;
}

.modal-dialog.modal-maximized .exam-selected-list-box,
.modal-dialog.modal-maximized #rx-order-selected-items-list {
  max-height: calc(94vh - 360px) !important;
  min-height: 300px;
}

/* ==========================================================
   ESTILOS MAXIMIZADOS PARA PRESCRIÃÃES, ATESTADOS E RELATÃRIOS
   ========================================================== */
.clinical-maximized-card {
  width: 100%;
  background: var(--apple-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.clinical-editor-textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  outline: none;
  background-color: #fbfbfd;
  color: var(--text-main);
  box-sizing: border-box;
  resize: vertical;
  transition: all 0.15s var(--ease-spring);
}

.clinical-editor-textarea:focus {
  background-color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18);
}

/* Camera Modal Specifics */
.camera-video-wrapper {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 360px;
  margin: 0 auto 16px auto;
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: #000000;
}

.camera-video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-guide-circle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 220px;
  border: 2px dashed rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  pointer-events: none;
}

/* Timeline & Clinical History */
.timeline-list {
  position: relative;
  padding-left: 24px;
}

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

.timeline-item {
  position: relative;
  margin-bottom: 24px;
}

.timeline-bullet {
  position: absolute;
  left: -24px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--primary);
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 1px var(--border-color);
}

.timeline-content {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.timeline-date-author {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}

/* Sector Pills in Exam Order */
.sector-tab-pill {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.sector-tab-pill:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-main);
}

.sector-tab-pill.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 113, 227, 0.25);
}

.exam-checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 12.5px;
}

.exam-checkbox-card:hover {
  background: #fbfbfd;
  border-color: rgba(0, 0, 0, 0.18);
}

.exam-checkbox-card.selected {
  background: var(--primary-subtle);
  border-color: var(--primary);
}

.exam-selected-list-box {
  background: #fbfbfd;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exam-selected-tag-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 12px;
  box-shadow: var(--shadow-sm);
}

.exam-selected-tag-name {
  font-weight: 600;
  color: var(--text-main);
}

.exam-selected-tag-sector {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  margin-left: 6px;
  font-weight: 600;
}

/* ==========================================================
   PRINT STYLES FOR OFFICIAL MEDICAL DOCUMENTS
   Configurado em Folha A4 com Margens de 1 cm e RodapÃ© com TraÃ§o Simples
   ========================================================== */
#printable-area {
  display: none;
}

@page {
  size: A4 portrait;
  margin: 10mm; /* Margens default de 1 cm em todas as bordas */
}

@media print {
  body * {
    visibility: hidden;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #printable-area, #printable-area * {
    visibility: visible;
  }

  #printable-area {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  #document-preview-modal,
  .modal-overlay {
    display: none !important;
  }
}

/* ==========================================================
   ESTILOS DO VISUALIZADOR DA GUIA MÃDICA (ON-SCREEN & PRINT)
   ========================================================== */
#document-preview-modal .modal-dialog {
  max-width: 950px;
  width: 95vw;
}

#guide-preview-sheet {
  background: #ffffff;
  width: 210mm;
  min-height: 297mm;
  max-width: 100%;
  padding: 10mm;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  border-radius: 4px;
  box-sizing: border-box;
}

.medical-doc-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #0f172a;
    background: #ffffff;
    box-sizing: border-box;
    line-height: 1.4;
  }

  .doc-header {
    text-align: center;
    margin-bottom: 14px;
  }

  .clinic-title {
    font-size: 16pt;
    font-weight: bold;
    letter-spacing: 0.5px;
    color: #0f172a;
    margin-bottom: 3px;
  }

  .clinic-subtitle {
    font-size: 10.5pt;
    color: #475569;
    margin-bottom: 2px;
  }

  .clinic-address {
    font-size: 9pt;
    color: #64748b;
  }

  .doc-divider {
    border-bottom: 2px solid #0f172a;
    margin: 12px 0 16px 0;
  }

  .doc-badge-type {
    display: inline-block;
    padding: 3px 12px;
    font-size: 11pt;
    font-weight: bold;
    border: 1px solid #0f172a;
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .doc-patient-box {
    border: 1px solid #94a3b8;
    background-color: #f8fafc;
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 18px;
    font-size: 10.5pt;
    line-height: 1.5;
  }

  .patient-info-row {
    display: flex;
    justify-content: space-between;
  }

  .patient-info-row.secondary {
    margin-top: 4px;
    font-size: 9.5pt;
    color: #334155;
  }

  .rx-body {
    min-height: 250px;
    margin-bottom: 20px;
  }

  .rx-section-title {
    font-size: 11.5pt;
    font-weight: bold;
    margin-bottom: 12px;
    border-bottom: 1px dashed #94a3b8;
    padding-bottom: 4px;
    letter-spacing: 0.5px;
  }

  .rx-item {
    margin-bottom: 14px;
    page-break-inside: avoid;
  }

  .rx-item-header {
    display: flex;
    gap: 8px;
    font-weight: bold;
    font-size: 11pt;
  }

  .rx-item-name {
    flex: 1;
  }

  .rx-item-route {
    font-size: 9.5pt;
    font-weight: 700;
    color: #0284c7;
    margin-right: 6px;
  }

  .rx-item-qty {
    font-style: italic;
    font-size: 10pt;
  }

  .rx-item-dosage {
    margin-left: 20px;
    margin-top: 3px;
    font-size: 10pt;
    color: #334155;
  }

  .rx-general-notes {
    margin-top: 18px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
    font-size: 9.5pt;
  }

  .doc-center-title {
    text-align: center;
    margin: 20px 0 24px 0;
  }

  .doc-center-title h2 {
    font-size: 15pt;
    letter-spacing: 1px;
    text-decoration: underline;
  }

  .certificate-body, .report-body {
    font-size: 11pt;
    line-height: 1.8;
    text-align: justify;
    min-height: 250px;
  }

  .cert-text {
    text-indent: 32px;
    margin-bottom: 16px;
  }

  .cert-cid-box {
    margin: 16px 0;
    padding: 8px 12px;
    border: 1px dashed #64748b;
    font-size: 10pt;
    background-color: #f8fafc;
  }

  .cert-date-location {
    text-align: right;
    margin-top: 24px;
    font-size: 10.5pt;
  }

  /* RodapÃ© Oficial Padronizado com TraÃ§ado ContÃ­nuo Simples Superior */
  .doc-footer {
    margin-top: 24px;
    padding-top: 14px;
    border-top: 1px solid #000000; /* TraÃ§ado contÃ­nuo simples na parte superior */
    display: flex;
    flex-direction: column;
    align-items: center;
    page-break-inside: avoid;
    width: 100%;
    box-sizing: border-box;
  }

  .signature-box {
    text-align: center;
    width: 320px;
  }

  .signature-line {
    border-top: 1px solid #000000;
    margin-bottom: 6px;
  }

  .doctor-signature-name {
    font-weight: bold;
    font-size: 11pt;
  }

  .doctor-signature-crm {
    font-size: 9.5pt;
    color: #334155;
  }

  .doctor-signature-spec {
    font-size: 9pt;
    color: #475569;
  }

  .doc-bottom-note {
    margin-top: 8px;
    font-size: 8pt;
    color: #64748b;
    text-align: center;
  }

  .clinic-establishment-footer {
    width: 100%;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #000000; /* TraÃ§ado contÃ­nuo simples */
    text-align: center;
    font-size: 8pt;
    color: #334155;
    line-height: 1.4;
    page-break-inside: avoid;
  }

  .clinic-est-name {
    font-weight: bold;
    color: #0f172a;
    font-size: 9pt;
    margin-bottom: 2px;
  }

  .clinic-est-legal {
    margin-top: 4px;
    font-size: 7.5pt;
    color: #64748b;
  }

  /* Full record print */
  .patient-dossier-header {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid #cbd5e1;
    padding-bottom: 14px;
  }

  .dossier-photo img {
    width: 90px;
    height: 90px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
  }

  .dossier-info h2 {
    font-size: 13pt;
    margin-bottom: 4px;
  }

  .dossier-info p {
    font-size: 9.5pt;
    line-height: 1.45;
  }

  .dossier-section {
    margin-bottom: 20px;
    page-break-inside: avoid;
  }

  .dossier-section h2 {
    font-size: 11pt;
    background-color: #f1f5f9;
    padding: 4px 8px;
    border-left: 4px solid #1e40af;
    margin-bottom: 10px;
  }

  .record-print-block {
    margin-bottom: 14px;
    border-bottom: 1px dotted #e2e8f0;
    padding-bottom: 10px;
    font-size: 10pt;
  }

  .danger-badge-text {
    color: #b91c1c;
    font-weight: bold;
  }

  /* GUIA DE REQUISIÃÃO DE EXAMES LABORATORIAIS */
  .exam-order-doc {
    line-height: 1.35;
  }

  .exam-indication-box {
    border: 1px solid #94a3b8;
    background-color: #f8fafc;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 10pt;
  }

  .indication-title {
    font-weight: bold;
    font-size: 9.5pt;
    color: #0f172a;
    margin-bottom: 2px;
    letter-spacing: 0.5px;
  }

  .indication-content {
    color: #1e293b;
  }

  .badge-urgency {
    display: inline-block;
    color: #b91c1c;
    font-weight: bold;
    margin-left: 8px;
  }

  .order-section-headline {
    font-size: 10.5pt;
    font-weight: bold;
    color: #0f172a;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 3px;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
  }

  .exam-order-sector-box {
    margin-bottom: 14px;
    page-break-inside: avoid;
  }

  .exam-sector-header {
    background-color: #f1f5f9;
    padding: 4px 8px;
    border-left: 4px solid #0d9488;
    font-weight: bold;
    font-size: 9.5pt;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
  }

  .exam-sector-items {
    padding-left: 12px;
  }

  .exam-order-item {
    display: flex;
    gap: 6px;
    font-size: 10pt;
    margin-bottom: 4px;
    line-height: 1.3;
  }

  .exam-order-num {
    font-weight: bold;
    min-width: 20px;
  }

  .exam-order-details {
    flex: 1;
  }

  .exam-order-name {
    font-weight: bold;
    color: #0f172a;
  }

  .exam-order-mat {
    font-size: 9pt;
    color: #475569;
    font-style: italic;
    margin-left: 4px;
  }

  .exam-order-notes {
    margin-top: 16px;
    padding: 8px 12px;
    border: 1px dashed #cbd5e1;
    font-size: 9pt;
    color: #334155;
    page-break-inside: avoid;
  }

/* ============================================================
   MODO CONSULTA - USUÁRIO OUTROS (SEM EDIÇÃO)
   ============================================================ */
body.role-viewer button[type="submit"],
body.role-viewer .btn-primary:not([onclick*="print"]):not([onclick*="Print"]):not([onclick*="close"]):not([onclick*="Close"]),
body.role-viewer button[onclick*="delete"],
body.role-viewer button[onclick*="Delete"],
body.role-viewer .action-btn-delete,
body.role-viewer .btn-danger,
body.role-viewer #btn-quick-new-patient {
  pointer-events: none !important;
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}

body.role-viewer .action-btn-edit {
  display: none !important;
}


/* ==========================================================
   CONTROLE DE ACESSO BASEADO EM FUNÇÕES (RBAC - CFM / LGPD)
   APPLE HUMAN INTERFACE GUIDELINES
   ========================================================== */

/* Cápsula de Sessão do Usuário na Barra Superior */
.user-session-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  padding: 4px 10px 4px 6px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s var(--ease-spring);
  user-select: none;
}

.user-session-pill:hover {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(0, 113, 227, 0.15);
  transform: translateY(-1px);
}

.user-avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.user-session-details {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.user-session-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.user-role-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
  display: inline-block;
  margin-top: 1px;
}

.btn-switch-session {
  background: rgba(0, 0, 0, 0.05);
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: 2px;
}

.user-session-pill:hover .btn-switch-session {
  background: var(--primary);
  color: #ffffff;
}

/* Indicadores de Restrição na Barra Lateral */
.nav-item.nav-restricted {
  opacity: 0.42;
  cursor: not-allowed;
  position: relative;
}

.nav-item.nav-restricted:hover {
  background: transparent;
  color: var(--text-secondary);
}

.nav-item.nav-restricted::after {
  content: "🔒";
  position: absolute;
  right: 14px;
  font-size: 11px;
  opacity: 0.8;
}

/* Badges RBAC */
.badge-purple {
  background: rgba(175, 82, 222, 0.12);
  color: #7c3aed;
  border: 1px solid rgba(175, 82, 222, 0.35);
}

/* Matriz de Permissões RBAC */
.rbac-matrix-table th,
.rbac-matrix-table td {
  padding: 12px 14px !important;
  font-size: 12px;
}

.rbac-matrix-table tbody tr:hover {
  background: rgba(0, 113, 227, 0.02);
}

/* Botões de Acesso Rápido de Login */
.quick-login-btn {
  transition: all 0.2s var(--ease-spring);
  cursor: pointer;
}

.quick-login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  filter: brightness(1.05);
}

/* Regras Estritas de Escopo por Perfil (CSS Scoping) */

/* Secretaria: Bloqueio estrito de áreas médicas (CFM 1.821 & LGPD) */
body.role-secretaria #nav-clinical-record,
body.role-secretaria [data-panel="panel-clinical-record"].nav-item {
  opacity: 0.35;
  cursor: not-allowed;
}

body.role-secretaria #select-active-doctor {
  pointer-events: auto;
}

/* Administrativo: Bloqueio de prescrição médica */
body.role-administrativo #btn-prescribe-rx,
body.role-administrativo #btn-new-certificate {
  display: none !important;
}
