/* ==========================================================================
   HELDA — Design System Premium (SaaS dark theme)
   Inspirado em Stripe / Linear / Vercel / Notion / Supabase / Clerk / Tremor
   IMPORTANTE: este arquivo só altera aparência. Nenhuma classe Bootstrap
   utilizada na lógica dos templates foi removida — apenas redesenhada.
   ========================================================================== */

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

:root {
  --bg: #0F172A;
  --sidebar-bg: #111827;
  --card-bg: #1E293B;
  --hover: #334155;
  --text: #F8FAFC;
  --text-secondary: #94A3B8;
  --blue: #3B82F6;
  --blue-dark: #2563EB;
  --indigo: #6366F1;
  --green: #22C55E;
  --yellow: #F59E0B;
  --red: #EF4444;
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-subtle-2: rgba(255, 255, 255, 0.10);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.28);
  --shadow-lift: 0 12px 32px rgba(0, 0, 0, 0.38);
}

* {
  font-family: 'Plus Jakarta Sans', Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}

html, body {
  background: var(--bg) !important;
  color: var(--text);
}

a { text-decoration: none; }

/* Scrollbar elegante */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--hover); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ==========================================================================
   LAYOUT GERAL
   ========================================================================== */
.helda-shell { display: flex; min-height: 100vh; }
.helda-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.helda-content { padding: 1.75rem 2rem; flex: 1; }

@media (max-width: 991px) {
  .helda-content { padding: 1.25rem; }
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--sidebar-bg) !important;
  border-right: 1px solid var(--border-subtle) !important;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text) !important;
  padding: .25rem .25rem 1.25rem .25rem;
  letter-spacing: -.01em;
}
.sidebar-brand .logo-badge {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--blue), var(--indigo));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(59, 130, 246, .35);
  flex-shrink: 0;
}
.sidebar-brand .logo-badge svg { width: 20px; height: 20px; color: #fff; }
.sidebar-brand .logo-badge-img {
  width: 38px; height: 38px; flex-shrink: 0; object-fit: contain;
  border-radius: 9px;
}

.sidebar-section-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-secondary); font-weight: 700;
  margin: 1rem .6rem .4rem .6rem; opacity: .65;
}

.sidebar-nav { display: flex; flex-direction: column; gap: .2rem; }

.nav-link {
  display: flex; align-items: center; gap: .8rem;
  padding: .65rem .85rem !important;
  border-radius: var(--radius-sm);
  font-weight: 500; font-size: .9rem;
  color: var(--text-secondary) !important;
  transition: all .2s ease;
  border: 1px solid transparent;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.nav-link:hover {
  background: var(--hover) !important;
  color: var(--text) !important;
  transform: translateX(2px);
}
.nav-link.active {
  background: linear-gradient(135deg, rgba(59,130,246,.20), rgba(99,102,241,.10)) !important;
  color: #fff !important;
  border-color: rgba(59, 130, 246, .35);
  font-weight: 600;
}

.sidebar hr { border-color: var(--border-subtle); opacity: 1; margin: 1rem 0; }

.sidebar-footer { margin-top: auto; padding-top: 1rem; }

.user-card {
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: .65rem .75rem;
  display: flex; align-items: center; gap: .65rem;
  margin-bottom: .6rem;
}
.user-card .avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #8B5CF6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: .85rem; flex-shrink: 0;
}
.user-card .user-meta { line-height: 1.25; overflow: hidden; }
.user-card .user-name { font-size: .85rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .user-role { font-size: .72rem; color: var(--text-secondary); }

.btn-logout {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .55rem; border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, .08); border: 1px solid rgba(239, 68, 68, .25);
  color: var(--red); font-size: .85rem; font-weight: 600;
  transition: all .2s ease;
}
.btn-logout:hover { background: rgba(239, 68, 68, .18); color: #fff; }
.btn-logout svg { width: 16px; height: 16px; }

/* Mobile sidebar toggle */
.sidebar-toggle-btn { display: none; }
@media (max-width: 991px) {
  .sidebar {
    position: fixed; left: 0; z-index: 1040;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-lift);
  }
  .sidebar.show { transform: translateX(0); }
  .sidebar-toggle-btn { display: inline-flex; }
  .sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1030;
    opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
}

/* ==========================================================================
   TOPBAR
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(15, 23, 42, .82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 1rem 2rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
@media (max-width: 991px) { .topbar { padding: 1rem 1.25rem; } }

.topbar-left { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.topbar-breadcrumb { font-size: .76rem; color: var(--text-secondary); display: flex; align-items: center; gap: .35rem; }
.topbar-title { font-weight: 700; font-size: 1.15rem; color: var(--text); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-right { display: flex; align-items: center; gap: .65rem; flex-shrink: 0; }

.search-box {
  background: var(--card-bg); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); padding: .5rem .9rem;
  display: flex; align-items: center; gap: .55rem; width: 260px;
  color: var(--text-secondary); transition: border-color .2s;
}
.search-box:focus-within { border-color: var(--blue); }
.search-box svg { width: 16px; height: 16px; flex-shrink: 0; }
.search-box input {
  background: transparent; border: none; outline: none;
  color: var(--text); width: 100%; font-size: .85rem;
}
@media (max-width: 768px) { .search-box { display: none; } }

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card-bg); border: 1px solid var(--border-subtle);
  color: var(--text-secondary); transition: all .2s ease; position: relative;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--hover); color: var(--text); transform: translateY(-1px); }
.icon-btn .notif-dot {
  position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); border: 2px solid var(--bg);
}

.topbar-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #8B5CF6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: .85rem; cursor: pointer;
  border: 2px solid var(--border-subtle-2);
}

/* ==========================================================================
   CARDS
   ========================================================================== */
.card-kpi {
  background: var(--card-bg) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-soft);
  padding: 1.35rem !important;
  transition: all .2s ease;
}
.card-kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }

.stat-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.stat-card-icon {
  width: 46px; height: 46px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-card-icon svg { width: 22px; height: 22px; }
.stat-card-icon.blue { background: rgba(59,130,246,.15); color: var(--blue); }
.stat-card-icon.green { background: rgba(34,197,94,.15); color: var(--green); }
.stat-card-icon.yellow { background: rgba(245,158,11,.15); color: var(--yellow); }
.stat-card-icon.red { background: rgba(239,68,68,.15); color: var(--red); }
.stat-card-icon.purple { background: rgba(139,92,246,.15); color: #A78BFA; }

.stat-card-value { font-size: 1.6rem; font-weight: 800; color: var(--text); letter-spacing: -.02em; line-height: 1.1; }
.stat-card-label { font-size: .8rem; color: var(--text-secondary); font-weight: 500; margin-bottom: .35rem; }
.stat-card-trend { font-size: .74rem; font-weight: 600; display: flex; align-items: center; gap: .25rem; margin-top: .4rem; }

/* ==========================================================================
   BOTÕES
   ========================================================================== */
.btn {
  border-radius: var(--radius-sm) !important;
  font-weight: 600 !important;
  font-size: .85rem !important;
  padding: .55rem 1.1rem !important;
  transition: all .2s ease !important;
  display: inline-flex; align-items: center; gap: .4rem;
}
.btn svg { width: 16px; height: 16px; }
.btn-sm { padding: .4rem .8rem !important; font-size: .8rem !important; }

.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--indigo)) !important;
  border: none !important; color: #fff !important;
  box-shadow: 0 4px 14px rgba(59, 130, 246, .32);
}
.btn-primary:hover { transform: translateY(-1px) scale(1.015); box-shadow: 0 10px 22px rgba(59, 130, 246, .42); color: #fff !important; }

.btn-outline-light { border: 1px solid var(--border-subtle-2) !important; color: var(--text) !important; background: transparent !important; }
.btn-outline-light:hover { background: var(--hover) !important; transform: translateY(-1px); }

.btn-outline-danger { border: 1px solid rgba(239, 68, 68, .35) !important; color: var(--red) !important; background: transparent !important; }
.btn-outline-danger:hover { background: rgba(239, 68, 68, .14) !important; transform: translateY(-1px); }

.btn-outline-success { border: 1px solid rgba(34, 197, 94, .35) !important; color: var(--green) !important; background: transparent !important; }
.btn-outline-success:hover { background: rgba(34, 197, 94, .14) !important; transform: translateY(-1px); }

.btn-outline-info { border: 1px solid rgba(59, 130, 246, .35) !important; color: var(--blue) !important; background: transparent !important; }
.btn-outline-info:hover { background: rgba(59, 130, 246, .14) !important; transform: translateY(-1px); }

/* Botões de ação em ícone (tabelas) */
.btn-icon-action {
  width: 34px; height: 34px; border-radius: 10px !important;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 !important;
}
.btn-icon-action svg { width: 16px; height: 16px; margin: 0; }

/* ==========================================================================
   BADGES (status / risco)
   ========================================================================== */
.badge {
  border-radius: 999px !important;
  padding: .38rem .75rem !important;
  font-weight: 600 !important;
  font-size: .72rem !important;
  letter-spacing: .02em;
  display: inline-flex; align-items: center; gap: .35rem;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge.bg-success { background: rgba(34, 197, 94, .15) !important; color: var(--green) !important; }
.badge.bg-danger  { background: rgba(239, 68, 68, .15) !important; color: var(--red) !important; }
.badge.bg-warning { background: rgba(245, 158, 11, .15) !important; color: var(--yellow) !important; }
.badge.bg-secondary { background: rgba(148, 163, 184, .15) !important; color: var(--text-secondary) !important; }
.badge.bg-info { background: rgba(59, 130, 246, .15) !important; color: var(--blue) !important; }
.badge.text-dark { color: inherit !important; }

/* ==========================================================================
   TABELAS
   ========================================================================== */
.table { color: var(--text) !important; margin-bottom: 0; }
.table thead th {
  color: var(--text-secondary) !important;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 700; border-bottom: 1px solid var(--border-subtle) !important;
  padding: 1rem 1.1rem !important; background: transparent !important;
  white-space: nowrap;
}
.table tbody td {
  padding: 1rem 1.1rem !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  vertical-align: middle; font-size: .87rem;
}
.table tbody tr { transition: background .15s ease; }
.table-hover tbody tr:hover { background: var(--hover) !important; }
.table-striped tbody tr:nth-of-type(odd) { background: rgba(255, 255, 255, .015); }
.table tbody tr:last-child td { border-bottom: none !important; }

/* ==========================================================================
   FORMULÁRIOS
   ========================================================================== */
.form-control, .form-select {
  background: var(--card-bg) !important;
  border: 1px solid var(--border-subtle-2) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm) !important;
  padding: .65rem .9rem !important;
  font-size: .87rem !important;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.form-control:focus, .form-select:focus {
  border-color: var(--blue) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15) !important;
  background: var(--card-bg) !important; color: var(--text) !important;
}
.form-control::placeholder { color: #64748B; }
label.form-label { color: var(--text-secondary) !important; font-size: .8rem; font-weight: 600; margin-bottom: .4rem; }
.form-check-input { background-color: var(--card-bg); border-color: var(--border-subtle-2); }
.form-check-input:checked { background-color: var(--blue); border-color: var(--blue); }

/* ==========================================================================
   ALERTAS
   ========================================================================== */
.alert { border-radius: var(--radius-sm) !important; border: 1px solid transparent !important; font-size: .87rem; }
.alert-success { background: rgba(34, 197, 94, .10) !important; color: var(--green) !important; border-color: rgba(34, 197, 94, .25) !important; }
.alert-danger  { background: rgba(239, 68, 68, .10) !important; color: var(--red) !important; border-color: rgba(239, 68, 68, .25) !important; }
.alert-warning { background: rgba(245, 158, 11, .10) !important; color: var(--yellow) !important; border-color: rgba(245, 158, 11, .25) !important; }
.alert-secondary, .alert-info { background: rgba(148, 163, 184, .08) !important; color: var(--text) !important; border-color: var(--border-subtle-2) !important; }

/* ==========================================================================
   UTILITÁRIOS DE TEXTO / CORES
   ========================================================================== */
.text-secondary { color: var(--text-secondary) !important; }
.text-success { color: var(--green) !important; }
.text-danger { color: var(--red) !important; }
.text-warning { color: var(--yellow) !important; }
.text-white { color: var(--text) !important; }
.text-info { color: var(--blue) !important; }

/* ==========================================================================
   RESPONSIVIDADE — GRÁFICOS COM SCROLL HORIZONTAL EM TELAS PEQUENAS
   ========================================================================== */
.fluxo-scroll-mobile {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
@media (min-width: 992px) {
  .fluxo-scroll-mobile { overflow-x: visible; }
  .fluxo-scroll-mobile > div { min-width: 0 !important; }
}

/* ==========================================================================
   RESPONSIVIDADE — AJUSTES MOBILE/TABLET GERAIS
   ========================================================================== */
@media (max-width: 767px) {
  .helda-content { padding: 1rem .85rem; }
  .card-kpi { padding: 1rem !important; }
  .stat-card-value { font-size: 1.25rem !important; }
  .topbar { padding: .75rem 1rem; }
  .topbar-title { font-size: 1rem; }
  .table thead th, .table tbody td { padding: .7rem .6rem !important; font-size: .8rem; }
  .btn-icon-action { width: 38px; height: 38px; } /* alvo de toque maior no celular */
  .nav-link { padding: .8rem .9rem !important; } /* alvo de toque maior no menu */
}
@media (max-width: 420px) {
  .stat-card-icon { width: 38px; height: 38px; }
  .stat-card-icon svg { width: 18px; height: 18px; }
}

/* ==========================================================================
   RESPONSIVIDADE — TABELA EM CARDS NO CELULAR (componente reutilizável)
   ========================================================================== */
@media (max-width: 575px) {
  .table-cards-mobile thead { display: none; }
  .table-cards-mobile, .table-cards-mobile tbody, .table-cards-mobile tr, .table-cards-mobile td {
    display: block; width: 100%;
  }
  .table-cards-mobile tr {
    background: rgba(255,255,255,.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    margin-bottom: .6rem;
    padding: .5rem .25rem;
  }
  .table-cards-mobile td {
    border: none !important;
    padding: .4rem .75rem !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    text-align: right;
  }
  .table-cards-mobile td[data-label]::before {
    content: attr(data-label);
    color: var(--text-secondary);
    font-size: .72rem;
    font-weight: 600;
    text-align: left;
    flex-shrink: 0;
  }
}

.tooltip-inner { background: var(--card-bg); color: var(--text); border: 1px solid var(--border-subtle-2); font-size: .76rem; border-radius: var(--radius-sm); }
.bs-tooltip-top .tooltip-arrow::before { border-top-color: var(--card-bg); }
.bs-tooltip-bottom .tooltip-arrow::before { border-bottom-color: var(--card-bg); }

/* Dropdowns Bootstrap (menu do usuário) */
.dropdown-menu {
  background: var(--card-bg) !important; border: 1px solid var(--border-subtle-2) !important;
  border-radius: var(--radius-sm) !important; box-shadow: var(--shadow-lift) !important;
  padding: .5rem !important;
}
.dropdown-item { color: var(--text-secondary) !important; border-radius: 8px !important; font-size: .85rem !important; padding: .55rem .75rem !important; }
.dropdown-item:hover { background: var(--hover) !important; color: var(--text) !important; }
.dropdown-divider { border-color: var(--border-subtle) !important; }

/* Animações utilitárias */
.transition-all { transition: all .2s ease; }
.hover-lift:hover { transform: translateY(-2px); }
