/* ======================================================================
   PharmaBot — Super Admin · Design System
   ====================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: 'Plus Jakarta Sans', sans-serif;
  --ink: #0A1628;
  --ink-2: #0F2040;
  --surface: #111D2E;
  --surface-2: #162337;
  --border: rgba(255,255,255,.08);
  --leaf: #54BD45;
  --leaf-bright: #78DB5C;
  --leaf-dark: #3da030;
  --muted: #6B8299;
  --text: #E8F0F8;
  --radius: 12px;
  --sidebar-w: 240px;
}

body {
  font-family: var(--font);
  background: var(--ink);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1d3149; border-radius: 9px; }
::-webkit-scrollbar-thumb:hover { background: #274265; }

a { color: inherit; }

/* ── Animações globais ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { 0% { background-position: -1000px 0; } 100% { background-position: 1000px 0; } }
@keyframes pulseRow { 0%,100% { background: rgba(84,189,69,.16); } 50% { background: rgba(84,189,69,.30); } }
@keyframes ripple-anim { to { transform: scale(2.6); opacity: 0; } }
@keyframes gradientShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

/* ====================================================================
   Sidebar
   ==================================================================== */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--ink-2) 0%, var(--ink) 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 60;
  transition: transform .28s ease;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo img { height: 36px; }
.sidebar-logo .brand { font-size: 13px; font-weight: 800; letter-spacing: .5px; }
.sidebar-logo .brand small { display: block; font-size: 10px; font-weight: 700; color: var(--leaf); text-transform: uppercase; letter-spacing: 1.5px; }

.nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  color: var(--muted); text-decoration: none;
  font-size: 14px; font-weight: 600;
  transition: background .15s ease, color .15s ease;
}
.nav a .nav-ic { font-size: 17px; width: 22px; text-align: center; filter: grayscale(.4); transition: filter .15s; }
.nav a:hover { background: rgba(255,255,255,.05); color: var(--text); }
.nav a:hover .nav-ic { filter: grayscale(0); }
.nav a.active { background: rgba(84,189,69,.14); color: var(--leaf-bright); }
.nav a.active .nav-ic { filter: grayscale(0); }

.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.sf-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px 12px; }
.sf-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; color: #06231a;
  background: linear-gradient(135deg, var(--leaf-bright), var(--leaf-dark));
}
.sf-info { min-width: 0; }
.sf-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sf-email { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sf-logout {
  width: 100%; padding: 10px; border-radius: 9px; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  font-family: var(--font); font-size: 13px; font-weight: 700; transition: all .15s;
}
.sf-logout:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }

/* Overlay (mobile) */
.sb-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 55; }
.sb-overlay.show { display: block; }

/* ====================================================================
   Main + Topbar
   ==================================================================== */
.main { margin-left: var(--sidebar-w); min-height: 100vh; animation: fadeIn .3s ease both; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 30px; background: rgba(10,22,40,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.hamburger {
  display: none; background: transparent; border: 1px solid var(--border);
  color: var(--text); width: 38px; height: 38px; border-radius: 9px; cursor: pointer; font-size: 18px;
}
.breadcrumb { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--leaf-bright); }
.breadcrumb .sep { margin: 0 8px; opacity: .5; }
.breadcrumb .cur { color: var(--text); }

.topbar-right { display: flex; align-items: center; gap: 12px; }

/* Sino de notificações */
.notif { position: relative; }
.notif-bell {
  position: relative; width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  font-size: 18px; display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.notif-bell:hover { background: #1d3047; }
.notif-count {
  position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 10px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 800;
  display: none; align-items: center; justify-content: center; border: 2px solid var(--ink);
}
.notif-dropdown {
  position: absolute; right: 0; top: 50px; width: 340px; max-height: 420px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5); padding: 8px; z-index: 80;
  display: none; animation: fadeUp .18s ease both;
}
.notif-dropdown.show { display: block; }
.notif-head { padding: 10px 12px 8px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.notif-item { display: flex; gap: 10px; padding: 11px 12px; border-radius: 10px; cursor: pointer; transition: background .15s; }
.notif-item:hover { background: rgba(255,255,255,.05); }
.notif-ic { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.notif-body { min-width: 0; }
.notif-msg { font-size: 13px; line-height: 1.4; }
.notif-farm { font-size: 12px; color: var(--leaf-bright); font-weight: 700; margin-top: 2px; }
.notif-empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 13px; }

/* ====================================================================
   Conteúdo
   ==================================================================== */
.wrap { padding: 30px; max-width: 1240px; margin: 0 auto; }
.page-title { font-size: 23px; font-weight: 800; letter-spacing: -.3px; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 6px; margin-bottom: 28px; }
.title-row { display: flex; align-items: center; gap: 10px; }
.title-badge { display: none; background: #ef4444; color: #fff; font-size: 13px; font-weight: 800; padding: 2px 10px; border-radius: 20px; }

/* ── Cards de métrica ── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 30px; }
.metric {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  display: flex; align-items: center; gap: 16px; transition: transform .15s ease, box-shadow .15s ease;
}
.metric:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(0,0,0,.28); }
.metric-ic {
  width: 50px; height: 50px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  background: rgba(84,189,69,.12);
}
.metric.blue   .metric-ic { background: rgba(59,130,246,.14); }
.metric.amber  .metric-ic { background: rgba(245,158,11,.14); }
.metric.purple .metric-ic { background: rgba(139,92,246,.14); }
.metric-val { font-size: 30px; font-weight: 800; line-height: 1; color: var(--leaf-bright); }
.metric.blue .metric-val { color: #93c5fd; }
.metric.amber .metric-val { color: #fbbf24; }
.metric.purple .metric-val { color: #c4b5fd; }
.metric-lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 7px; font-weight: 700; }

/* ── Toolbar / busca / filtros ── */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.toolbar h2 { font-size: 17px; font-weight: 800; }
.filtros-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.busca {
  flex: 1; min-width: 220px; padding: 11px 15px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 14px; font-family: var(--font); outline: none; transition: border-color .15s, box-shadow .15s;
}
.busca::placeholder { color: var(--muted); }
.busca:focus { border-color: var(--leaf); box-shadow: 0 0 0 3px rgba(84,189,69,.16); }
.filtro-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.filtro-btn {
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
  padding: 9px 14px; border-radius: 9px; font-size: 12.5px; font-weight: 700;
  cursor: pointer; font-family: var(--font); transition: all .15s;
}
.filtro-btn:hover { background: #1d3047; color: var(--text); }
.filtro-btn.active { background: var(--leaf); border-color: var(--leaf); color: #06231a; }
.contador { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }

/* ── Botões ── */
.btn-primary {
  background: linear-gradient(135deg, var(--leaf-bright), var(--leaf-dark)); color: #06231a;
  border: none; padding: 11px 20px; border-radius: 10px; font-size: 14px; font-weight: 800;
  cursor: pointer; font-family: var(--font); transition: all .18s; box-shadow: 0 6px 18px rgba(84,189,69,.28);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(84,189,69,.4); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-amber { background: linear-gradient(135deg, #fbbf24, #d97706); color: #3a2400; }
.btn-ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  padding: 9px 16px; border-radius: 9px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: var(--font); transition: all .15s; text-decoration: none; display: inline-block;
}
.btn-ghost:hover { background: rgba(255,255,255,.06); color: var(--text); }
.btn-ver { background: transparent; color: var(--leaf-bright); border: 1px solid var(--border); padding: 8px 15px; border-radius: 9px; font-size: 12.5px; font-weight: 800; cursor: pointer; font-family: var(--font); transition: all .15s; }
.btn-ver:hover { background: rgba(84,189,69,.12); }

/* ── Ripple ── */
.ripple-host { position: relative; overflow: hidden; }
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: rgba(255,255,255,.4); transform: scale(0); opacity: .6;
  animation: ripple-anim .6s ease-out forwards;
}

/* ── Tabela ── */
.tabela-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,.16); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 800; background: var(--surface-2); }
td { padding: 13px 16px; border-bottom: 1px solid rgba(255,255,255,.05); font-size: 14px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: rgba(255,255,255,.03); }

.cel-farm { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; color: #fff;
}
.cel-nome { font-weight: 700; }
.cel-nome a { color: var(--text); text-decoration: none; cursor: pointer; }
.cel-nome a:hover { color: var(--leaf-bright); text-decoration: underline; }
.cel-email { color: var(--muted); font-size: 12.5px; }
.metric-num { font-weight: 800; font-size: 15px; }
.saude-emoji { font-size: 17px; }
.spark { width: 60px; height: 28px; display: block; }

.venc-exp { color: #fca5a5; font-weight: 700; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 20px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.badge.trial     { background: rgba(245,158,11,.16); color: #fbbf24; }
.badge.mensal    { background: rgba(59,130,246,.16); color: #93c5fd; }
.badge.semestral { background: rgba(139,92,246,.16); color: #c4b5fd; }
.badge.anual     { background: rgba(84,189,69,.16); color: var(--leaf-bright); }
.badge.ativo     { background: rgba(34,197,94,.16); color: #86efac; }
.badge.inativo   { background: rgba(148,163,184,.16); color: #cbd5e1; }
.badge.admin     { background: rgba(84,189,69,.16); color: var(--leaf-bright); }
.badge.gerente   { background: rgba(59,130,246,.16); color: #93c5fd; }
.badge.atendente { background: rgba(148,163,184,.16); color: #cbd5e1; }
.badge.dono      { background: rgba(245,158,11,.20); color: #fbbf24; border: 1px solid rgba(245,158,11,.5); }
.badge.st            { background: rgba(148,163,184,.16); color: #cbd5e1; }
.badge.st-concluido  { background: rgba(34,197,94,.16); color: #86efac; }
.badge.st-cancelado  { background: rgba(239,68,68,.16); color: #fca5a5; }

/* ── Ações na tabela ── */
.acoes { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-acao {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 6px 11px; border-radius: 8px; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: var(--font); transition: all .15s;
}
.btn-acao:hover { background: #1d3047; }
.btn-acao.danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-acao.ok:hover { background: var(--leaf-dark); border-color: var(--leaf-dark); color: #06231a; }

/* ── Skeleton ── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, #1e3050 50%, var(--surface-2) 75%);
  background-size: 1000px 100%; animation: shimmer 2s infinite; border-radius: 6px;
  display: inline-block; height: 14px;
}
.sk-avatar { width: 38px; height: 38px; border-radius: 11px; }
.sk-line { height: 12px; border-radius: 6px; }

/* ── Empty state ── */
.empty { padding: 60px 24px; text-align: center; }
.empty-ic { font-size: 54px; opacity: .5; margin-bottom: 14px; }
.empty-titulo { font-size: 16px; font-weight: 800; margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--muted); }
.vazio { padding: 40px; text-align: center; color: var(--muted); }

/* ── Card de alertas (inline) ── */
.alertas-box { display: none; background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.3); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 24px; }
.alertas-titulo { font-size: 14px; font-weight: 800; color: #fcd34d; margin-bottom: 12px; }
.alerta-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px; font-size: 13.5px; color: #fde68a; cursor: pointer; transition: background .15s; }
.alerta-item:hover { background: rgba(255,255,255,.06); }
.alerta-item.alto { color: #fca5a5; font-weight: 700; }

/* ── Linha destacada ── */
.row-destaque td { background: rgba(84,189,69,.16) !important; animation: pulseRow 1s ease 2; }

/* ── Atividade / Logs ── */
.atividade { margin-top: 32px; }
.atividade-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.atividade-head h2 { font-size: 17px; font-weight: 800; }
.logs-lista { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.log-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,.05); font-size: 13.5px; }
.log-item:last-child { border-bottom: none; }
.log-ic { font-size: 16px; width: 24px; text-align: center; flex-shrink: 0; }
.log-txt { flex: 1; }
.log-time { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ── Página de detalhes ── */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 22px; }
.box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: 0 8px 24px rgba(0,0,0,.16); }
.box-title { font-size: 15px; font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.linha { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.05); font-size: 14px; }
.linha:last-child { border-bottom: none; }
.linha .k { color: var(--muted); }
.linha .v { font-weight: 700; }
.prog-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 8px; }
.prog-track { height: 10px; border-radius: 999px; background: rgba(255,255,255,.10); overflow: hidden; }
.prog-fill { height: 100%; border-radius: 999px; transition: width .5s ease; }
.sec-title { font-size: 16px; font-weight: 800; margin: 6px 0 14px; }
canvas#grafico { width: 100%; height: 200px; display: block; }

/* ── Modal ── */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(5,12,22,.7); backdrop-filter: blur(3px); z-index: 100; align-items: center; justify-content: center; padding: 24px; }
.modal-bg.show { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 460px; padding: 28px; max-height: 92vh; overflow-y: auto; box-shadow: 0 30px 70px rgba(0,0,0,.55); animation: fadeUp .22s ease both; }
.modal h3 { font-size: 19px; font-weight: 800; margin-bottom: 20px; }
.m-field { margin-bottom: 15px; }
.m-field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.m-field input, .m-field select {
  width: 100%; padding: 11px 13px; border-radius: 9px; border: 1.5px solid var(--border);
  background: var(--ink-2); color: #fff; font-size: 14px; font-family: var(--font); outline: none; transition: border-color .15s, box-shadow .15s;
}
.m-field input:focus, .m-field select:focus { border-color: var(--leaf); box-shadow: 0 0 0 3px rgba(84,189,69,.16); }
.m-field select option { color: #111; }
.m-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-erro { display: none; margin-bottom: 14px; padding: 10px 13px; border-radius: 8px; font-size: 13px; background: rgba(239,68,68,.12); color: #fca5a5; border-left: 3px solid #ef4444; }
.modal-acoes { display: flex; gap: 10px; margin-top: 22px; }
.btn-cancel { flex: 1; background: transparent; color: var(--muted); border: 1px solid var(--border); padding: 12px; border-radius: 9px; font-weight: 700; cursor: pointer; font-family: var(--font); }
.btn-cancel:hover { background: rgba(255,255,255,.06); }
.btn-salvar { flex: 1; background: linear-gradient(135deg, var(--leaf-bright), var(--leaf-dark)); color: #06231a; border: none; padding: 12px; border-radius: 9px; font-weight: 800; cursor: pointer; font-family: var(--font); }
.btn-salvar:disabled { opacity: .6; cursor: not-allowed; }

/* ── Toast ── */
.toast { position: fixed; bottom: 26px; right: 26px; padding: 14px 22px; border-radius: 11px; font-size: 14px; font-weight: 700; color: #fff; z-index: 200; opacity: 0; transform: translateY(14px); transition: all .3s; pointer-events: none; box-shadow: 0 14px 34px rgba(0,0,0,.4); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: linear-gradient(135deg, var(--leaf-dark), #2f7d26); }
.toast.error { background: linear-gradient(135deg, #dc2626, #991b1b); }

/* ====================================================================
   Responsivo
   ==================================================================== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: flex; align-items: center; justify-content: center; }
  .wrap { padding: 20px; }
  .topbar { padding: 12px 18px; }
  .grid2 { grid-template-columns: 1fr; }
  .notif-dropdown { width: calc(100vw - 36px); right: -8px; }
}
