/* ═══════════════════════════════════════════════════════════
   Dashboard Layout Variations
   Applied via body class: layout-classic | layout-topnav | layout-compact | layout-centered
   ═══════════════════════════════════════════════════════════ */

/* ── BASE (shared across all layouts) ─────────────────────── */
/* Nav is fixed at 70px height — all layouts must respect this */
:root { --nav-h: 70px; }

/* ── LAYOUT 1: CLASSIC (default sidebar left) ─────────────── */
body.layout-classic .dashboard-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 22px;
  align-items: start;
}
body.layout-classic .dashboard-grid > aside {
  position: sticky;
  top: 82px;
}

/* ── LAYOUT 2: TOP NAV ──────────────────────────────────────
   Original aside is hidden. A JS-generated #dash-topnav bar
   is injected below the fixed site nav and mirrors its style.
   ─────────────────────────────────────────────────────────── */

/* Hide the original sidebar when topnav is active */
body.layout-topnav .dashboard-grid > aside { display: none; }

body.layout-topnav .dashboard-grid {
  display: block;
}

body.layout-topnav .dashboard {
  padding-top: calc(var(--nav-h) + 56px + 28px); /* nav + topnav bar + spacing */
  max-width: 1400px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

/* ── The injected topnav bar ── */
/* ── TOPNAV BAR ─────────────────────────────────────────────── */
#dash-topnav {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  z-index: 998;
  height: 56px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: stretch;
}

/* Wrapper that limits width and centers — matches dashboard content */
#dash-topnav-wrap {
  flex: 1;
  min-width: 0;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  display: flex;
  align-items: stretch;
}

/* Scroll arrows — flex siblings of inner, not absolute */
.tn-scroll-btn {
  flex-shrink: 0;
  width: 28px;
  background: none;
  border: none;
  color: rgba(255,255,255,.4);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s;
}
.tn-scroll-btn:hover { color: #fff; }
.tn-scroll-btn.hidden { visibility: hidden; pointer-events: none; }

#dash-topnav-inner {
  flex: 1;
  min-width: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-behavior: smooth;
}
#dash-topnav-inner::-webkit-scrollbar { display: none; }

/* ── Profile chip ── */
#dash-topnav-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  margin-right: 8px;
  border-radius: 8px;
  background: transparent;
  border: none;
  flex-shrink: 0;
  cursor: default;
}
#dash-topnav-profile .tn-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  border: 1.5px solid rgba(204,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  color: #fff;
  background: rgba(204,0,0,.25);
  flex-shrink: 0;
}
#dash-topnav-profile .tn-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
#dash-topnav-profile .tn-name {
  font-size: .78rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}
#dash-topnav-profile .tn-wcoin {
  font-size: .7rem;
  color: #f59e0b;
  white-space: nowrap;
}

/* ── Group label (category divider) ── */
.dash-tn-group-label {
  font-size: .56rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,.2);
  padding: 0 8px;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: center;
  user-select: none;
}

/* ── Menu buttons ── */
.dash-tn-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 38px;
  padding: 0 13px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: rgba(255,255,255,.5);
  font-size: .78rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color .15s, background .15s, border-color .15s;
}
.dash-tn-btn .tn-btn-icon {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}
.dash-tn-btn .tn-btn-label {
  font-size: .88rem;
  letter-spacing: .01em;
}
.dash-tn-btn:hover {
  color: rgba(255,255,255,.9);
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.1);
}
.dash-tn-btn.active {
  color: #fff;
  background: rgba(204,0,0,.18);
  border-color: rgba(204,0,0,.45);
  box-shadow: 0 0 10px rgba(204,0,0,.15);
}
.dash-tn-btn.active .tn-btn-icon {
  filter: drop-shadow(0 0 4px rgba(255,80,80,.5));
}

/* ── LAYOUT 3: COMPACT SIDEBAR ──────────────────────────────
   Sidebar is narrow icon-only, content gets more space.
   Tooltip shown on hover.
   ─────────────────────────────────────────────────────────── */
body.layout-compact .dashboard-grid {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 16px;
  align-items: start;
}

body.layout-compact .dashboard-grid > aside {
  position: sticky;
  top: 82px;
}

body.layout-compact .sidebar-card {
  overflow: visible !important;
  position: relative;
  z-index: 200;
}
body.layout-compact .dashboard-grid > aside {
  z-index: 200;
}

body.layout-compact .sb-profile-banner { display: none; }

body.layout-compact .dashboard-grid > aside .sidebar-card > div[style*="margin-top:-36px"] {
  padding: 10px 8px 8px !important;
  margin-top: 0 !important;
  display: flex;
  flex-direction: column;
  align-items: center;
}

body.layout-compact .user-avatar {
  width: 40px !important;
  height: 40px !important;
  font-size: .9rem !important;
  border-width: 2px !important;
}

body.layout-compact .user-name { display: none; }
body.layout-compact #sidebar-vip { display: none; }
body.layout-compact #sidebar-join { display: none; }
body.layout-compact #tour-replay-btn { display: none; }

body.layout-compact .dashboard-grid > aside .sb-stat-pill,
body.layout-compact .dashboard-grid > aside div[style*="grid-template-columns:1fr 1fr"] {
  display: none;
}

body.layout-compact .dashboard-grid > aside div[style*="height:1px"] { display: none; }

body.layout-compact .sidebar-menu {
  padding: 6px 6px 12px !important;
}

body.layout-compact .sidebar-group-label { display: none; }

body.layout-compact .sidebar-menu-item {
  position: relative;
  border-radius: 10px !important;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2px auto !important;
  padding: 0 !important;
  /* Hide all text content — only ::before (emoji) shows */
  color: transparent !important;
  font-size: 0 !important;
  overflow: visible;
}

/* Show only the emoji via data-icon attribute */
body.layout-compact .sidebar-menu-item::before {
  content: attr(data-icon);
  font-size: 1.3rem;
  line-height: 1;
  color: rgba(255,255,255,.7);
  display: block;
}
body.layout-compact .sidebar-menu-item.active::before,
body.layout-compact .sidebar-menu-item:hover::before {
  color: #fff;
}

/* Tooltip on hover */
body.layout-compact .sidebar-menu-item:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-2);
  border: 1px solid rgba(255,255,255,.12);
  color: #fff;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  z-index: 99999;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  pointer-events: none;
}

.sb-currency-row { cursor: default; }

/* ── LAYOUT 4: CENTERED ──────────────────────────────────────
   Aside hidden. JS builds a profile strip + pill menu above content.
   ─────────────────────────────────────────────────────────── */
body.layout-centered .dashboard-grid > aside { display: none; }
body.layout-centered .dashboard-grid { display: block; }

body.layout-centered .dashboard {
  max-width: 900px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

/* ── Centered header card (profile + menu) ── */
#dash-centered-header {
  background: var(--bg-card, var(--bg-2));
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 20px;
}

/* Profile strip */
#dash-centered-profile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
#dash-centered-profile .cp-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(204,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  font-weight: 700;
  color: #fff;
  background: rgba(204,0,0,.2);
  flex-shrink: 0;
}
#dash-centered-profile .cp-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
#dash-centered-profile .cp-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}
#dash-centered-profile .cp-wcoin {
  font-size: .82rem;
  color: #f59e0b;
}
#dash-centered-profile .cp-spacer { flex: 1; }

/* ── Group tabs row ── */
#dash-centered-groups {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
#dash-centered-groups::-webkit-scrollbar { display: none; }

.cm-group-tab {
  flex-shrink: 0;
  padding: 11px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: rgba(255,255,255,.45);
  font-size: .82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cm-group-tab:hover { color: rgba(255,255,255,.85); }
.cm-group-tab.active {
  color: #fff;
  border-bottom-color: var(--red, #cc0000);
}

/* ── Items row for selected group ── */
#dash-centered-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px;
  min-height: 52px;
  align-items: center;
}

.cm-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: rgba(255,255,255,.55);
  font-size: .82rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.cm-btn:hover {
  border-color: rgba(204,0,0,.45);
  color: #fff;
  background: rgba(204,0,0,.07);
}
.cm-btn.active {
  background: rgba(204,0,0,.18);
  border-color: rgba(204,0,0,.6);
  color: #fff;
}

/* ── RESPONSIVE: mobile drawer sidebar ── */
@media (max-width: 768px) {
  /* Grid: full width, sidebar hidden by default */
  body.layout-classic .dashboard-grid,
  body.layout-compact .dashboard-grid,
  body.layout-topnav  .dashboard-grid {
    grid-template-columns: 1fr !important;
  }

  /* Sidebar vira drawer lateral */
  body.layout-classic .dashboard-grid > aside,
  body.layout-compact .dashboard-grid > aside {
    position: fixed !important;
    top: 0;
    left: -280px;
    width: 280px;
    bottom: 0;
    z-index: 1100;
    background: var(--bg-1, #0a0a0e);
    border-right: 1px solid rgba(200,0,0,0.2);
    transition: left 0.3s ease;
    transform: none !important;
    overflow: hidden !important;
    padding: 0 !important;
  }
  body.layout-classic .dashboard-grid > aside .sidebar-card,
  body.layout-compact .dashboard-grid > aside .sidebar-card {
    margin-top: 70px;
    height: calc(100% - 70px) !important;
    max-height: calc(100% - 70px) !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    border-radius: 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 40px) !important;
  }
  body.layout-classic .dashboard-grid > aside.mob-open,
  body.layout-compact .dashboard-grid > aside.mob-open {
    left: 0;
    box-shadow: 4px 0 32px rgba(0,0,0,0.7);
  }

  /* Overlay ao abrir sidebar */
  #dash-mob-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1099;
    backdrop-filter: blur(2px);
  }
  #dash-mob-overlay.active { display: block; }

  /* Botão toggle da sidebar (removido, usa bottom bar agora) */
  #dash-mob-toggle { display: none !important; }

  /* mob-open: garantir scroll no iOS — sem transform! */
  .dashboard-grid > aside.mob-open .sidebar-card {
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch;
    transform: none !important;
  }

  /* Compact sidebar fixes on mobile */
  body.layout-compact .sidebar-card { overflow: hidden !important; }
  body.layout-compact .sb-profile-banner { display: block; }
  body.layout-compact .user-name,
  body.layout-compact #sidebar-vip { display: revert; }
  body.layout-compact .sidebar-group-label { display: block; }
  body.layout-compact .sidebar-menu-item {
    width: auto !important;
    height: auto !important;
    font-size: .83rem !important;
    padding: 9px 14px !important;
    justify-content: flex-start !important;
  }
  body.layout-topnav .dashboard-grid > aside { position: static !important; }

  /* Dashboard main padding */
  .dashboard { padding: 80px 12px 40px !important; }
}

/* Esconder toggle em desktop */
#dash-mob-toggle { display: none; }
