/* ===
   LAYOUT.CSS - Kerangka app: header, sidebar, bottom-nav, main, FAB === */

/* === HEADER === */
.header {
  background: var(--card-bg);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hamburger-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
}

.hamburger-btn:hover {
  background: var(--bg);
}

.header-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-title {  
  flex: 1;
  cursor: pointer;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header h1 {
  font-size: 1.05rem;
  color: var(--primary);
  transition: color 0.3s;
}

.tagline {
  font-size: 0.65rem;
  color: var(--text-secondary, #6b7280);
  display: block;
}

/* === SIDEBAR === */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  z-index: 200;
  pointer-events: none;
  visibility: hidden;
}

.sidebar.open {
  pointer-events: auto;
  visibility: visible;
}

.sidebar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s;
}

.sidebar.open .sidebar-overlay {
  opacity: 1;
}

.sidebar-content {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  max-width: 85%;
  background: var(--card-bg);  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 0.3s;
  overflow-y: auto;
  padding: 16px 0;
}

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

.sidebar-header {
  padding: 12px 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

#sidebar-avatar {
  overflow : hidden;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background:linear-gradient(135deg,#2563eb,#1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  flex-shrink: 0;
}

#sidebar-photo {
  display: none;
  max-width: 100%;
  max-height: 100%; 
  border-radius: 50%;
  object-fit: cover;
}

.store-icon {
  width: 32px;
  height: 32px;
  background: transparent;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: background 0.3s;
}

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

.store-name {
  font-weight: 700;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-owner {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;  padding: 11px 19px;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font-size: 0.9rem;
  transition: background 0.2s;
}

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

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

.sidebar-icon {
  font-size: 1.2rem;
}

/* === MAIN === */
.main {
  padding: 14px;
  padding-bottom: 80px;
  max-width: 800px;
  margin: 0 auto;
}

.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.page-title {
  font-size: 1.15rem;
  margin-bottom: 14px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === BOTTOM NAV === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px 2px;
  z-index: 100;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.6rem;
  color: var(--text-secondary);
  border: none;
  background: none;
  flex: 1;
  transition: all 0.2s;
}

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

.bottom-nav-item .nav-icon {
  font-size: 1.2rem;
  margin-bottom: 2px;
}

/* === FAB === */
.chat-fab {
  position: fixed;
  bottom: 80px;
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  z-index: 99;
  transition:
    transform 0.2s,
    background 0.3s;
}

.chat-fab:hover {
  transform: scale(1.1);
}

/* === USER MENU === */
#user-menu-container {
  display: flex;
  align-items: center;
}

.user-menu {
  cursor: pointer;
  transition: transform 0.2s;
}

.user-menu:hover {
  transform: scale(1.05);
}

.user-menu-logged {
  cursor: pointer;
  transition: transform 0.2s;
}

.user-menu-logged:hover {
  transform: scale(1.05);
}

/* === USER NAME DISPLAY (BARU) === */
.user-menu-logged {
  cursor: pointer;
  transition: all 0.2s;
}

.user-menu-logged:hover {
  transform: scale(1.05);
}

.user-name-display {
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-name-display.premium {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}

.sidebar-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

/* Tombol Intal PWA
#pwa-install-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}
#pwa-install-btn:hover { 
  background: var(--primary-dark, #1d4ed8); }
#pwa-install-btn:active { 
  transform: scale(0.95); 
}

/* =========================================
   DESKTOP MODE (Layar Laptop/PC > 1024px)
   ========================================= */
@media (min-width: 1024px) {
    
    /* 1. Sidebar jadi permanen di kiri */
    .sidebar {
        visibility: visible;
        pointer-events: auto;
    }
    .sidebar-overlay {
        display: none; /* Hilangkan overlay gelap */
    }
    .sidebar-content {
        transform: none; /* Jangan slide, langsung muncul */
        border-right: 1px solid var(--border);
        box-shadow: none;
    }
    .sidebar.open .sidebar-content {
        transform: none;
    }

    /* 2. Header geser ke kanan mengikuti sidebar */
    .header {
        margin-left: var(--sidebar-width);
    }
    .hamburger-btn {
        display: none; /* Sembunyikan tombol hamburger di desktop */
    }

    /* 3. Konten utama (.main) melebar & lega */
    .main {
        margin-left: var(--sidebar-width);
        max-width: 1400px; /* Batas maksimal agar tidak terlalu lebar di monitor besar */
        margin-right: auto;
        padding: 24px 32px; /* Padding lebih lega dari mobile (14px) */
    }

    /* 4. Sembunyikan Bottom Nav */
    .bottom-nav {
        display: none;
    }

    /* 5. Sesuaikan FAB (Tombol Chat/Asisten) */
    .chat-fab {
        right: 32px;
        bottom: 32px;
    }

    /* 6. Perbaiki Tabel agar full width di desktop */
    .table-container {
        width: 100%;
    }
    
    /* 7. Stats Grid jadi 4 kolom di desktop (biar rapi) */
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Update user-name-display untuk accommodate badge */
.user-name-display {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== PAGE HEADER ROW ===== */
.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

