/* =============================================
   LAYOUT BASE
   ============================================= */
:root {
  --sidebar-width: 265px;
  --sidebar-bg: #0d2d6e;
  --sidebar-active: #1565C0;
  --sidebar-hover: rgba(255,255,255,.08);
  --sidebar-text: rgba(255,255,255,.75);
  --sidebar-text-active: #ffffff;
  --gold: #F9A825;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  background-color: #f0f2f8;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  margin: 0;
}

/* =============================================
   SIDEBAR
   ============================================= */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  transition: transform .25s ease;
}

/* Logo area */
.sidebar-logo {
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-logo a {
  display: block;
  text-decoration: none;
}

/* ── Tab bar ───────────────────────────────── */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,.10);
  flex-shrink: 0;
  background: rgba(0,0,0,.15);
}

.sidebar-tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 2px 7px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: rgba(255,255,255,.42);
  font-size: .55rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  min-width: 0;
  overflow: hidden;
}

.sidebar-tab-btn i {
  font-size: 1rem;
  display: block;
  flex-shrink: 0;
}

.sidebar-tab-btn span {
  display: block;
  width: 100%;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-tab-btn:hover {
  color: rgba(255,255,255,.75);
  background: rgba(255,255,255,.05);
}

.sidebar-tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
  background: rgba(255,255,255,.04);
}

/* ── Tab content panels ────────────────────── */
.sidebar-tab-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-tab-panel.active {
  display: flex;
}

/* Section labels */
.sidebar-section-label {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: rgba(255,255,255,.30);
  padding: 12px 18px 3px;
  text-transform: uppercase;
}

/* Nav links */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}

.sidebar-link i {
  font-size: 1rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  border-left-color: var(--gold);
  font-weight: 600;
}

/* Disabled / coming soon links */
.sidebar-link.soon {
  opacity: .38;
  pointer-events: none;
  cursor: default;
}

.sidebar-link.soon::after {
  content: 'em breve';
  font-size: .55rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(249,168,37,.12);
  border: 1px solid rgba(249,168,37,.3);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: auto;
}

/* ── Footer / user ─────────────────────────── */
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 10px 14px;
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold);
  color: #0d2d6e;
  font-weight: 700;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  overflow: hidden;
}

.sidebar-user-name {
  color: #fff;
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  color: rgba(255,255,255,.40);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.sidebar-logout {
  color: rgba(255,255,255,.4);
  font-size: 1.1rem;
  text-decoration: none;
  padding: 4px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.sidebar-logout:hover {
  color: #ff6b6b;
  background: rgba(255,255,255,.08);
}

/* =============================================
   MAIN CONTENT (offset by sidebar)
   ============================================= */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  /* Limita a largura ao espaço disponível → força table-responsive a rolar */
  max-width: calc(100vw - var(--sidebar-width));
  overflow-x: hidden;
}

/* Mobile top bar (hidden on desktop) */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 999;
  background: #fff;
  padding: 10px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  align-items: center;
}

/* =============================================
   RESPONSIVE — mobile
   ============================================= */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  .main-content {
    margin-left: 0;
    max-width: 100vw;
  }
  .mobile-topbar {
    display: flex;
  }
}

/* =============================================
   CARDS & COMPONENTS
   ============================================= */

.kpi-card {
  transition: transform .15s ease, box-shadow .15s ease;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.1) !important;
}

.kpi-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.card {
  border-radius: 12px;
}

.card-header {
  border-radius: 12px 12px 0 0 !important;
}

.table th {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6c757d;
  font-weight: 600;
}

.table td {
  font-size: .9rem;
}

.badge {
  font-weight: 500;
}

.pagination .page-link {
  border-radius: 6px !important;
  margin: 0 2px;
  border: none;
  color: #0d6efd;
}

.pagination .page-item.active .page-link {
  background-color: #0d6efd;
  color: #fff;
}

.navbar-brand {
  font-size: 1.1rem;
  letter-spacing: .01em;
}

main {
  min-height: calc(100vh - 60px);
}

.form-control:focus,
.form-select:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 .2rem rgba(13,110,253,.15);
}

.btn {
  border-radius: 8px;
}

.btn-sm {
  border-radius: 6px;
}

.alert {
  border-radius: 10px;
  border: none;
}

/* Login page */
.login-icon {
  width: 64px;
  height: 64px;
  background: rgba(13,110,253,.08);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

/* Scrollable tables — arrastar para o lado */
.table-responsive {
  border-radius: 0 0 12px 12px;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  display: block;
  width: 100%;
}

/* Chart canvas sizing */
canvas {
  max-height: 340px;
}

/* =============================================
   COMMISSION TABLE (bank_table_detail / history)
   ============================================= */

/* Dark two-row header */
.comm-thead tr th {
  background: #1a1a2e;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
  border-color: #2a2a3e;
  padding: 6px 8px;
}

/* Highlighted "Comissão Total" header */
.comm-total-th {
  background: #1565C0 !important;
  color: #fff !important;
  font-size: .78rem !important;
}

/* Table row hover */
#commTable tbody tr:hover {
  background: rgba(13, 110, 253, 0.05);
}

/* First row in history = current version highlight */
#commTable tbody tr.table-success {
  background: rgba(25, 135, 84, 0.07) !important;
}

/* Filter panel labels */
.filter-label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Compact table cells for commission view */
#commTable td {
  font-size: .82rem;
  padding: 6px 8px;
  border-color: #f0f0f0;
}

/* History badge column */
#commTable td:first-child {
  border-left: 3px solid transparent;
}
#commTable tbody tr.table-success td:first-child {
  border-left-color: #198754;
}
#commTable tbody tr:not(.table-success) td:first-child {
  border-left-color: #dee2e6;
}
