
:root {
  /* Colors */
  --color-primary: #2563EB; /* Blue 600 */
  --color-primary-hover: #1D4ED8;
  --color-sidebar-bg: #FFFFFF; /* White */
  --color-sidebar-text: #64748B; /* Slate 500 */
  --color-sidebar-active: #EFF6FF; /* Blue 50 */
  --color-sidebar-active-text: #2563EB; /* Blue 600 */
  --color-sidebar-border: #E2E8F0; /* Slate 200 */
  --color-bg: #F8FAFC; /* Slate 50 */
  --color-surface: #FFFFFF;
  --color-text: #0F172A;
  --color-text-muted: #64748B;
  --color-border: #E2E8F0;
  
  /* Status Colors */
  --color-success: #10B981;
  --color-success-bg: #D1FAE5;
  --color-warning: #F59E0B;
  --color-warning-bg: #FEF3C7;
  --color-danger: #EF4444;
  --color-danger-bg: #FEE2E2;
  --color-info: #3B82F6;
  --color-info-bg: #DBEAFE;

  /* Typography */
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  
  /* Metrics */
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, margin { margin: 0; }

body p {
    margin-bottom: 20px;
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; height: auto; display: block; }

/* Admin Layout */
.admin-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  border-right: 1px solid var(--color-sidebar-border);
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-sidebar-border);
}

.sidebar-nav {
  flex: 1;
  padding: 20px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: var(--color-sidebar-text);
  transition: all 0.2s;
  font-weight: 500;
  border-left: 4px solid transparent;
}
.nav-item:hover, .nav-item.active {
  background-color: var(--color-sidebar-active);
  color: var(--color-sidebar-active-text);
  border-left: 4px solid var(--color-primary);
}
.nav-icon {
  margin-right: 12px;
  width: 20px;
  text-align: center;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-search input {
  padding: 8px 16px 8px 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background-color: var(--color-bg);
  width: 300px;
  font-size: 0.875rem;
}

.content-area {
  padding: 24px;
  flex: 1;
}

/* Typography */
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.page-subtitle {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin-bottom: 24px;
}

/* Components */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  margin-bottom: 24px;
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-body {
  padding: 20px;
}

/* Grid & Layout Utilities */
.grid { display: grid; }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); gap: 20px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }

/* Dashboard Stat Cards */
.stat-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.stat-title {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--color-text);
}
.stat-trend {
  font-size: 0.875rem;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.trend-up { color: var(--color-success); }
.trend-down { color: var(--color-danger); }

/* Tables */
.table-container {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
th {
  background-color: var(--color-bg);
  padding: 12px 20px;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--color-border);
  border-top: 1px solid var(--color-border);
}
td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.875rem;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover { background-color: rgba(243, 244, 246, 0.5); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.success { background: var(--color-success-bg); color: var(--color-success); }
.badge.warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge.danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge.info { background: var(--color-info-bg); color: var(--color-info); }
.badge.draft { background: var(--color-bg); color: var(--color-text-muted); border: 1px solid var(--color-border); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.2s;
  gap: 8px;
}
.btn-primary {
  background-color: var(--color-primary);
  color: white;
}
.btn-primary:hover {
  background-color: var(--color-primary-hover);
}
.btn-secondary {
  background-color: white;
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover {
  background-color: var(--color-bg);
}
.btn-danger {
  background-color: var(--color-danger);
  color: white;
}
.btn-sm { padding: 4px 12px; font-size: 0.75rem; }

/* Forms */
.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--color-text);
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.2s;
  background: #f8fafc;
}
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 20px;
  gap: 20px;
}
.tab-item {
  padding: 12px 4px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tab-item.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.tab-item:hover:not(.active) {
  color: var(--color-text);
  border-bottom-color: var(--color-border);
}

/* Utilities */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.mt-4 { margin-top: 16px; }
.mt-2 { margin-top: 8px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }

/* Thumbnail image in table */
.img-thumbnail {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--color-border);
}

/* Public Theme (Green Accent) */
.public-theme {
  --pub-primary: #20b57e;
  --pub-primary-hover: #1b9669;
  --pub-primary-light: #e8f7f0;
}
.public-theme .btn-primary {
  background-color: var(--pub-primary);
}
.public-theme .btn-primary:hover {
  background-color: var(--pub-primary-hover);
}
.public-theme a:not(.btn) {
  transition: color 0.2s;
}
.public-theme .public-logo {
  color: var(--pub-primary);
}
.public-theme .public-nav a:hover {
  color: var(--pub-primary);
}
.public-theme .form-control:focus {
  border-color: var(--pub-primary);
  box-shadow: 0 0 0 3px rgba(32, 181, 126, 0.12);
}

/* Hamburger Menu */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  z-index: 1001;
}
.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text);
  margin: 5px 0;
  border-radius: 2px;
  transition: all 0.3s;
}
.mobile-menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
}
.mobile-menu-overlay.active {
  display: block;
  opacity: 1;
}
.mobile-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: white;
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 20px rgba(0,0,0,0.1);
}
.mobile-menu.active {
  transform: translateX(0);
}
.mobile-menu-header {
  padding: 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mobile-menu-nav {
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mobile-menu-nav a {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 1rem;
  color: var(--color-text);
  transition: background 0.2s;
}
.mobile-menu-nav a:hover {
  background: var(--color-bg);
}

/* Bottom Navigation (Portal) */
.bottom-nav {
  display: block;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 780px;
  height: 64px;
  background: white;
  border-top: 1px solid var(--color-border);
  z-index: 100;
  padding: 4px 0;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100%;
  max-width: 500px;
  margin: 0 auto;
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: 0.625rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: color 0.2s;
  min-width: 56px;
}
.bottom-nav-item.active {
  color: var(--pub-primary, var(--color-primary));
}
.bottom-nav-item svg {
  width: 22px;
  height: 22px;
}

/* Admin Mobile Sidebar */
.admin-hamburger {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
}
.admin-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-text);
  margin: 4px 0;
  border-radius: 2px;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9;
  opacity: 0;
  transition: opacity 0.3s;
}
.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* PWA Standalone Mode */
@media (display-mode: standalone) {
  body {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
  }
  .public-header, .footer {
    padding-top: env(safe-area-inset-top, 0);
  }
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

/* Responsive */
@media (max-width: 768px) {
  /* Admin */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 10;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main-content { margin-left: 0; }
  .admin-hamburger { display: block; }
  .topbar-search { display: none; }
  .topbar-user-info { display: none; }
  .content-area { padding: 16px; }
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  /* Public */
  .hamburger-btn { display: block; }
  .public-nav { display: none; }
  .public-header {
    padding: 12px 0;
    margin-bottom: 16px;
  }
  .public-container {
    padding: 12px 16px;
  }
  .public-theme .grid-cols-2 {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Portal */
  .bottom-nav { display: block; }
  .portal-sidebar { display: none !important; }
  .portal-layout {
    grid-template-columns: 1fr !important;
  }
  .portal-content {
    padding-bottom: 80px;
  }

  /* Tables on mobile → card */
  .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  td, th { padding: 10px 12px; font-size: 0.8rem; }
  .card-body { padding: 16px; }
  .card-header { padding: 12px 16px; }

  /* Forms */
  .form-control {
    padding: 12px 14px;
    font-size: 1rem;
  }
  .btn {
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  /* Mobile Footer hidden inside media query? No, we remove it from here */
}

/* Global Footer Hidden */
.footer { display: none !important; }



  /* Page title */
  .page-title { font-size: 1.25rem; }

/* App-like Home Components */
  .search-bar-container {
    position: relative;
    width: 100%;
    margin-bottom: 24px;
  }
  .search-bar-container input {
    width: 100%;
    background-color: rgb(243, 244, 246);
    border: none;
    padding: 14px 16px 14px 44px;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    color: var(--color-text);
  }
  .search-bar-container input:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--pub-primary, #20b57e);
  }
  .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
  }

  .horizontal-scroll {
    display: flex;
    overflow-x: auto;
    gap: 16px;
    padding-bottom: 12px;
    margin-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
  }
  .horizontal-scroll::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
  }
  .category-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 72px;
    text-decoration: none;
  }
  .category-icon-box {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.2s;
  }
  .category-item:hover .category-icon-box {
    transform: scale(1.05);
  }
  .category-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text);
    text-align: center;
  }

  .trending-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
  }
  .trending-card {
    display: flex;
    background: white;
    border-radius: 16px;
    padding: 12px;
    gap: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    text-decoration: none;
    color: inherit;
    position: relative;
    border: 1px solid var(--color-border);
  }
  .trending-image {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--color-bg);
  }
  .trending-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .trending-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.3;
  }
  .trending-tags {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-bottom: 8px;
  }
  .trending-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--pub-primary, #20b57e);
  }
  .trending-add-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: #111;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
  }
  .trending-card:hover .trending-add-btn {
    background: var(--pub-primary, #20b57e);
  }

  /* Search UI */
  .search-header-layout { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; padding: 12px 0; }
  .search-back-btn { color: var(--color-text); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; text-decoration: none; }
  .search-filter-btn { color: var(--color-text-muted); width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: white; border: 1px solid var(--color-border); border-radius: 8px; }
  .search-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
  .search-section-title { font-size: 1.1rem; font-weight: 700; color: var(--color-text); }
  .history-pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; background: white; border: 1px solid var(--color-border); border-radius: 12px; font-size: 0.85rem; color: var(--color-text-muted); text-decoration: none; margin-bottom: 8px; margin-right: 8px; }
  .cat-pill { display: inline-flex; align-items: center; padding: 8px 16px; background: white; border: 1px solid var(--color-border); border-radius: 20px; font-size: 0.85rem; font-weight: 500; color: var(--color-text-muted); text-decoration: none; white-space: nowrap; }
  .cat-pill.active { background: var(--pub-primary-light, #e8f7f0); border-color: transparent; color: var(--pub-primary, #20b57e); }
  .product-badge { position: absolute; top: 0; left: 0; background: var(--pub-primary, #20b57e); color: white; font-size: 0.65rem; font-weight: bold; padding: 4px 8px; border-bottom-right-radius: 8px; border-top-left-radius: 12px; z-index: 1; letter-spacing: 0.5px; }
  .rating-box { display: flex; align-items: center; gap: 4px; font-size: 0.8rem; color: var(--color-text-muted); font-weight: 600; }
  .rating-box svg { color: #F59E0B; }

@media (max-width: 480px) {
  .grid-cols-4 { grid-template-columns: 1fr; }
  .grid-cols-2 { grid-template-columns: 1fr; }
  .public-container { padding: 8px 12px; }
  .trending-list { display: flex; flex-direction: column; }
}

@media (min-width: 781px) {
  .bottom-nav {
    border-radius: 16px 16px 0 0;
  }
  .public-header,
  .search-header-layout,
  .pesanan-header-layout,
  .detail-header-layout {
    border-radius: 0 0 16px 16px;
  }
}
