/* Console administrativo — layout de painel (decisão D14: sem modo acessível; não é usado com eye tracking).
   Usa os tokens de marca do extensia.css (espelhado com o apps-app) e ajusta tamanhos para uso com mouse. */

:root {
  --touch: 40px;
  --touch-huge: 44px;
  --touch-icon: 36px;
  --btn-gap: 8px;
  --sidebar: 248px;
  --line: var(--gray-200);
}

body { background: #f5f7f7; }
.btn { min-height: var(--touch); padding: 0 16px; border-radius: 10px; font-size: .92rem; font-weight: 700; gap: 8px; }
.btn:hover { transform: none; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: .85rem; }
.btn-primary { box-shadow: none; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--teal-900); }
.btn-ghost:hover { background: var(--bg-alt); border-color: var(--teal-500); }
.btn-danger-solid { background: var(--error); color: #fff; }
.btn-danger-solid:hover { background: #b83737; }
.btn-link { background: none; border: 0; color: var(--teal-700); padding: 0 6px; min-height: 32px; font-weight: 700; }
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--error); }
.btn-link[disabled] { color: var(--ink-600); text-decoration: none; }

/* ---------- Estrutura: menu lateral + conteúdo ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100dvh; }
.sidebar { background: var(--teal-900); color: #fff; display: flex; flex-direction: column; gap: 8px; padding: 18px 14px; position: sticky; top: 0; height: 100dvh; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.05rem; padding: 4px 6px 14px; }
.brand img { height: 30px; background: #fff; border-radius: 8px; padding: 3px 6px; }
.menu-toggle { display: none; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: 6px 10px; font: inherit; cursor: pointer; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: rgba(255,255,255,.82); text-decoration: none; font-weight: 600; font-size: .94rem; }
.side-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-nav a.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 0 var(--orange-500); }
.side-nav .ico { width: 22px; text-align: center; }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.15); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.side-foot .who { display: flex; flex-direction: column; min-width: 0; }
.side-foot .who strong { color: #fff; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .who span { color: rgba(255,255,255,.65); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.main { padding: 24px clamp(16px, 3vw, 40px) 48px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 1.55rem; }
.subtitle { margin: 4px 0 0; color: var(--ink-600); font-size: .92rem; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: .85rem; color: var(--ink-600); margin-bottom: 4px; }
.crumbs a { color: var(--teal-700); text-decoration: none; font-weight: 600; }
.crumbs a:hover { text-decoration: underline; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.alert { padding: 10px 14px; border-radius: 10px; font-weight: 600; font-size: .92rem; }
.alert-error { background: var(--error-bg); color: var(--error); border: 1px solid #f3c2c2; }
.alert-ok { background: #e7f4ec; color: #1f6b43; border: 1px solid #bfe3cd; }

/* ---------- Painéis, tabelas e barra de filtros ---------- */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 2px rgba(0,56,56,.04); }
.panel-pad { padding: 20px 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { font-size: 1.05rem; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.toolbar .input { min-height: 38px; padding: 6px 12px; border-radius: 10px; border-width: 1px; width: auto; }
.toolbar .search { flex: 1; min-width: 220px; max-width: 420px; }
.toolbar .count { margin-left: auto; color: var(--ink-600); font-size: .88rem; }
.table-wrap { overflow-x: auto; position: relative; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-600); font-weight: 800; padding: 10px 16px; background: var(--bg-alt); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafcfc; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table .muted-cell { color: var(--ink-600); }
.table .truncate { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .84rem; background: var(--bg-alt); padding: 2px 6px; border-radius: 6px; }
.empty-state { padding: 36px 20px; text-align: center; color: var(--ink-600); }
.role { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.role-paciente { background: var(--teal-100); color: var(--teal-900); }
.role-medica { background: var(--orange-100); color: #9a4310; }
.role-admin { background: #ece8f7; color: #4b3a8f; }
.tag { font-size: .72rem; font-weight: 800; color: var(--teal-700); background: var(--teal-100); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }

/* ---------- Formulários (telas de cadastro/edição) ---------- */
.form-panel { max-width: 760px; }
.form-grid { display: grid; gap: 18px; padding: 22px; }
.form-grid .field label, .form-grid .field .label { font-size: .88rem; font-weight: 700; color: var(--teal-900); }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row .field { min-width: 120px; }
.hint.example { margin: 2px 0 0; padding: 8px 12px; background: var(--bg-alt); border-radius: 8px; font-style: italic; }
.tag-custom { background: var(--orange-100); color: #9a4310; }
.form-grid .input { min-height: 42px; border-width: 1px; border-radius: 10px; padding: 8px 12px; }
.form-grid textarea.input { min-height: 110px; }
.hint { font-size: .82rem; color: var(--ink-600); }
.form-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); background: var(--bg-alt); border-radius: 0 0 14px 14px; }
.role-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.role-option { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: #fff; }
.role-option:has(input:checked) { border-color: var(--teal-500); box-shadow: 0 0 0 3px var(--teal-100); }
.role-option input { margin-top: 3px; accent-color: var(--teal-700); }
.role-option strong { display: block; font-size: .92rem; }
.role-option span { font-size: .8rem; color: var(--ink-600); }
.role-option.disabled { opacity: .6; cursor: not-allowed; }

/* ---------- Início ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; text-decoration: none; color: inherit; }
.kpi .num { font-size: 2rem; font-weight: 800; color: var(--teal-900); line-height: 1.1; }
.kpi .lbl { color: var(--ink-600); font-weight: 600; font-size: .9rem; }
a.kpi:hover { border-color: var(--teal-500); }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.quick a { display: flex; gap: 12px; align-items: flex-start; padding: 16px 18px; text-decoration: none; color: inherit; }
.quick a:hover { border-color: var(--teal-500); }
.quick .ico { font-size: 1.4rem; }
.quick strong { display: block; color: var(--teal-900); }
.quick span { font-size: .85rem; color: var(--ink-600); }

/* ---------- Janela de confirmação ---------- */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(0, 30, 30, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.dialog { background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); width: min(460px, 100%); padding: 22px; display: flex; flex-direction: column; gap: 10px; animation: pop .15s; }
.dialog h2 { font-size: 1.15rem; }
.dialog p { margin: 0; color: var(--ink-600); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ---------- Telas pequenas: menu vira barra no topo ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { position: static; height: auto; padding: 12px 16px; }
  .brand { padding-bottom: 0; }
  .menu-toggle { display: inline-flex; }
  .side-nav, .side-foot { display: none; }
  .sidebar.open .side-nav, .sidebar.open .side-foot { display: flex; }
  .role-options { grid-template-columns: 1fr; }
  .table .hide-sm { display: none; }
}

/* Celular: cada linha da tabela vira um cartão (sem rolagem lateral). */
@media (max-width: 700px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { padding: 2px 0; border: 0; }
  .table tbody tr:hover td { background: none; }
  .table .actions { text-align: left; width: auto; padding-top: 6px; }
  .table .actions .btn-link:first-child { padding-left: 0; }
  .table .truncate { max-width: none; white-space: normal; }
}
.hint a { color: var(--teal-700); font-weight: 700; }
