/* =======================================================================
   Fanbel Owner — Theme (variables, base, layout, navigation, preloader)
   Inspired by foodappi (Tailwind tokens) + weblama (PWA preloader)
   ======================================================================= */

:root {
  /* Brand — Fanbel Orange (matching logo PT. Fanbel Jaya Bersama) */
  --fb-primary: #E84A1F;
  --fb-primary-600: #C73A12;
  --fb-primary-700: #A82E0C;
  --fb-primary-50: #FDE9E2;
  --fb-primary-100: #F9C9B8;
  --fb-primary-soft: rgba(232, 74, 31, 0.08);

  /* Accent / status */
  --fb-secondary: #1F1F39;
  --fb-accent: #F5A623;            /* gold from logo (used for charts/highlights only) */
  --fb-purple: #8b5cf6;
  --fb-purple-soft: rgba(139, 92, 246, 0.12);
  --fb-blue: #1E5A8E;              /* blue from logo (kept for variety, sparingly) */
  --fb-blue-soft: rgba(30, 90, 142, 0.12);
  --fb-yellow: #F5A623;            /* alias of accent */
  --fb-yellow-soft: rgba(245, 166, 35, 0.12);
  --fb-green: #10b981;
  --fb-green-soft: rgba(16, 185, 129, 0.12);
  --fb-cyan: #06b6d4;
  --fb-cyan-soft: rgba(6, 182, 212, 0.12);
  --fb-red: #ef4444;
  --fb-red-soft: rgba(239, 68, 68, 0.12);
  --fb-gray-soft: rgba(100, 116, 139, 0.12);

  /* Neutrals */
  --fb-heading: #1F1F39;
  --fb-text: #4b5563;
  --fb-paragraph: #6E7191;
  --fb-muted: #A0A3BD;
  --fb-border: #EFF0F6;
  --fb-border-strong: #d9dbe9;
  --fb-bg: #f7f7fc;
  --fb-surface: #ffffff;
  --fb-surface-2: #fafafd;

  /* Effects */
  --fb-radius-sm: 8px;
  --fb-radius: 14px;
  --fb-radius-lg: 20px;
  --fb-radius-xl: 28px;
  --fb-radius-pill: 999px;

  --fb-shadow-xs: 0 2px 6px rgba(67, 89, 113, 0.06);
  --fb-shadow-sm: 0 2px 6px rgba(67, 89, 113, 0.12);
  --fb-shadow: 0 8px 24px rgba(31, 31, 57, 0.06);
  --fb-shadow-lg: 0 18px 40px rgba(31, 31, 57, 0.08);
  --fb-shadow-primary: 0 12px 28px rgba(232, 74, 31, 0.25);

  --fb-transition: all 0.25s ease;

  /* Layout */
  --fb-sidebar-w: 260px;
  --fb-topbar-h: 68px;

  /* Type */
  --fb-font-sans: 'Public Sans', 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --fb-font-display: 'Rubik', 'Public Sans', sans-serif;
}

/* ----------- Reset / Base ----------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--fb-font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--fb-paragraph);
  background: var(--fb-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--fb-primary); text-decoration: none; transition: var(--fb-transition); }
a:hover { color: var(--fb-primary-700); }

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--fb-font-display);
  color: var(--fb-heading);
  font-weight: 600;
  line-height: 1.25;
}

img { max-width: 100%; height: auto; display: block; }

button { font-family: inherit; cursor: pointer; }

/* ----------- Scrollbar ----------- */
.fb-app *::-webkit-scrollbar { width: 8px; height: 8px; }
.fb-app *::-webkit-scrollbar-track { background: transparent; }
.fb-app *::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, 0.25); border-radius: 4px; }
.fb-app *::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, 0.45); }

/* ----------- Preloader ----------- */
.fb-preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--fb-primary-50) 0%, #ffffff 100%);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
.fb-preloader.is-hidden { opacity: 0; visibility: hidden; }

.fb-preloader-inner { text-align: center; }

.fb-preloader-gears {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 18px;
}
.fb-preloader-gears .fb-gear {
  position: absolute;
  font-size: 48px;
  color: var(--fb-primary);
}
.fb-preloader-gears .fb-gear-1 {
  top: 0; left: 0;
  animation: fb-gear-spin 1.8s linear infinite;
}
.fb-preloader-gears .fb-gear-2 {
  bottom: 0; right: 0;
  font-size: 32px;
  color: var(--fb-accent);
  animation: fb-gear-spin 2.4s linear infinite reverse;
}

@keyframes fb-gear-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.fb-preloader-text {
  margin: 0 0 14px;
  font-weight: 500;
  color: var(--fb-heading);
  letter-spacing: 0.5px;
}

.fb-preloader-bar-wrap {
  width: 200px;
  height: 4px;
  margin: 0 auto;
  background: rgba(0, 179, 165, 0.15);
  border-radius: 4px;
  overflow: hidden;
}
.fb-preloader-bar {
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg, var(--fb-primary), var(--fb-accent));
  border-radius: 4px;
  animation: fb-preloader-bar 1.4s ease-in-out infinite;
}
@keyframes fb-preloader-bar {
  0%   { transform: translateX(-100%); }
  50%  { transform: translateX(150%); }
  100% { transform: translateX(350%); }
}

/* ----------- App Shell ----------- */
.fb-app {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.fb-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--fb-sidebar-w);
  transition: margin-left 0.3s ease;
}

.fb-main-content {
  flex: 1;
  padding: 24px 28px 40px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ----------- Sidebar ----------- */
.fb-sidebar {
  position: fixed;
  top: 0; left: 0;
  bottom: 0;
  width: var(--fb-sidebar-w);
  background: var(--fb-surface);
  border-right: 1px solid var(--fb-border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  z-index: 60;
  transform: translateX(0);
  transition: transform 0.3s ease;
}

.fb-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 18px;
  border-bottom: 1px solid var(--fb-border);
  margin-bottom: 18px;
}
.fb-sidebar-brand { display: inline-flex; align-items: center; }
.fb-sidebar-logo { height: 44px; width: 44px; border-radius: 8px; object-fit: contain; }

.fb-sidebar-close { display: none; }

.fb-sidebar-nav { flex: 1; overflow-y: auto; }
.fb-sidebar-section { margin-bottom: 22px; }
.fb-sidebar-section-title {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--fb-muted);
  margin: 0 12px 8px;
  font-weight: 600;
}

.fb-sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--fb-radius-sm);
  color: var(--fb-text);
  font-weight: 500;
  margin-bottom: 4px;
  position: relative;
  transition: var(--fb-transition);
}
.fb-sidebar-link i { font-size: 18px; }
.fb-sidebar-link:hover {
  background: var(--fb-primary-soft);
  color: var(--fb-primary);
  transform: translateX(2px);
}
.fb-sidebar-link.active {
  background: var(--fb-primary-soft);
  color: var(--fb-primary);
  font-weight: 600;
}
.fb-sidebar-link.active::before {
  content: '';
  position: absolute;
  left: -16px; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--fb-primary);
  border-radius: 0 3px 3px 0;
}
.fb-sidebar-link-danger:hover { background: var(--fb-red-soft); color: var(--fb-red); }

.fb-sidebar-footer {
  padding: 16px 12px 4px;
  border-top: 1px solid var(--fb-border);
  text-align: center;
}
.fb-sidebar-footer-text {
  font-size: 12px;
  color: var(--fb-muted);
  margin: 0;
}

/* ----------- Topbar ----------- */
.fb-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--fb-topbar-h);
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--fb-border);
}

.fb-topbar-left { display: flex; align-items: center; gap: 14px; }
.fb-topbar-title { font-size: 18px; font-weight: 600; color: var(--fb-heading); margin: 0; }

/* Topbar brand (logo + company name + tagline) */
.fb-topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--fb-radius-sm);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
}
.fb-topbar-brand:hover { background: var(--fb-primary-soft); }
.fb-topbar-brand-mark {
  height: 44px;
  width: 44px;
  border-radius: 6px;
  object-fit: contain;
  background: #ffffff;
  flex-shrink: 0;
}
.fb-topbar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.fb-topbar-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: #E84A1F;            /* orange-red from logo */
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.fb-topbar-brand-tagline {
  font-size: 11px;
  font-weight: 500;
  color: var(--fb-muted);
  white-space: nowrap;
  margin-top: 1px;
}

/* Screen-reader only (still in DOM, but visually hidden) */
.fb-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.fb-icon-btn {
  width: 40px; height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--fb-radius-sm);
  color: var(--fb-text);
  font-size: 18px;
  transition: var(--fb-transition);
}
.fb-icon-btn:hover { background: var(--fb-primary-soft); color: var(--fb-primary); }
.fb-sidebar-toggle { display: none; }

.fb-topbar-right { display: flex; align-items: center; gap: 14px; position: relative; }

.fb-topbar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  border-radius: var(--fb-radius-pill);
  cursor: pointer;
  transition: var(--fb-transition);
}
.fb-topbar-profile:hover { background: var(--fb-primary-soft); }
.fb-topbar-profile-info { display: flex; flex-direction: column; text-align: right; }
.fb-topbar-profile-name { font-size: 14px; font-weight: 600; color: var(--fb-heading); }
.fb-topbar-profile-role { font-size: 11px; color: var(--fb-muted); }

.fb-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--fb-primary), var(--fb-primary-700));
  color: #fff;
  border-radius: 50%;
  font-weight: 600;
}
.fb-avatar-sm { width: 36px; height: 36px; font-size: 16px; }

.fb-profile-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--fb-surface);
  border: 1px solid var(--fb-border);
  border-radius: var(--fb-radius);
  box-shadow: var(--fb-shadow);
  padding: 6px;
  display: none;
  z-index: 50;
}
.fb-profile-dropdown.is-open { display: block; animation: fb-fade-down 0.2s ease; }

.fb-profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--fb-radius-sm);
  color: var(--fb-text);
  font-size: 14px;
  font-weight: 500;
}
.fb-profile-dropdown-item:hover { background: var(--fb-primary-soft); color: var(--fb-primary); }

@keyframes fb-fade-down {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----------- Backdrop (mobile) ----------- */
.fb-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 55;
  opacity: 0;
  visibility: hidden;
  transition: var(--fb-transition);
}
.fb-backdrop.is-visible { opacity: 1; visibility: visible; }

/* ----------- Responsive ----------- */
@media (max-width: 991.98px) {
  .fb-sidebar {
    transform: translateX(-100%);
    box-shadow: var(--fb-shadow-lg);
  }
  .fb-sidebar.is-open { transform: translateX(0); }
  .fb-sidebar-close { display: inline-flex; }
  .fb-main { margin-left: 0; }
  .fb-sidebar-toggle { display: inline-flex; }
  .fb-topbar-profile-info { display: none; }
  .fb-main-content { padding: 18px 16px 32px; }
  .fb-topbar { padding: 0 16px; }

  /* Topbar brand: hide tagline on mobile, shrink mark */
  .fb-topbar-brand { gap: 8px; padding: 4px 6px; }
  .fb-topbar-brand-mark { height: 38px; width: 38px; }
  .fb-topbar-brand-name { font-size: 13px; }
  .fb-topbar-brand-tagline { display: none; }
}

/* Very small screens: hide company name too, keep only the mark */
@media (max-width: 380px) {
  .fb-topbar-brand-name { display: none; }
  .fb-topbar-brand { padding: 4px; }
}

/* ----------- Animations ----------- */
.fb-fade-in { animation: fb-fade-in 0.5s ease both; }
.fb-fade-up { animation: fb-fade-up 0.5s ease both; }
.fb-stagger > * { animation: fb-fade-up 0.5s ease both; }
.fb-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.fb-stagger > *:nth-child(2) { animation-delay: 0.10s; }
.fb-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.fb-stagger > *:nth-child(4) { animation-delay: 0.20s; }
.fb-stagger > *:nth-child(5) { animation-delay: 0.25s; }
.fb-stagger > *:nth-child(6) { animation-delay: 0.30s; }
.fb-stagger > *:nth-child(7) { animation-delay: 0.35s; }
.fb-stagger > *:nth-child(8) { animation-delay: 0.40s; }

@keyframes fb-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fb-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fb-pulse-ring {
  0%   { transform: scale(0.9); opacity: 0.7; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Print: hide chrome */
@media print {
  .fb-sidebar, .fb-topbar, .fb-backdrop, .fb-preloader { display: none !important; }
  .fb-main { margin-left: 0; }
}
