/* ============================================================
   ClinMaster — Tema Vitalità Clínica
   Cores: Branco #ffffff | Verde #2eaa6e | Lilás #8b5ca8
   Dalantec Sistemas | Deris Araújo
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ------------------------------------------------------------
   VARIÁVEIS
   ------------------------------------------------------------ */
:root {
  --primary:       #2eaa6e;
  --primary-dark:  #238a58;
  --primary-light: #e8f7f0;

  --accent:        #8b5ca8;
  --accent-dark:   #6d4688;
  --accent-light:  #f3edf8;

  --danger:        #ef4444;
  --warning:       #f59e0b;
  --info:          #3b82f6;

  --bg:            #f4f7f5;
  --surface:       #ffffff;
  --surface2:      #f8faf9;
  --border:        #e2ebe6;
  --border-strong: #c8ddd2;

  --text:          #1a2e25;
  --text-muted:    #5a7a68;
  --text-light:    #94b5a4;

  --sidebar-w:     255px;
  --sidebar-bg:    #ffffff;
  --sidebar-border:#e2ebe6;
  --sidebar-hover: #f0faf5;
  --sidebar-active-bg: #e8f7f0;
  --sidebar-active-text: #2eaa6e;

  --radius:        10px;
  --radius-lg:     14px;
  --shadow:        0 1px 4px rgba(46,170,110,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 4px 16px rgba(46,170,110,.12);
  --shadow-lg:     0 10px 40px rgba(0,0,0,.10);

  --font:          'Plus Jakarta Sans', sans-serif;
  --font-mono:     'JetBrains Mono', monospace;
  --transition:    all .18s ease;
}

/* ------------------------------------------------------------
   RESET / BASE
   ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* ------------------------------------------------------------
   LAYOUT PRINCIPAL
   ------------------------------------------------------------ */
.cm-layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.cm-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .3s ease;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c8ddd2 transparent;
}
.cm-sidebar::-webkit-scrollbar { width: 4px; }
.cm-sidebar::-webkit-scrollbar-track { background: transparent; }
.cm-sidebar::-webkit-scrollbar-thumb { background: #c8ddd2; border-radius: 2px; }

/* Logo */
.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo img {
  max-height: 52px;
  max-width: 185px;
  object-fit: contain;
}
.sidebar-logo .logo-text {
  font-size: 21px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.5px;
}
.sidebar-logo .logo-text span { color: var(--primary); }
.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-top: 2px;
}

/* Nav */
.sidebar-nav { padding: 14px 12px; flex: 1; }

.nav-section-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-light);
  padding: 8px 10px 4px;
  margin-top: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: var(--transition);
  cursor: pointer;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--primary);
}
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 700;
  border-left: 3px solid var(--primary);
}
.nav-item .nav-icon { width: 17px; height: 17px; flex-shrink: 0; }

/* Footer sidebar */
.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1px solid var(--border);
}
.sidebar-user .user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 11px; color: var(--text-muted); }

/* CONTEÚDO PRINCIPAL */
.cm-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* TOPBAR */
.cm-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); }
.topbar-breadcrumb { font-size: 12px; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.topbar-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
  transition: var(--transition);
  position: relative;
}
.topbar-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.badge-notif {
  position: absolute; top: -3px; right: -3px;
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.cm-content { padding: 26px; flex: 1; }

/* ------------------------------------------------------------
   CARDS
   ------------------------------------------------------------ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-size: 14.5px; font-weight: 700; color: var(--text); }
.card-body  { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* STAT CARDS */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
  width: 50px; height: 50px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.green  { background: var(--primary-light); color: var(--primary); }
.stat-icon.purple { background: var(--accent-light);  color: var(--accent); }
.stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon.yellow { background: #fef3c7; color: #d97706; }
.stat-icon.red    { background: #fee2e2; color: #dc2626; }
.stat-icon.teal   { background: #ccfbf1; color: #0d9488; }

.stat-info .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-info .stat-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1.2; }
.stat-info .stat-sub   { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* ------------------------------------------------------------
   TABELAS
   ------------------------------------------------------------ */
.table-wrapper { overflow-x: auto; }
table.cm-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.cm-table thead th {
  background: var(--surface2);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.cm-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.cm-table tbody tr:last-child td { border-bottom: none; }
.cm-table tbody tr:hover td { background: var(--primary-light); }

/* ------------------------------------------------------------
   FORMULÁRIOS
   ------------------------------------------------------------ */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 12.5px; font-weight: 600;
  color: var(--text); margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control, .form-select {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px; font-family: var(--font);
  color: var(--text); background: var(--surface);
  transition: var(--transition); outline: none;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46,170,110,.12);
}
textarea.form-control { resize: vertical; min-height: 90px; }
.form-control.error { border-color: var(--danger); }
.form-hint  { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 11.5px; color: var(--danger);     margin-top: 4px; }

.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ------------------------------------------------------------
   BOTÕES
   ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius);
  font-size: 13.5px; font-family: var(--font); font-weight: 600;
  cursor: pointer; border: none; outline: none;
  transition: var(--transition); white-space: nowrap; text-decoration: none;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-success { background: var(--primary); color: #fff; }
.btn-success:hover { background: var(--primary-dark); color: #fff; }

.btn-accent  { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); color: #fff; }

.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; color: #fff; }

.btn-secondary {
  background: var(--surface); color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--primary-light); color: var(--primary); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------
   BADGES
   ------------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600;
}
.bg-green-100  { background: var(--primary-light); }
.text-green-700 { color: var(--primary-dark); }
.bg-blue-100  { background: #dbeafe; }
.text-blue-700 { color: #1d4ed8; }
.bg-yellow-100 { background: #fef3c7; }
.text-yellow-700{ color: #b45309; }
.bg-red-100   { background: #fee2e2; }
.text-red-700  { color: #b91c1c; }
.bg-slate-100  { background: #f1f5f9; }
.text-slate-700 { color: #475569; }
.bg-orange-100 { background: #ffedd5; }
.text-orange-700{ color: #c2410c; }
.bg-purple-100 { background: var(--accent-light); }
.text-purple-700{ color: var(--accent-dark); }

/* ------------------------------------------------------------
   ALERTAS
   ------------------------------------------------------------ */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}
.alert-success { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #b6e8d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ------------------------------------------------------------
   MODAL
   ------------------------------------------------------------ */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(26,46,37,.45);
  z-index: 200;
  align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  animation: modalIn .2s ease;
  border: 1px solid var(--border);
}
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(-8px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px; border-radius: 6px;
  transition: var(--transition);
}
.modal-close:hover { background: var(--primary-light); color: var(--primary); }
.modal-body   { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  background: var(--surface2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ------------------------------------------------------------
   PÁGINA DE LOGIN
   ------------------------------------------------------------ */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  position: relative;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 44px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-logo { text-align: center; margin-bottom: 36px; }
.login-logo img { max-height: 64px; max-width: 220px; object-fit: contain; }
.login-logo .logo-name { font-size: 30px; font-weight: 800; color: var(--text); letter-spacing: -1px; }
.login-logo .logo-name span { color: var(--primary); }
.login-logo .logo-tag {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 2px; margin-top: 2px;
}

.login-card .form-label { color: var(--text); }
.login-card .form-control { background: var(--surface); border-color: var(--border); color: var(--text); }
.login-card .form-control:focus { border-color: var(--primary); }
.login-footer { text-align: center; margin-top: 28px; font-size: 11.5px; color: var(--text-light); }

/* Decoração lateral login */
.login-page::before {
  content: '';
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: var(--primary);
}
.login-page::after {
  content: '';
  position: fixed;
  left: 6px; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}

/* ------------------------------------------------------------
   AGENDA
   ------------------------------------------------------------ */
.agenda-event {
  background: var(--primary);
  color: #fff; border-radius: 4px;
  padding: 2px 6px; font-size: 11px; font-weight: 500;
  margin-bottom: 2px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.agenda-event.confirmado { background: var(--primary-dark); }
.agenda-event.realizado  { background: #64748b; }
.agenda-event.cancelado  { background: var(--danger); }
.agenda-event.falta      { background: var(--warning); }
.agenda-event.agendado   { background: var(--accent); }

.time-slot {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 6px;
  transition: var(--transition);
}
.time-slot:hover { border-color: var(--primary); background: var(--primary-light); }
.time-slot .slot-time { font-size: 13px; font-weight: 700; color: var(--primary); font-family: var(--font-mono); min-width: 50px; }
.time-slot .slot-info { flex: 1; }
.time-slot .slot-paciente { font-weight: 600; font-size: 13.5px; }
.time-slot .slot-tipo { font-size: 11.5px; color: var(--text-muted); }

/* ------------------------------------------------------------
   PRONTUÁRIO
   ------------------------------------------------------------ */
.prontuario-header {
  background: var(--text);
  color: #fff; padding: 24px 30px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* ------------------------------------------------------------
   RESPONSIVO
   ------------------------------------------------------------ */
@media (max-width: 1024px) {
  .cm-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .cm-sidebar.open { transform: translateX(0); }
  .cm-main { margin-left: 0; }
  .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .cm-content { padding: 16px; }
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
  .cm-topbar { padding: 0 16px; }
  .login-card { padding: 32px 24px; }
}

/* ------------------------------------------------------------
   UTILITÁRIOS
   ------------------------------------------------------------ */
.flex   { display: flex; }
.flex-1 { flex: 1; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1  { margin-top: 4px; }
.mt-2  { margin-top: 8px; }
.mt-4  { margin-top: 16px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.text-sm    { font-size: 12.5px; }
.text-muted { color: var(--text-muted); }
.font-bold  { font-weight: 700; }
.w-full     { width: 100%; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.grid   { display: grid; }
.cols-4 { grid-template-columns: repeat(4,1fr); gap: 18px; }
.cols-3 { grid-template-columns: repeat(3,1fr); gap: 18px; }
.cols-2 { grid-template-columns: repeat(2,1fr); gap: 18px; }

@media (max-width: 900px) {
  .cols-4, .cols-3 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 580px) {
  .cols-4, .cols-3, .cols-2 { grid-template-columns: 1fr; }
}

/* Tooltip */
[data-tip] { position: relative; cursor: help; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: 110%; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff;
  padding: 4px 10px; border-radius: 6px;
  font-size: 12px; white-space: nowrap; z-index: 999; pointer-events: none;
}

/* Spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Divider */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* Avatar */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; background: var(--primary-light);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: var(--primary); flex-shrink: 0;
}

/* Barra lateral colorida nos cards de destaque */
.card-accent-green { border-left: 4px solid var(--primary); }
.card-accent-purple { border-left: 4px solid var(--accent); }

/* Print */
@media print {
  .cm-sidebar, .cm-topbar, .no-print { display: none !important; }
  .cm-main { margin-left: 0; }
  .cm-content { padding: 0; }
  .card { border: none; box-shadow: none; }
}
