/* ── ADS FINANCEIRO — layout.css ─────────────────────────────────────────────
   Shell exclusivo do index.html: top-bar, app-shell, header, notificações,
   sidebar, conteúdo/iframe, dashboard e equipe.
   Depende de: tokens.css, base.css
   Keyframes (fadeUp, fadeIn, spin, pulse-green, badgePop, bell-shake, kpi-fade)
   ficam no <style> inline pois são referenciados por outros contextos.       */


/* ── TOP LOADING BAR ────────────────────────────────────────────────────── */
#top-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px; width: 0;
  z-index: 99999;
  background: linear-gradient(90deg, #8DC63F, #a3e635, #8DC63F);
  background-size: 200% 100%;
  border-radius: 0 2px 2px 0;
  transition: width .3s ease, opacity .4s ease;
  opacity: 0;
  animation: top-bar-shine 1.2s linear infinite;
}
#top-bar.loading { opacity: 1; }
@keyframes top-bar-shine {
  0%   { background-position: 200% 0 }
  100% { background-position: -200% 0 }
}


/* ── APP SHELL ──────────────────────────────────────────────────────────── */
#app-shell        { display: none; height: 100dvh; width: 100vw; flex-direction: column; }
#app-shell.visivel{ display: flex; animation: fadeIn .4s ease; }

#app-header {
  height: 56px;
  flex-shrink: 0;
  background: rgba(10, 18, 35, .98);
  border-bottom: 1px solid rgba(141, 198, 63, .15);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  backdrop-filter: blur(10px);
  z-index: 200;
  box-shadow: 0 2px 20px rgba(0, 0, 0, .4);
}
.header-logo       { display: flex; align-items: center; gap: .625rem; text-decoration: none; flex-shrink: 0; }
.header-logo-badge { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, #8DC63F, #a3e635); display: flex; align-items: center; justify-content: center; }
#breadcrumb-modulo { flex: 1; display: flex; align-items: center; gap: .5rem; font-size: .75rem; color: #64748b; overflow: hidden; }
.nome-modulo       { color: #e2e8f0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions    { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
.perfil-badge {
  display: flex; align-items: center; gap: .5rem;
  background: rgba(141, 198, 63, .08);
  border: 1px solid rgba(141, 198, 63, .2);
  border-radius: 9999px;
  padding: .25rem .75rem .25rem .375rem;
  font-size: .75rem;
}
.perfil-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8DC63F, #a3e635);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: #020617;
  font-family: 'Montserrat', sans-serif;
}
.btn-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: rgba(15, 23, 42, .8);
  border: 1px solid #1e293b;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #64748b;
  transition: all .2s;
  position: relative;
}
.btn-icon:hover              { border-color: #334155; color: #e2e8f0; background: rgba(30, 41, 59, .8); }
.btn-icon.logout:hover       { border-color: rgba(239, 68, 68, .4); color: #f87171; background: rgba(239, 68, 68, .08); }
#app-body { display: flex; flex: 1; overflow: hidden; }


/* ── NOTIFICAÇÕES ───────────────────────────────────────────────────────── */
#btn-notif .badge {
  position: absolute; top: -4px; right: -4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff; font-size: 9px; font-weight: 800;
  font-family: 'Montserrat', sans-serif;
  display: none; align-items: center; justify-content: center;
  border: 2px solid #020617;
  animation: badgePop .3s cubic-bezier(.16, 1, .3, 1);
}
#btn-notif .badge.visivel { display: flex; }

#dropdown-notif {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 360px; max-height: 480px;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 1rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  z-index: 1000;
  display: none; flex-direction: column; overflow: hidden;
}
#dropdown-notif.aberto { display: flex; animation: fadeUp .2s cubic-bezier(.16, 1, .3, 1); }
.notif-header  { padding: .875rem 1rem; border-bottom: 1px solid #1e293b; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.notif-lista   { overflow-y: auto; flex: 1; }
.notif-item    { display: flex; gap: .75rem; padding: .875rem 1rem; border-bottom: 1px solid #0f172a; cursor: pointer; transition: background .15s; }
.notif-item:hover                  { background: rgba(15, 23, 42, .8); }
.notif-item.nao-lida               { background: rgba(141, 198, 63, .04); border-left: 3px solid rgba(141, 198, 63, .4); }
.notif-item.nao-lida:hover         { background: rgba(141, 198, 63, .07); }
.notif-dot      { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.notif-dot.nova { background: #8DC63F; }
.notif-dot.lida { background: #1e293b; }
.bell-ring      { animation: bell-shake .7s cubic-bezier(.36, .07, .19, .97) both; }
#notif-posicao  { position: relative; }


/* ── SIDEBAR ────────────────────────────────────────────────────────────── */
#sidebar {
  width: 232px;
  flex-shrink: 0;
  background: rgba(10, 18, 35, .95);
  border-right: 1px solid rgba(30, 41, 59, .8);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width .3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
}
#sidebar.recolhido { width: 64px; }

.sidebar-section-label {
  padding: 1.25rem 1.125rem .375rem;
  font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em;
  color: #334155; white-space: nowrap; overflow: hidden; transition: opacity .2s;
}
#sidebar.recolhido .sidebar-section-label { opacity: 0; }

.nav-item {
  display: flex; align-items: center; gap: .75rem;
  margin: 1px .625rem; padding: .625rem .75rem;
  border-radius: .75rem; cursor: pointer;
  border: 1px solid transparent; transition: all .2s;
  text-decoration: none; color: #64748b;
  font-size: .8125rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; position: relative;
}
.nav-item:hover { background: rgba(15, 23, 42, .8); border-color: #1e293b; color: #cbd5e1; }
.nav-item.ativo {
  background: linear-gradient(135deg, rgba(141, 198, 63, .15), rgba(141, 198, 63, .08));
  border-color: rgba(141, 198, 63, .3); color: #8DC63F;
  box-shadow: 0 0 16px rgba(141, 198, 63, .1);
  border-left: 3px solid #8DC63F; padding-left: calc(.875rem - 2px);
}
.nav-item-icon  { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item-label { overflow: hidden; transition: opacity .2s, max-width .3s; max-width: 200px; }
#sidebar.recolhido .nav-item-label { opacity: 0; max-width: 0; }

.nav-badge {
  margin-left: auto; font-size: 9px; font-weight: 800;
  font-family: 'Montserrat', sans-serif;
  padding: 1px 6px; border-radius: 9999px; flex-shrink: 0; transition: opacity .2s;
}
.badge-admin { background: rgba(141, 198, 63, .15); color: #8DC63F; border: 1px solid rgba(141, 198, 63, .25); }
.badge-cfo   { background: rgba(251, 191, 36, .15); color: #fbbf24; border: 1px solid rgba(251, 191, 36, .25); }
.badge-lock  { background: rgba(148, 163, 184, .1); color: #64748b; border: 1px solid #1e293b; }
#sidebar.recolhido .nav-badge { opacity: 0; }

.sidebar-toggle {
  margin: .5rem .625rem; padding: .5rem .75rem;
  border-radius: .625rem; cursor: pointer;
  border: 1px solid #1e293b; background: rgba(2, 6, 23, .6); color: #475569;
  font-size: .75rem; display: flex; align-items: center; gap: .5rem;
  transition: all .2s; white-space: nowrap; overflow: hidden;
}
.sidebar-toggle:hover { border-color: #334155; color: #94a3b8; }
#sidebar.recolhido .sidebar-toggle-label { opacity: 0; max-width: 0; overflow: hidden; transition: opacity .2s, max-width .3s; }

.sidebar-spacer    { flex: 1; }
.sidebar-divider   { height: 1px; background: #1e293b; margin: .5rem .625rem; }
.sidebar-user-card {
  margin: .625rem; padding: .875rem;
  border-radius: .875rem; background: rgba(15, 23, 42, .8);
  border: 1px solid #1e293b; overflow: hidden; transition: padding .3s;
}
#sidebar.recolhido .sidebar-user-card { padding: .5rem; }

/* Tooltip recolhido */
#sidebar.recolhido .nav-item::after {
  content: attr(data-tooltip);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: #0f172a; border: 1px solid #334155; border-radius: .5rem;
  padding: .375rem .625rem; font-size: .75rem; color: #e2e8f0;
  white-space: nowrap; pointer-events: none; opacity: 0;
  transition: opacity .15s; z-index: 500;
}
#sidebar.recolhido .nav-item:hover::after { opacity: 1; }


/* ── CONTEÚDO PRINCIPAL / IFRAME ────────────────────────────────────────── */
#conteudo-principal {
  flex: 1; overflow: hidden; position: relative;
  display: flex; flex-direction: column;
}
#modulo-frame        { flex: 1; width: 100%; border: none; display: none; background: #020617; }
#modulo-frame.visivel{ display: block; animation: fadeIn .35s ease both; }
#loading-modulo {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(2, 6, 23, .9); z-index: 10;
  flex-direction: column; gap: 1rem;
}
#loading-modulo.visivel { display: flex; }
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(141, 198, 63, .15);
  border-top-color: #8DC63F; border-radius: 50%;
  animation: spin .8s linear infinite;
}
#sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(2, 6, 23, .7); backdrop-filter: blur(4px); z-index: 99;
}


/* ── DASHBOARD ──────────────────────────────────────────────────────────── */
#tela-dashboard        { flex: 1; overflow-y: auto; padding: 1.5rem; display: none; }
#tela-dashboard.visivel{ display: block; animation: fadeIn .4s ease; }

.dash-grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi-card      { background: rgba(15, 23, 42, .8); border: 1px solid #1e293b; border-radius: 1rem; padding: 1.25rem; transition: all .25s; }
.kpi-card:hover{ border-color: #334155; transform: translateY(-2px); }
.kpi-valor     { font-family: 'Montserrat', sans-serif; font-weight: 800; font-size: 1.875rem; line-height: 1; margin: .5rem 0 .25rem; }
.kpi-label     { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: #475569; }
.kpi-sub       { font-size: 11px; color: #64748b; margin-top: .25rem; }
@keyframes kpi-fade { 0%, 100% { opacity: .4 } 50% { opacity: 1 } }
.kpi-skeleton  { animation: kpi-fade 1.2s ease infinite; letter-spacing: .15em; font-size: .75em; }

.dash-grid-main { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.dash-card      { background: rgba(15, 23, 42, .8); border: 1px solid #1e293b; border-radius: 1rem; padding: 1.25rem; }
.dash-card-header{ display: flex; align-items: center; gap: .625rem; margin-bottom: 1rem; padding-bottom: .875rem; border-bottom: 1px solid #1e293b; }
.dash-card-title { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #94a3b8; }

.modulo-btn {
  display: flex; align-items: center; gap: .875rem;
  padding: .875rem 1rem; border-radius: .875rem;
  border: 1px solid #1e293b; background: transparent;
  cursor: pointer; transition: all .25s;
  text-decoration: none; width: 100%; text-align: left; margin-bottom: .5rem;
}
.modulo-btn:last-child           { margin-bottom: 0; }
.modulo-btn:hover                { border-color: rgba(141, 198, 63, .35); background: rgba(141, 198, 63, .05); transform: translateX(3px); }
.modulo-btn.bloqueado            { opacity: .35; cursor: not-allowed; }
.modulo-btn.bloqueado:hover      { transform: none; border-color: #1e293b; background: transparent; }
.modulo-btn-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.atividade-item           { display: flex; align-items: center; gap: .75rem; padding: .625rem 0; border-bottom: 1px solid #0f172a; }
.atividade-item:last-child{ border-bottom: none; }
.atividade-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #8DC63F, #a3e635);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; color: #020617;
  font-family: 'Montserrat', sans-serif; flex-shrink: 0;
}


/* ── EQUIPE ─────────────────────────────────────────────────────────────── */
#tela-equipe        { flex: 1; overflow-y: auto; padding: 1.5rem; display: none; }
#tela-equipe.visivel{ display: block; animation: fadeIn .4s ease; }
.equipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-top: 1rem; }
.membro-card        { background: rgba(15, 23, 42, .8); border: 1px solid #1e293b; border-radius: 1.125rem; padding: 1.25rem; transition: all .25s; }
.membro-card:hover  { border-color: #334155; transform: translateY(-2px); }
.membro-card.admin  { border-left: 3px solid #8DC63F; }
.membro-card.comercial{ border-left: 3px solid #38bdf8; }
.membro-card.inativo{ opacity: .45; }
.membro-status        { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.membro-status.online { background: #34d399; box-shadow: 0 0 6px rgba(52, 211, 153, .6); }
.membro-status.recente{ background: #fbbf24; box-shadow: 0 0 6px rgba(251, 191, 36, .5); }
.membro-status.offline{ background: #475569; }
.membro-status.inativo{ background: #334155; }


/* ── MEDIA QUERIES ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .dash-grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  #sidebar { display: none; }
}
@media (max-width: 640px) {
  .dash-grid-kpi  { grid-template-columns: 1fr 1fr; gap: .75rem; }
  #tela-dashboard { padding: 1rem .875rem; }
  #tela-equipe    { padding: 1rem .875rem; }
  .equipe-grid    { grid-template-columns: 1fr; }
  .kpi-valor      { font-size: 1.5rem; }
  .dash-grid-main { grid-template-columns: 1fr; gap: .75rem; }
}
