/* ==========================================================================
   IDORC — Design System
   Modelo tipo Enuves (gestão de igrejas). HTML/CSS/JS puro, sem backend.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* ===== Identidade IDORC (escuro + dourado/laranja) ===== */
  --brand-h: 40;
  --brand-s: 92%;
  --brand-l: 56%;
  --brand: hsl(var(--brand-h) var(--brand-s) var(--brand-l));      /* dourado/âmbar */
  --brand-600: hsl(var(--brand-h) var(--brand-s) calc(var(--brand-l) - 8%));
  --brand-700: #F7C766;                                            /* dourado claro p/ texto em tint */
  --brand-50: rgba(245,185,66,.08);
  --brand-100: rgba(245,185,66,.18);                               /* focus ring / avatar / selection */
  --brand-tint: rgba(245,185,66,.10);                              /* hover linhas / badges */
  --on-brand: #17110A;                                             /* texto escuro sobre o dourado */

  --bg: #0A0A0C;
  --surface: #15151B;
  --surface-2: #1C1C24;
  --border: #26262F;
  --border-strong: #33343F;
  --text: #F5F1E8;
  --text-2: #B9B3A8;
  --text-3: #8B857A;

  --success: #3FB68B;  --success-bg: rgba(63,182,139,.15);
  --warning: #F5B942;  --warning-bg: rgba(245,185,66,.15);
  --danger:  #EF5A6F;  --danger-bg:  rgba(239,90,111,.15);
  --info:    #6AA9FF;  --info-bg:    rgba(106,169,255,.15);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35), 0 1px 3px rgba(0,0,0,.30);
  --shadow: 0 6px 18px rgba(0,0,0,.40);
  --shadow-lg: 0 16px 46px rgba(0,0,0,.55);

  --sidebar-w: 250px;
  --topbar-h: 62px;
  --bottomnav-h: 62px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0 0 .4em; line-height: 1.25; font-weight: 700; }
img { max-width: 100%; display: block; }
::selection { background: var(--brand-100); }

/* ---------- Layout shell ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: #14161f;
  color: #c7cbd6;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; color: #fff; font-weight: 800; font-size: 18px;
  letter-spacing: -.02em;
}
.sidebar__logo {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: var(--brand); color: var(--on-brand);
  display: grid; place-items: center; font-weight: 800; font-size: 17px;
}
.sidebar__section { padding: 6px 12px; }
.sidebar__label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: #6c7284; padding: 12px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 9px; color: #c7cbd6;
  font-weight: 500; cursor: pointer; margin-bottom: 2px;
}
.nav-item:hover { background: #1f222e; color: #fff; text-decoration: none; }
.nav-item.is-active { background: var(--brand); color: var(--on-brand); }
.nav-item .ico { width: 19px; height: 19px; flex: none; }
.sidebar__foot { margin-top: auto; padding: 12px; border-top: 1px solid #24273400; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
.topbar__search {
  flex: 1; max-width: 420px; position: relative;
}
.topbar__search input {
  width: 100%; height: 38px; border: 1px solid var(--border); border-radius: 10px;
  padding: 0 12px 0 36px; background: var(--surface-2); font-size: 13.5px;
}
.topbar__search svg { position: absolute; left: 11px; top: 10px; color: var(--text-3); }
.topbar__spacer { flex: 1; }
.iconbtn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; cursor: pointer;
  color: var(--text-2); position: relative;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px;
  background: var(--danger); border-radius: 50%; border: 2px solid var(--surface); }

.church-switch {
  display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 6px;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface);
}
.church-switch:hover { background: var(--surface-2); }
.church-switch img, .church-switch .avatar { width: 28px; height: 28px; border-radius: 7px; }
.avatar {
  border-radius: 50%; background: var(--brand-100); color: var(--brand-700);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}

.content { padding: 24px; flex: 1; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head p { color: var(--text-2); margin: 4px 0 0; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  background: var(--surface-2); color: var(--text); transition: filter .12s, background .12s;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 17px; height: 17px; }
.btn--primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.btn--primary:hover { background: var(--brand-600); }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { background: var(--danger-bg); color: var(--danger); }
.btn--danger:hover { background: #fbdedb; }
.btn--sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card__head { padding: 16px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; }
.card__head h3 { margin: 0; font-size: 15px; }
.card__head .btn { margin-left: auto; }
.card__body { padding: 18px; }
.card__body--flush { padding: 0; }

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

/* Stat tiles */
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat__label { color: var(--text-2); font-size: 12.5px; font-weight: 600; display:flex; align-items:center; gap:8px;}
.stat__value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.stat__delta { font-size: 12px; font-weight: 600; }
.stat__ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand); }
.delta-up { color: var(--success); } .delta-down { color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.tbl th {
  color: var(--text-2); font-weight: 600; font-size: 12px; text-transform: uppercase;
  letter-spacing: .03em; background: var(--surface-2); cursor: pointer; white-space: nowrap;
}
.tbl th.sortable:hover { color: var(--text); }
.tbl tbody tr:hover { background: var(--brand-tint); }
.tbl td.actions { text-align: right; white-space: nowrap; }
.tbl .muted { color: var(--text-3); }
.tbl__empty { padding: 44px; text-align: center; color: var(--text-3); }

.toolbar { display: flex; gap: 10px; align-items: center; padding: 14px 16px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 340px; }
.toolbar .search input { width: 100%; height: 36px; border: 1px solid var(--border);
  border-radius: 9px; padding: 0 12px 0 34px; background: var(--surface-2); font: inherit; }
.toolbar .search svg { position: absolute; left: 10px; top: 9px; color: var(--text-3); }
.toolbar__spacer { flex: 1; }

.pagination { display: flex; align-items: center; gap: 6px; padding: 12px 16px;
  border-top: 1px solid var(--border); color: var(--text-2); font-size: 13px; }
.pagination .btn--sm { min-width: 32px; }
.pagination__spacer { flex: 1; }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.badge--brand { background: var(--brand-tint); color: var(--brand-700); }
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--warning { background: var(--warning-bg); color: var(--warning); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--info { background: var(--info-bg); color: var(--info); }
.badge .dotc { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip { display:inline-flex; align-items:center; gap:6px; padding:4px 10px; background:var(--surface-2);
  border:1px solid var(--border); border-radius:999px; font-size:12.5px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px;
  overflow-x: auto; }
.tab { padding: 10px 14px; font-weight: 600; color: var(--text-2); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.tabpane { display: none; } .tabpane.is-active { display: block; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 6px; color: var(--text); }
.field .hint { color: var(--text-3); font-size: 12px; margin-top: 4px; }
.input, .select, .textarea {
  width: 100%; min-height: 38px; border: 1px solid var(--border-strong); border-radius: 9px;
  padding: 8px 11px; font: inherit; background: var(--surface); color: var(--text);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100);
}
.textarea { min-height: 84px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.switch input { display: none; }
.switch .track { width: 40px; height: 23px; border-radius: 999px; background: var(--border-strong);
  position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: left .15s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { left: 19px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(18,20,28,.5); backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade .15s ease;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: pop .16s ease;
}
.modal--lg { max-width: 820px; }
.modal__head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal__head h3 { margin: 0; font-size: 17px; }
.modal__head .iconbtn { margin-left: auto; border: none; }
.modal__body { padding: 20px; overflow-y: auto; }
.modal__foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: #14161f; color: #fff; padding: 12px 16px; border-radius: 11px;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; font-weight: 500;
  animation: slidein .2s ease; max-width: 340px; }
.toast--success { background: #10683f; } .toast--danger { background: #a5342d; }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } }

/* ---------- Dropdown ---------- */
.menu { position: relative; }
.menu__pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface);
  border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow-lg); min-width: 200px;
  padding: 6px; z-index: 60; display: none; }
.menu.open .menu__pop { display: block; }
.menu__item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  cursor: pointer; color: var(--text); font-size: 13.5px; }
.menu__item:hover { background: var(--surface-2); }
.menu__item.danger { color: var(--danger); }
.menu__sep { height: 1px; background: var(--border); margin: 5px 0; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth__aside { background: linear-gradient(150deg, var(--brand-700), var(--brand));
  color: #fff; padding: 48px; display: flex; flex-direction: column; }
.auth__aside h2 { font-size: 30px; max-width: 420px; }
.auth__aside p { opacity: .85; max-width: 420px; font-size: 15px; }
.auth__feature { display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; max-width: 420px; }
.auth__feature .ic { width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.15);
  display: grid; place-items: center; flex: none; }
.auth__main { display: grid; place-items: center; padding: 32px; }
.auth__card { width: 100%; max-width: 380px; }
.auth__logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; margin-bottom: 26px; }
.auth__logo .sidebar__logo { width: 40px; height: 40px; }

/* ---------- Misc ---------- */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3);
  font-weight: 700; margin: 22px 0 10px; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-2 { color: var(--text-2); } .text-3 { color: var(--text-3); }
.flex { display: flex; } .items-center { align-items: center; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-0{margin-top:0}.mb-0{margin-bottom:0}
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-3); }
.empty-state svg { width: 46px; height: 46px; margin-bottom: 10px; opacity: .5; }
.avatar-lg { width: 64px; height: 64px; font-size: 24px; }
.people-photo { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; background: var(--border); gap: 1px; }
.cal__dow { background: var(--surface-2); padding: 8px; text-align: center; font-size: 11px;
  text-transform: uppercase; color: var(--text-2); font-weight: 700; }
.cal__day { background: var(--surface); min-height: 92px; padding: 7px; font-size: 12px; }
.cal__day.other { background: var(--surface-2); color: var(--text-3); }
.cal__day .n { font-weight: 700; }
.cal__day.today .n { color: var(--brand); }
.cal__ev { margin-top: 4px; font-size: 11px; padding: 2px 6px; border-radius: 6px;
  background: var(--brand-tint); color: var(--brand-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Progress */
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

/* ---------- Responsive ---------- */
.sidebar-toggle { display: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 90; width: var(--sidebar-w); transform: translateX(-100%);
    transition: transform .2s; }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after { content:""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 80; }
  .sidebar-toggle { display: grid; }
  .auth { grid-template-columns: 1fr; }
  .auth__aside { display: none; }
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .form-row, .form-row--3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .content { padding: 16px; }
  .topbar__search { display: none; }
}

/* ==========================================================================
   IDORC — Overrides do tema escuro + navegação mobile
   ========================================================================== */
a:hover { text-decoration: none; }
.sidebar { background: #0D0D11; border-right: 1px solid var(--border); color: var(--text-2); }
.nav-item { color: var(--text-2); }
.nav-item:hover { background: #1A1A22; color: var(--text); }
.nav-item.is-active { background: var(--brand); color: var(--on-brand); font-weight: 700; }
.sidebar__label { color: var(--text-3); }
.topbar { background: var(--surface); }
.topbar__search input { color: var(--text); }
.topbar__search input::placeholder { color: var(--text-3); }
.iconbtn { background: var(--surface-2); }
.church-switch { background: var(--surface-2); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.tbl th { background: #101015; }
.stat__ico { background: var(--brand-tint); color: var(--brand); }
.toast { background: #1C1C24; border: 1px solid var(--border); }

/* Marca dourada no login (aside) */
.auth__aside {
  background:
    radial-gradient(70% 60% at 20% 10%, rgba(247,148,30,.28), transparent 60%),
    radial-gradient(60% 60% at 90% 90%, rgba(225,48,108,.20), transparent 60%),
    #0D0D11;
  border-right: 1px solid var(--border);
}
.auth__aside h2, .auth__aside p { color: var(--text); }
.auth__feature .ic { background: rgba(245,185,66,.14); color: var(--brand); }

/* ---------- Bottom navigation (mobile-first) ---------- */
.bottomnav { display: none; }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  height: var(--bottomnav-h);
  background: rgba(13,13,17,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  grid-auto-flow: column; grid-auto-columns: 1fr; align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-3); font-size: 10.5px; font-weight: 600;
}
.bottomnav a .ico { width: 22px; height: 22px; }
.bottomnav a.is-active { color: var(--brand); }
.bottomnav a:hover { color: var(--text); text-decoration: none; }

@media (max-width: 900px) {
  .bottomnav { display: grid; }
  .content { padding-bottom: calc(var(--bottomnav-h) + 20px); }
  .sidebar__foot { padding-bottom: 20px; }
}

/* Botão fechar do menu lateral (só no mobile) */
.sidebar-close { display: none; width: 32px; height: 32px; }
@media (max-width: 900px) {
  .sidebar-close { display: grid; }
  .sidebar { width: min(84vw, 300px); }
}

/* Correções: switch dentro de formulário + ações da tabela alinhadas */
.field > label.switch { display: inline-flex; margin-bottom: 0; }
.switch__lbl { font-weight: 600; color: var(--text); }
.actions .row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: nowrap; }
.actions .row-actions .iconbtn { width: 32px; height: 32px; border-radius: 8px; flex: none; }
.actions .row-actions .iconbtn.btn--danger { border-color: transparent; }
