/* ════════════════════════════════════════════════
   SISTEMA SAÚDE MULTIDISCIPLINAR — ESTILOS GLOBAIS
   BR HELPDESK © 2024
   ════════════════════════════════════════════════ */

:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --bg-app: #f0f4f8;
  --sidebar-w: 260px;
  --header-h: 60px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

/* ── Gradiente de fundo Login ── */
.bg-gradient-primary {
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 40%, #2563eb 100%);
  min-height: 100vh;
}

.text-white-75  { color: rgba(255,255,255,.75); }
.text-white-50  { color: rgba(255,255,255,.5); }

/* ── Container de Login ── */
.login-container {
  width: 100%;
  max-width: 400px;
  padding: 1.5rem;
}

.logo-icon {
  width: 72px;
  height: 72px;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: white;
  margin: 0 auto;
  backdrop-filter: blur(10px);
}

/* ── Layout App ── */
body.app-body {
  background: var(--bg-app);
  overflow-x: hidden;
}

/* SIDEBAR */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: white;
  border-right: 1px solid #e2e8f0;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  transition: transform .3s ease;
  display: flex;
  flex-direction: column;
}

#sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); }

.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: var(--header-h);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-brand { font-weight: 700; font-size: .95rem; line-height: 1.2; color: #1e293b; }
.sidebar-sub   { font-size: .7rem; color: #64748b; }

.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }

.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #94a3b8;
  padding: .75rem 1.25rem .25rem;
}

.nav-item { margin: 0 .5rem .1rem; }

.nav-link {
  border-radius: 8px;
  padding: .6rem .875rem;
  color: #475569;
  font-size: .875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: .625rem;
  transition: all .15s;
}

.nav-link:hover { background: #f1f5f9; color: var(--primary); }
.nav-link.active { background: #eff6ff; color: var(--primary); font-weight: 600; }
.nav-link i { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
  border-top: 1px solid #e2e8f0;
  padding: .875rem 1rem;
}

/* TOPBAR */
#topbar {
  height: var(--header-h);
  background: white;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 900;
}

#topbar .page-title { font-weight: 600; font-size: 1rem; color: #1e293b; margin: 0; }

/* MAIN CONTENT */
#main-content {
  margin-left: var(--sidebar-w);
  transition: margin .3s ease;
  min-height: 100vh;
}

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

.content-area { padding: 1.5rem; }

/* CARDS */
.card { border: 1px solid #e2e8f0; border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: white; border-bottom: 1px solid #f1f5f9; padding: 1rem 1.25rem; }

/* KPI cards */
.kpi-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow);
}
.kpi-value { font-size: 2rem; font-weight: 700; color: #1e293b; line-height: 1; }
.kpi-label { font-size: .8rem; color: #64748b; margin-top: .25rem; }
.kpi-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}

/* STATUS BADGES */
.badge-draft     { background: #f1f5f9; color: #475569; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-signed    { background: #dbeafe; color: #1e40af; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

/* FORMULÁRIO DE ATENDIMENTO */
.form-section {
  background: white;
  border-radius: var(--radius);
  border: 1px solid #e2e8f0;
  margin-bottom: 1rem;
  overflow: hidden;
}

.form-section-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: .75rem 1.125rem;
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #334155;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-section-body { padding: 1rem 1.125rem; }

/* CHECKBOXES EM GRADE */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .4rem;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background .1s;
}

.checkbox-item:hover { background: #f0f9ff; }
.checkbox-item input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
.checkbox-item label { font-size: .82rem; color: #374151; cursor: pointer; margin: 0; }

/* ASSINATURA CANVAS */
.signature-canvas-wrap {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  background: #fafafa;
  position: relative;
  cursor: crosshair;
  touch-action: none;
}

.signature-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 160px;
  border-radius: 8px;
}

.signature-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #94a3b8;
  font-size: .85rem;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
}

.signature-signed { border-color: #10b981; border-style: solid; background: #f0fdf4; }

/* TABELAS */
.table-responsive { border-radius: var(--radius); overflow: hidden; }
.table thead th { background: #f8fafc; border-bottom: 2px solid #e2e8f0; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #64748b; white-space: nowrap; }
.table tbody tr:hover { background: #f8fafc; }
.table td { vertical-align: middle; font-size: .875rem; }

/* MOBILE */
@media (max-width: 768px) {
  #sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  #sidebar.mobile-open { transform: translateX(0); box-shadow: var(--shadow-md); }
  #main-content { margin-left: 0 !important; }
  .content-area { padding: 1rem; }
  .checkbox-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 1.5rem; }
  #sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 999;
  }
  #sidebar-overlay.show { display: block; }
}

/* OVERLAY sidebar móvel */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 999;
}
#sidebar-overlay.show { display: block; }

/* PROFISSÃO BADGE */
.prof-badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  gap: .3rem;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }

/* IMPRESSÃO / RELATÓRIO */
@media print {
  #sidebar, #topbar, .no-print { display: none !important; }
  #main-content { margin-left: 0 !important; }
  .form-section { break-inside: avoid; }
}

/* TOAST */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; }

/* Spinner page */
.page-loader {
  position: fixed; inset: 0;
  background: white;
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}

/* REPORT PDF preview */
.report-card {
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
  box-shadow: var(--shadow-md);
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #e2e8f0;
}

.report-section { margin-bottom: 1.25rem; }
.report-section h6 {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #64748b;
  margin-bottom: .5rem;
  padding-bottom: .25rem;
  border-bottom: 1px solid #f1f5f9;
}

.report-field { display: flex; gap: .5rem; margin-bottom: .3rem; font-size: .875rem; }
.report-field strong { color: #374151; min-width: 180px; }
.report-field span { color: #1e293b; }

.signature-preview img {
  max-height: 80px;
  max-width: 200px;
  border-bottom: 1px solid #1e293b;
  padding-bottom: .25rem;
}
