/**
 * layout.css — Sidebar, Navbar, Grid Bento, Responsif
 * =====================================================
 * Pola: DESIGN.md §Layout (72px sidebar, 12-col bento, breakpoints)
 * Stitch: member_home (sidebar + topbar), open_access_top (navbar publik)
 */

/* ══════════════════════════════════════════
   A. NAVBAR PUBLIK (open_access)
   ══════════════════════════════════════════ */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: var(--z-topbar);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--gutter);
}

[data-theme="dark"] .navbar {
  background: rgba(10, 19, 48, 0.85);
}

.navbar__inner {
  max-width: var(--content-max);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

/* Brand */
.navbar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  color: var(--text-strong);
  flex-shrink: 0;
}

.navbar__logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xl);
  background: var(--primary-900);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-400);
  position: relative;
}

.navbar__logo-dot {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--accent-400);
  position: absolute;
  top: -2px;
  right: -2px;
  border: 2px solid var(--surface);
}

.navbar__title {
  font: var(--headline-sm);
  letter-spacing: var(--headline-sm-ls);
  color: var(--primary-900);
}

/* Nav Menu (pill container) */
.navbar__menu {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: var(--surface-muted);
  border-radius: var(--radius-full);
}

.navbar__link {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  font: var(--label-md);
  letter-spacing: var(--label-md-ls);
  color: var(--text-muted);
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.navbar__link:hover {
  color: var(--text-strong);
}

.navbar__link.active {
  background: var(--primary-900);
  color: var(--text-on-dark);
  box-shadow: var(--shadow-sm);
}

/* Nav Actions */
.navbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ══════════════════════════════════════════
   B. SIDEBAR MEMBER / ADMIN (72px, icon-only)
   ══════════════════════════════════════════ */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-lg) 0;
  box-shadow: 1px 0 8px rgba(0, 0, 0, 0.08);
  transition: transform var(--transition-normal);
}

.sidebar__logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-xl);
  background: var(--secondary-600);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.sidebar__logo svg,
.sidebar__logo .icon {
  width: 24px;
  height: 24px;
  color: var(--text-on-dark);
}

/* Nav Items */
.sidebar__nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  width: 100%;
  padding: 0 var(--space-xs);
  overflow-y: auto;
}

.sidebar__item {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text);
  transition: all var(--transition-fast);
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar__item:hover {
  background: var(--primary-800);
  color: var(--text-on-dark);
}

.sidebar__item.active {
  background: var(--surface);
  color: var(--primary-900);
  box-shadow: var(--shadow-sm);
}

.sidebar__item svg,
.sidebar__item .icon {
  width: 22px;
  height: 22px;
}

/* Badge pada ikon sidebar */
.sidebar__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font: var(--label-sm);
  letter-spacing: var(--label-sm-ls);
  line-height: 1;
  box-shadow: 0 0 0 2px var(--sidebar-bg);
}

.sidebar__badge--live {
  background: var(--accent-400);
  color: var(--primary-900);
}

.sidebar__badge--new {
  background: var(--secondary-600);
  color: var(--text-on-dark);
}

.sidebar__badge--count {
  background: var(--danger);
  color: var(--text-on-dark);
}

/* Tooltip sidebar */
.sidebar__tooltip {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 10px;
  background: var(--primary-900);
  color: var(--text-on-dark);
  font: var(--label-sm);
  letter-spacing: var(--label-sm-ls);
  border-radius: var(--radius-md);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: var(--z-tooltip);
}

.sidebar__item:hover .sidebar__tooltip {
  opacity: 1;
}

/* Footer sidebar (settings + logout) */
.sidebar__footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
}

.sidebar__item--logout:hover {
  background: var(--danger);
  color: var(--text-on-dark);
}

/* ══════════════════════════════════════════
   C. TOPBAR MEMBER / ADMIN
   ══════════════════════════════════════════ */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .topbar {
  background: rgba(16, 27, 69, 0.90);
}

/* Search di topbar */
.topbar__search {
  position: relative;
  width: 100%;
  max-width: 480px;
}

.topbar__search-icon {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.topbar__search-input {
  width: 100%;
  height: 44px;
  padding-left: 44px;
  padding-right: var(--space-md);
  background: var(--surface-muted);
  border-radius: var(--radius-full);
  font: var(--body-sm);
  color: var(--text-strong);
  transition: background var(--transition-fast);
}

.topbar__search-input:focus {
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--secondary-600);
}

/* Actions di topbar */
.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.topbar__icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  position: relative;
}

.topbar__icon-btn:hover {
  background: var(--surface-muted);
  color: var(--text-strong);
}

.topbar__notif-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--danger);
  position: absolute;
  top: 8px;
  right: 8px;
}

/* Profile di topbar */
.topbar__profile {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding-left: var(--space-sm);
}

.topbar__avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary-600);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-on-dark);
  font: var(--label-md);
  overflow: hidden;
}

.topbar__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.topbar__name {
  font: var(--label-md);
  letter-spacing: var(--label-md-ls);
  color: var(--text-strong);
}

.topbar__role {
  font: var(--body-sm);
  color: var(--text-muted);
  margin-top: 1px;
}

/* ══════════════════════════════════════════
   D. AREA KONTEN UTAMA
   ══════════════════════════════════════════ */

/* Layout publik (dengan navbar, tanpa sidebar) */
.layout-public {
  padding-top: var(--navbar-height);
  min-height: 100vh;
}

/* Layout member/admin (dengan sidebar + topbar) */
.layout-app {
  padding-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
}

.layout-app__content {
  width: 100%;
  padding: var(--gutter);
  min-height: calc(100vh - var(--topbar-height));
}

/* ══════════════════════════════════════════
   E. GRID BENTO (12 Kolom)
   ══════════════════════════════════════════ */
.bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--gutter);
  width: 100%;
}

.bento--auto {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Span helpers */
.col-1  { grid-column: span 1; }
.col-2  { grid-column: span 2; }
.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-5  { grid-column: span 5; }
.col-6  { grid-column: span 6; }
.col-7  { grid-column: span 7; }
.col-8  { grid-column: span 8; }
.col-9  { grid-column: span 9; }
.col-10 { grid-column: span 10; }
.col-11 { grid-column: span 11; }
.col-12 { grid-column: span 12; }

/* Grid khusus member home (8 + 4) */
.grid-home {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

/* Grid 2, 3, 4 kolom */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-md); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-md); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-md); }

/* Section container */
.section {
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.section--wide {
  max-width: var(--max-width);
}

.section--full {
  max-width: none;
}

/* ══════════════════════════════════════════
   F. FOOTER
   ══════════════════════════════════════════ */
.footer {
  background: var(--primary-900);
  color: var(--text-on-dark-muted);
  padding: var(--space-2xl) var(--gutter);
}

.footer a {
  color: var(--text-on-dark-muted);
  transition: color var(--transition-fast);
}

.footer a:hover {
  color: var(--text-on-dark);
}

.footer__inner {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
}

/* ══════════════════════════════════════════
   G. MOBILE BOTTOM BAR (< 768px)
   ══════════════════════════════════════════ */
.bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: var(--z-sidebar);
  padding: var(--space-xs) var(--space-sm);
  box-shadow: var(--shadow-top);
}

.bottom-bar__nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 100%;
}

.bottom-bar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font: var(--label-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
  padding: var(--space-xs);
}

.bottom-bar__item.active {
  color: var(--primary-600);
}

.bottom-bar__item svg,
.bottom-bar__item .icon {
  width: 22px;
  height: 22px;
}

/* ══════════════════════════════════════════
   H. RESPONSIVE BREAKPOINTS
   ══════════════════════════════════════════ */

/* Desktop besar ≥ 1280px */
@media (min-width: 1280px) {
  .grid-home {
    grid-template-columns: 2fr 1fr;
  }
}

/* Desktop ≥ 1024px */
@media (min-width: 1024px) {
  .hide-desktop { display: none !important; }
}

/* Tablet 768–1023px */
@media (max-width: 1023px) {
  .hide-tablet { display: none !important; }

  .bento {
    grid-template-columns: repeat(6, 1fr);
  }

  .col-4, .col-3 { grid-column: span 3; }
  .col-8, .col-7, .col-9, .col-10, .col-11, .col-12 { grid-column: span 6; }

  .grid-4 { grid-template-columns: repeat(2, 1fr); }

  .navbar__menu { display: none; }
}

/* Mobile < 768px */
@media (max-width: 767px) {
  :root {
    --gutter: var(--gutter-mobile);
    --margin: var(--margin-mobile);
  }

  .hide-mobile { display: none !important; }

  .bento {
    grid-template-columns: 1fr;
  }

  .col-1, .col-2, .col-3, .col-4, .col-5, .col-6,
  .col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
    grid-column: span 1;
  }

  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

  .grid-home {
    grid-template-columns: 1fr;
  }

  /* Sidebar tersembunyi di mobile */
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Topbar full-width di mobile */
  .topbar {
    left: 0;
  }

  /* Konten tanpa padding sidebar */
  .layout-app {
    padding-left: 0;
  }

  /* Bottom bar muncul */
  .bottom-bar {
    display: block;
  }

  /* Konten beri ruang untuk bottom bar */
  .layout-app__content {
    padding-bottom: 80px;
  }

  .layout-public {
    padding-bottom: 80px;
  }

  /* Profil di topbar disembunyikan */
  .topbar__name,
  .topbar__role {
    display: none;
  }
}

/* Mobile kecil < 480px */
@media (max-width: 479px) {
  h1, .display-lg {
    font: var(--display-lg-mobile);
    letter-spacing: var(--display-lg-ls);
  }
}
