/* ============================================================
   STOK-SOKA — Layout CSS
   Sidebar, header, bottom nav, grid halaman
   ============================================================ */

/* ------------------------------------------------------------
   1. APP SHELL
   ------------------------------------------------------------ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ------------------------------------------------------------
   2. SIDEBAR (desktop)
   ------------------------------------------------------------ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--dur) var(--ease);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--r);
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  overflow: hidden;
}

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

.sidebar-brand {
  flex: 1;
  min-width: 0;
}

.sidebar-app-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-outlet-name {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.sidebar-section {
  margin-bottom: 16px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 12px;
  margin-bottom: 6px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--dur) var(--ease);
  text-decoration: none;
  margin-bottom: 2px;
  min-height: 40px;
}

.sidebar-item:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.sidebar-item.is-active {
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-weight: 600;
}

.sidebar-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-item .sidebar-badge {
  margin-left: auto;
  background: var(--danger);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease);
}

.sidebar-user:hover {
  background: var(--bg);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ------------------------------------------------------------
   3. MAIN AREA
   ------------------------------------------------------------ */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* ------------------------------------------------------------
   4. HEADER
   ------------------------------------------------------------ */
.header {
  position: sticky;
  top: 0;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 100;
}

.header-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-muted);
}

.header-menu-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ------------------------------------------------------------
   5. CONTENT
   ------------------------------------------------------------ */
.content {
  flex: 1;
  padding: 16px;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

.content-narrow {
  max-width: 720px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.page-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar .search-wrapper {
  flex: 1;
  min-width: 200px;
}

/* ------------------------------------------------------------
   6. BOTTOM NAV (mobile)
   ------------------------------------------------------------ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-inner {
  display: flex;
  height: 100%;
  align-items: stretch;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-subtle);
  font-size: 10px;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--dur) var(--ease);
  padding: 6px 4px;
  min-height: 44px;
  position: relative;
}

.bottom-nav-item:hover {
  text-decoration: none;
  color: var(--text-muted);
}

.bottom-nav-item.is-active {
  color: var(--primary);
}

.bottom-nav-item svg {
  width: 20px;
  height: 20px;
}

.bottom-nav-item .bottom-nav-badge {
  position: absolute;
  top: 6px;
  right: 50%;
  transform: translateX(14px);
  background: var(--danger);
  color: #FFFFFF;
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
}

/* ------------------------------------------------------------
   7. DRAWER (mobile menu tambahan)
   ------------------------------------------------------------ */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  z-index: 300;
  animation: fadeIn var(--dur) var(--ease);
}

.drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
  z-index: 400;
  animation: drawerIn var(--dur) var(--ease);
  max-height: 80vh;
  overflow-y: auto;
}

@keyframes drawerIn {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.drawer-handle {
  width: 40px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 999px;
  margin: 0 auto 16px;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: background var(--dur) var(--ease);
  min-height: 48px;
}

.drawer-item:hover {
  background: var(--bg);
  text-decoration: none;
}

.drawer-item svg {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
}

.drawer-item.is-danger {
  color: var(--danger);
}

.drawer-item.is-danger svg {
  color: var(--danger);
}

/* ------------------------------------------------------------
   8. RESPONSIVE
   ------------------------------------------------------------ */

/* Tablet: sidebar collapse ke icon-only */
@media (max-width: 1023px) and (min-width: 769px) {
  :root {
    --sidebar-w: 64px;
  }

  .sidebar-brand,
  .sidebar-section-title,
  .sidebar-item span:not(.sidebar-badge),
  .sidebar-user-info {
    display: none;
  }

  .sidebar-item {
    justify-content: center;
    padding: 10px;
  }

  .sidebar-item svg {
    margin: 0;
  }

  .sidebar-header {
    justify-content: center;
    padding: 12px 8px;
  }

  .sidebar-user {
    justify-content: center;
  }

  .sidebar-footer {
    padding: 8px;
  }
}

/* Mobile: sidebar hilang, bottom nav muncul */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: var(--shadow-lg);
  }

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

  .main-area {
    margin-left: 0;
    padding-bottom: var(--bottom-nav-h);
  }

  .header-menu-btn {
    display: flex;
  }

  .bottom-nav {
    display: block;
  }

  .content {
    padding: 12px;
  }

  .page-title {
    font-size: 18px;
  }

  .toolbar {
    gap: 6px;
  }

  .toolbar .search-wrapper {
    min-width: 100%;
  }
}

/* Desktop besar */
@media (min-width: 1280px) {
  .content {
    padding: 24px;
  }
}

/* ------------------------------------------------------------
   9. SIDEBAR OVERLAY (mobile)
   ------------------------------------------------------------ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  z-index: 150;
  animation: fadeIn var(--dur) var(--ease);
}

.sidebar-overlay.is-open {
  display: block;
}

@media (min-width: 769px) {
  .sidebar-overlay {
    display: none !important;
  }
}