/* ============================================================
   Design Tokens — GrowBe warm palette
   ============================================================ */
:root {
  /* Colors */
  --bg:        #FBF7F2;
  --card:      #ffffff;
  --border:    #F1E7DC;
  --border2:   #F6EEE5;
  --text:      #2E2A26;
  --muted:     #7C7066;
  --subtle:    #AEA294;
  --pri:       #F47A1F;
  --pri2:      #EE6B1A;
  --pri-bg:    #FFF1E4;
  --pri-light: #FFF3E8;
  --ok:        #16a34a;
  --ok-bg:     #dcfce7;
  --warn:      #f59e0b;
  --warn-bg:   #fef3c7;
  --err:       #E0492B;
  --err-bg:    #fee2e2;
  --line:      #EEE2D5;

  /* Typography */
  --font-head: 'Baloo 2', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;

  /* Layout */
  --sidebar-w:        248px;
  --sidebar-w-tablet: 78px;
  --topbar-h:         68px;
  --bnav-h:           56px;
  --radius:           14px;
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

/* ============================================================
   Login Page
   ============================================================ */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: var(--bg);
}
.login-box {
  background: var(--card);
  padding: 2rem 2.5rem;
  border-radius: 20px;
  box-shadow: 0 12px 32px rgba(120,80,30,.12);
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--border);
}
.login-logo {
  display: block;
  margin: 0 auto 1rem;
  height: 100px;
}
.login-box h2 {
  text-align: center;
  margin: 0 0 1.5rem;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--text);
}
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .88rem;
  font-weight: 800;
  margin-bottom: .3rem;
  color: var(--muted);
}
.form-group input[type="text"],
.form-group input[type="password"] {
  width: 100%;
  padding: .75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  background: var(--bg);
  transition: border-color .2s, box-shadow .2s;
  color: var(--text);
}
.form-group input:focus {
  outline: none;
  border-color: var(--pri);
  box-shadow: 0 0 0 3px rgba(244,122,31,.15);
  background: #fff;
}
.captcha-wrapper { display: flex; align-items: center; gap: .5rem; }
.captcha-text {
  background: var(--pri-bg);
  padding: .75rem 1rem;
  border-radius: 10px;
  font-family: var(--font-head);
  font-weight: 800;
  letter-spacing: 3px;
  user-select: none;
  flex-shrink: 0;
  color: var(--pri2);
  border: 1.5px dashed var(--pri);
}
.captcha-wrapper input { flex-grow: 1; }
.btn-refresh {
  background: var(--pri-bg);
  color: var(--pri2);
  border: 1.5px solid var(--border);
  padding: .5rem .75rem;
  width: auto;
  margin-top: .5rem;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: .9rem;
}
.form-message {
  text-align: center;
  margin-bottom: 1rem;
  padding: .75rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: .9rem;
}
.form-message.error   { background: var(--err-bg);  color: var(--err); }
.form-message.success { background: var(--ok-bg);   color: var(--ok); }

/* Login submit button */
.login-box .btn,
.login-box button[type="submit"] {
  width: 100%;
  padding: .85rem;
  border: none;
  border-radius: 14px;
  background: var(--pri);
  color: #fff;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(244,122,31,.28);
  transition: filter .15s;
}
.login-box .btn:hover,
.login-box button[type="submit"]:hover { filter: brightness(1.06); }

/* ============================================================
   App Shell — flex row: sidebar + main-area
   ============================================================ */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh; /* modern: excludes Android address bar */
  overflow: hidden;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 18px 14px;
  overflow-y: auto;
  z-index: 1200;
  transition: transform .25s ease;
}
.sidebar::-webkit-scrollbar { width: 0; }

/* Logo */
.sb-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 20px;
}
.sb-logo-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--pri);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(244,122,31,.35);
  overflow: hidden;
}
.sb-logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.sb-logo-text { line-height: 1; }
.sb-app-name {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 20px;
  color: var(--pri);
  line-height: 1;
}
.sb-tagline {
  font-size: 9px;
  font-weight: 800;
  color: var(--subtle);
  letter-spacing: 1.5px;
  margin-top: 3px;
}

/* Nav items */
.sb-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  transition: background .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover {
  background: var(--pri-bg);
  color: var(--pri2);
}
.nav-item-active {
  background: var(--pri-bg);
  color: var(--pri2);
  font-weight: 800;
}
.nav-ic {
  font-size: 18px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}
.nav-label { flex: 1; }

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

/* User info */
.sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 10px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  margin-top: 12px;
  flex-shrink: 0;
}
.sb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #F6C453;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 14px;
  color: #7a4a00;
  flex-shrink: 0;
}
.sb-user-info { flex: 1; min-width: 0; }
.sb-username {
  font-weight: 800;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-level {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  padding: 1px 8px;
  border-radius: 999px;
  margin-top: 2px;
}
.sb-level.lv1 { background: var(--err); }
.sb-level.lv2 { background: #f97316; }
.sb-level.lv3 { background: #2563eb; }
.sb-logout {
  font-size: 18px;
  color: var(--subtle);
  text-decoration: none;
  flex-shrink: 0;
  line-height: 1;
  padding: 4px;
  border-radius: 8px;
  transition: color .15s, background .15s;
}
.sb-logout:hover { color: var(--err); background: var(--err-bg); }

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 1100;
}
.sidebar-overlay.visible { display: block; }

/* ============================================================
   Main Area
   ============================================================ */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* modern: accounts for Android browser chrome */
  overflow: hidden;
}

/* Top Bar */
.top-bar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  flex-shrink: 0;
}
.sb-toggle {
  display: none; /* hidden on desktop */
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  padding: 6px;
  border-radius: 8px;
  line-height: 1;
  flex-shrink: 0;
}
.sb-toggle:hover { background: var(--pri-bg); color: var(--pri); }
.top-bar-title {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 20px;
  color: var(--text);
  flex: 1;
}
.top-bar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.top-clock { text-align: right; }
.top-clock-date {
  font-weight: 800;
  font-size: 13px;
  color: var(--text);
  line-height: 1.2;
}
.top-clock-time {
  font-weight: 700;
  font-size: 12px;
  color: var(--subtle);
}

/* Content area */
.content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* ============================================================
   Bottom Navigation (mobile only)
   ============================================================ */
.bottom-nav { display: none; }

/* ============================================================
   Page / Container
   ============================================================ */
.page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
.container {
  width: min(920px, 100% - 24px);
  margin: 0 auto;
}

/* ============================================================
   Form Card (sticky filter section)
   ============================================================ */
.form-card {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--card);
  border-bottom: 1.5px solid var(--border);
  padding: 14px 16px;
  box-shadow: 0 4px 16px rgba(120,80,30,.06);
}
.form-inner {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 560px) {
  .form-row { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   Inputs & Buttons (global)
   ============================================================ */
.label {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 5px;
  display: block;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.input, .select, .file {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-body);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.input:focus, .select:focus {
  border-color: var(--pri);
  box-shadow: 0 0 0 3px rgba(244,122,31,.15);
  background: #fff;
}
.btn {
  padding: 12px 18px;
  border: none;
  border-radius: 12px;
  font-weight: 800;
  font-family: var(--font-body);
  cursor: pointer;
  font-size: 15px;
  transition: filter .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-submit {
  background: var(--pri);
  color: #fff;
  box-shadow: 0 4px 14px rgba(244,122,31,.25);
}
.btn-submit:hover { filter: brightness(1.06); }

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  margin: 8px 0 12px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
}
.alert.err  { background: var(--err-bg);  color: #991b1b; }
.alert.ok   { background: var(--ok-bg);   color: #14532d; }
.alert.info { background: #e0f2fe;        color: #075985; }

/* ============================================================
   List & Cards
   ============================================================ */
.list { padding: 10px 0 28px; }
.card {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 3px 12px rgba(120,80,30,.05);
  margin-bottom: 10px;
  transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 6px 20px rgba(120,80,30,.10); }
.card.highlight {
  outline: 2px solid var(--pri);
  box-shadow: 0 8px 24px rgba(244,122,31,.18);
}
.thumb {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--pri-light);
  flex-shrink: 0;
}
.meta { flex: 1 1 auto; min-width: 0; }
.meta h3 { margin: 0; font-size: 15px; font-weight: 800; color: var(--text); }
.meta small { color: var(--subtle); font-size: 13px; }

.card-actions { display: flex; gap: 8px; }
.btn-action {
  padding: 6px 12px;
  border: 1.5px solid transparent;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  background: none;
  font-family: var(--font-body);
  transition: background .15s;
}
.btn-action.edit   { border-color: #fcd34d; color: #92400e; background: var(--warn-bg); }
.btn-action.delete { border-color: #fca5a5; color: #991b1b; background: var(--err-bg); }
.btn-action.edit:hover   { background: #fde68a; }
.btn-action.delete:hover { background: #fecaca; }

/* ============================================================
   Avatar & Level Badge
   ============================================================ */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--pri-bg);
  color: var(--pri2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
}

.level-badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: var(--subtle);
  white-space: nowrap;
}
.level-badge.lv1 { background: var(--err); }
.level-badge.lv2 { background: #f97316; }
.level-badge.lv3 { background: #2563eb; }

/* ============================================================
   Store Filter Group
   ============================================================ */
.store-filter-group {
  padding-bottom: 1rem;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 1rem;
}

/* ============================================================
   Photo Preview
   ============================================================ */
.preview { display: flex; align-items: center; gap: 10px; }
.preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
  border: 1.5px solid var(--border);
}

/* ============================================================
   Form actions
   ============================================================ */
.form-actions.edit-mode  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions.add-mode .btn-submit { width: 100%; }

/* ============================================================
   Tablet (838px–) — rail sidebar
   ============================================================ */
@media (max-width: 900px) and (min-width: 769px) {
  .sidebar {
    width: var(--sidebar-w-tablet);
    padding: 16px 0;
    align-items: center;
  }
  .sb-logo { padding: 4px 8px 20px; flex-direction: column; gap: 4px; }
  .sb-logo-text { display: none; }
  .sb-logo-icon { width: 44px; height: 44px; }

  .nav-item { padding: 11px; justify-content: center; border-radius: 14px; }
  .nav-label { display: none; }
  .nav-ic { font-size: 20px; width: auto; }

  .sb-divider { margin: 6px 12px; }

  .sb-user { flex-direction: column; gap: 6px; padding: 10px 8px; }
  .sb-user-info { display: none; }
  .sb-logout { display: none; }
}

/* ============================================================
   Mobile (≤768px) — drawer sidebar + bottom nav
   ============================================================ */
@media (max-width: 768px) {
  /* Sidebar becomes a drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,.12);
  }
  .sidebar.sidebar-open { transform: translateX(0); }

  .sb-toggle { display: flex; }

  .top-bar { padding: 0 16px; height: 60px; gap: 10px; }
  .top-bar-title { font-size: 17px; }
  .top-clock-date { font-size: 12px; }

  /* Content: add bottom padding for bottom nav */
  .content { padding-bottom: var(--bnav-h); }

  /* Absensi and Kasir pages: scrollable content */
  body.pg-absensi .content,
  body.pg-kasir .content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Bottom nav */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bnav-h);
    background: var(--card);
    border-top: 1.5px solid var(--border);
    z-index: 1050;
    justify-content: space-around;
    align-items: stretch;
    box-shadow: 0 -2px 12px rgba(120,80,30,.10);
  }
  .bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--subtle);
    border-top: 2.5px solid transparent;
    transition: color .15s;
    padding: 6px 0 8px;
  }
  .bnav-item.bnav-active {
    color: var(--pri);
    border-top-color: var(--pri);
  }
  .bnav-icon { font-size: 1.4rem; line-height: 1; }
  .bnav-label {
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
  }
}

/* ============================================================
   Desktop — hide sidebar toggle, show full sidebar
   ============================================================ */
@media (min-width: 901px) {
  .sb-toggle { display: none; }
  .sidebar-overlay { display: none !important; }
}
