/* =========================================================
   Aplikasi Stok Barang - Tema "JAGO" (Sidebar Layout)
   PT. Tirta Investama Cianjur
   ========================================================= */

:root {
  --navy-dark: #0a1f44;
  --navy-mid: #123a76;
  --navy-light: #1a56b0;
  --content-bg: #eef3fb;
  --accent-green: #1f8a4c;
  --text-navy: #0a1f44;
  --topbar-height: 84px; /* PATCH: sebelumnya 108px */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: linear-gradient(160deg, var(--navy-dark) 0%, var(--navy-mid) 45%, var(--navy-light) 100%);
  font-family: 'Segoe UI', Tahoma, Verdana, sans-serif;
  color: var(--text-navy);
  min-height: 100vh;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar {
  width: 240px; /* PATCH: sebelumnya 280px */
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-dark) 0%, var(--navy-mid) 100%);
  display: flex;
  flex-direction: column;
  padding: 0 16px 20px;
  position: relative;
  overflow: hidden;
  transition: width 0.25s ease, left 0.3s ease;
}

.sidebar-logo-box {
  background: #ffffff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  height: var(--topbar-height);
  margin: 0 -16px 20px;
  position: relative;
  z-index: 2;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(10, 31, 68, 0.08);
}

.sidebar-brand-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-brand-fallback {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy-light), var(--navy-dark));
  color: #fff;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.sidebar-brand-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--navy-dark);
  letter-spacing: 0.5px;
}

.sidebar-brand-sub {
  font-size: 0.66rem;
  color: #6b7280;
  font-weight: 600;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-plant {
  font-size: 0.62rem;
  color: var(--navy-light);
  font-weight: 700;
  margin-top: 2px;
}

.sidebar-menu {
  flex-grow: 1;
  position: relative;
  z-index: 2;
  overflow-y: auto;
}
.sidebar-menu .nav-link {
  color: #cfe0ff;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: 12px;
  padding: 11px 14px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.15s ease;
}
.sidebar-menu .nav-link i {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
}
.sidebar-menu .nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: #ffffff;
}
.sidebar-menu .nav-link.active {
  background: #ffffff;
  color: var(--navy-light);
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
.sidebar-menu .dropdown-menu {
  background: #0f2c5c;
  border: none;
  border-radius: 10px;
  padding: 6px;
}
.sidebar-menu .dropdown-item {
  color: #cfe0ff;
  font-size: 0.88rem;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-menu .dropdown-item:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.sidebar::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 220px;
  background: radial-gradient(ellipse at 30% 100%, rgba(255,255,255,0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: 1;
}

/* =========================================================
   MAIN PANEL
   ========================================================= */
.main-panel {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-header {
  background:
    radial-gradient(ellipse 500px 260px at 88% 130%, rgba(198, 222, 250, 0.55) 0%, transparent 70%),
    radial-gradient(ellipse 380px 220px at 68% -30%, rgba(198, 222, 250, 0.35) 0%, transparent 70%),
    #ffffff;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: relative;
  z-index: 2;
  box-shadow: 0 2px 10px rgba(10, 31, 68, 0.08);
}

.jago-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.jago-title-wrap { display: inline-block; }
.jago-brand h1 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--navy-dark);
  margin: 0;
  line-height: 1.15;
  white-space: nowrap;
}
.jago-brand p {
  font-size: 0.6rem;
  color: var(--navy-light);
  font-weight: 700;
  margin: 3px 0 0 0;
  border-top: 2px solid var(--navy-light);
  display: block;
  width: 100%;
  padding-top: 2px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 1;
  white-space: nowrap;
}
.user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #eef3fb;
  border: 1.5px solid var(--navy-light);
  display: flex; align-items: center; justify-content: center;
  color: var(--navy-light);
  font-size: 1.1rem;
  flex-shrink: 0;
}
.user-name { font-weight: 600; color: var(--text-navy); font-size: 0.95rem; }
.user-role-badge {
  background: var(--navy-dark);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
}

.user-menu-dropdown { position: relative; }
.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 4px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.user-menu-toggle:hover { background: #f3f7fd; }
.user-menu-toggle::after { display: none; }
.user-menu-info { text-align: left; line-height: 1.3; }
.user-menu-caret {
  font-size: 0.75rem;
  color: #9aa7ba;
  margin-left: 2px;
  transition: transform 0.15s ease;
}
.user-menu-toggle[aria-expanded="true"] .user-menu-caret { transform: rotate(180deg); }

.user-dropdown-menu {
  border: none;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(10, 31, 68, 0.18);
  padding: 8px;
  min-width: 200px;
  margin-top: 10px !important;
}
.user-dropdown-menu .dropdown-item {
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-navy);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-dropdown-menu .dropdown-item i { font-size: 1rem; width: 18px; }
.user-dropdown-menu .dropdown-item:hover { background: #eef3fb; }
.user-dropdown-menu .dropdown-item.text-danger:hover { background: #fdecec; }
.user-dropdown-menu .dropdown-divider { margin: 6px 4px; }

.login-link { color: var(--navy-light); text-decoration: none; font-weight: 600; }
.login-link:hover { color: var(--navy-dark); text-decoration: underline; }

.content-area {
  flex-grow: 1;
  background: var(--content-bg);
  padding: 28px 32px;
  position: relative;
  overflow: hidden;
}
.content-area::before {
  content: "";
  position: absolute;
  top: -40px; right: -60px;
  width: 380px; height: 380px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 400'%3E%3Ccircle cx='200' cy='200' r='200' fill='%23dbe9fb' fill-opacity='0.5'/%3E%3C/svg%3E");
  background-size: contain;
  pointer-events: none;
  z-index: 0;
}
.content-area > * { position: relative; z-index: 1; }

.page-title-bar {
  border-left: 5px solid var(--navy-light);
  padding-left: 14px;
  margin-bottom: 4px;
}
.page-title-bar h4 { font-weight: 800; color: var(--navy-dark); margin-bottom: 2px; }

.card { border: none; border-radius: 16px; box-shadow: 0 3px 14px rgba(10, 31, 68, 0.07); }

.stat-card {
  display: flex; align-items: center; gap: 16px; padding: 20px;
  background: #fff; overflow: hidden; position: relative;
}
.stat-icon {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: #fff; flex-shrink: 0;
}
.stat-icon.blue   { background: linear-gradient(135deg, #2f7bd8, #1650a0); }
.stat-icon.green  { background: linear-gradient(135deg, #34c78e, #1f8a4c); }
.stat-icon.red    { background: linear-gradient(135deg, #f2545b, #c0392b); }
.stat-icon.orange { background: linear-gradient(135deg, #ffb35c, #f08a24); }
.stat-icon.purple { background: linear-gradient(135deg, #a06bd6, #6a3fb0); }

.stat-card-link { display: block; text-decoration: none; }
.stat-card-link .stat-card { transition: transform 0.15s ease, box-shadow 0.15s ease; cursor: pointer; }
.stat-card-link:hover .stat-card { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(10, 31, 68, 0.12); }

.stat-label { color: #7c8aa0; font-size: 0.85rem; font-weight: 600; }
.stat-value { font-size: 1.9rem; font-weight: 800; color: var(--text-navy); line-height: 1.1; }
.stat-sub { font-size: 0.78rem; color: #9aa7ba; margin-top: 2px; }

.stat-card::after {
  content: "";
  position: absolute; right: 0; bottom: 0; width: 90px; height: 60px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 60'%3E%3Cpath d='M0 60 C 30 10 60 50 100 0 L100 60 Z' fill='%23eef3fb'/%3E%3C/svg%3E");
  background-size: cover;
  pointer-events: none;
}

.table thead { background-color: #f3f7fd; }
.table thead th { color: var(--navy-dark); font-weight: 700; font-size: 0.85rem; border-bottom: none; }
.table td, .table th { vertical-align: middle; }
.table tbody tr:hover { background-color: #f8fbff; }

.btn-primary { background-color: var(--navy-light); border-color: var(--navy-light); }
.btn-primary:hover { background-color: var(--navy-dark); border-color: var(--navy-dark); }

.badge-stok-aman { background-color: var(--accent-green) !important; }
.badge-stok-rendah { background-color: #d9463f !important; }

.app-footer {
  background: linear-gradient(180deg, var(--navy-mid) 0%, var(--navy-dark) 100%);
  color: #cfe0ff; padding: 26px 20px 18px; text-align: center; position: relative; overflow: hidden;
}
.app-footer::before {
  content: "";
  position: absolute; top: -1px; left: 0; right: 0; height: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 60' preserveAspectRatio='none'%3E%3Cpath fill='%23eef3fb' d='M0 30 C 200 60 400 0 600 25 C 800 50 1000 5 1200 30 L1200 0 L0 0 Z'/%3E%3C/svg%3E");
  background-size: cover;
}
.app-footer .footer-taglines { font-weight: 700; font-size: 0.92rem; color: #ffffff; margin-bottom: 6px; }
.app-footer .footer-taglines i { color: #6fc2ff; margin: 0 6px; }
.app-footer .footer-copy { font-size: 0.78rem; color: #9fb4d6; }

.login-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--navy-dark) 0%, var(--navy-light) 100%);
}
.login-card { width: 100%; max-width: 400px; }
.signature-pad { cursor: crosshair; background-color: #fff; }
.login-avatar-badge {
  width: 64px; height: 64px; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; margin: 0 auto;
}

.toast-container-custom {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast-jago {
  background: #ffffff; border-radius: 12px; box-shadow: 0 8px 24px rgba(10, 31, 68, 0.18);
  padding: 14px 16px; display: flex; align-items: flex-start; gap: 10px;
  position: relative; overflow: hidden; animation: toastSlideIn 0.35s ease forwards;
  border-left: 4px solid var(--accent-green);
}
.toast-jago.toast-danger { border-left-color: #d9463f; }
.toast-icon { font-size: 1.3rem; flex-shrink: 0; margin-top: 1px; }
.toast-success .toast-icon { color: var(--accent-green); }
.toast-danger .toast-icon { color: #d9463f; }
.toast-msg { flex-grow: 1; font-size: 0.88rem; color: var(--text-navy); line-height: 1.4; padding-right: 6px; }
.toast-close { background: none; border: none; color: #9aa7ba; cursor: pointer; font-size: 1rem; line-height: 1; flex-shrink: 0; padding: 0; }
.toast-close:hover { color: var(--text-navy); }
.toast-progress { position: absolute; bottom: 0; left: 0; height: 3px; background: var(--accent-green); animation: toastProgress 4.5s linear forwards; }
.toast-danger .toast-progress { background: #d9463f; }
.toast-jago.toast-hide { animation: toastSlideOut 0.3s ease forwards; }

@keyframes toastSlideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastSlideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(120%); opacity: 0; } }
@keyframes toastProgress { from { width: 100%; } to { width: 0%; } }

.live-clock-box {
  display: flex; flex-direction: column; align-items: flex-end;
  margin-right: 6px; padding-right: 14px; border-right: 1px solid #dfe6ef;
}
.live-clock-time { font-weight: 800; font-size: 1rem; color: var(--navy-dark); font-variant-numeric: tabular-nums; line-height: 1.1; }
.live-clock-date { font-size: 0.7rem; color: #8a97ab; font-weight: 600; margin-top: 2px; }

.notif-bell-wrap { position: relative; }
.notif-bell-btn {
  width: 38px; height: 38px; border-radius: 50%; background: #eef3fb; border: none;
  display: flex; align-items: center; justify-content: center; color: var(--navy-light);
  font-size: 1.1rem; cursor: pointer; position: relative; flex-shrink: 0;
}
.notif-bell-btn:hover { background: #dde9fa; }
.notif-badge-count {
  position: absolute; top: -3px; right: -3px; background: #d9463f; color: #fff;
  font-size: 0.62rem; font-weight: 800; min-width: 17px; height: 17px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff; padding: 0 3px;
}
.notif-panel {
  position: absolute; top: 48px; right: 0; width: 320px; background: #fff; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(10, 31, 68, 0.2); padding: 14px; display: none; z-index: 50;
  max-height: 360px; overflow-y: auto;
}
.notif-panel.show { display: block; animation: toastSlideIn 0.2s ease; }
.notif-panel-title { font-weight: 800; color: var(--navy-dark); font-size: 0.9rem; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.notif-item { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid #f0f3f8; font-size: 0.83rem; }
.notif-item:last-child { border-bottom: none; }
.notif-item-name { color: var(--text-navy); font-weight: 600; }
.notif-item-sub { color: #9aa7ba; font-size: 0.74rem; }
.notif-item-badge { background: #fdecec; color: #d9463f; font-weight: 700; font-size: 0.72rem; padding: 3px 8px; border-radius: 8px; white-space: nowrap; }
.notif-empty { text-align: center; color: #9aa7ba; font-size: 0.85rem; padding: 16px 0; }

.sidebar-toggle-btn {
  width: 38px; height: 38px; border-radius: 10px; background: #eef3fb; border: none;
  color: var(--navy-light); display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; cursor: pointer; flex-shrink: 0; margin-right: 6px;
}
.sidebar-toggle-btn:hover { background: #dde9fa; }

.app-shell.sidebar-collapsed .sidebar { width: 84px; }
.app-shell.sidebar-collapsed .sidebar-brand-info,
.app-shell.sidebar-collapsed .sidebar-menu .nav-link span.menu-text,
.app-shell.sidebar-collapsed .sidebar-menu .dropdown-menu { display: none !important; }
.app-shell.sidebar-collapsed .sidebar-logo-box { justify-content: center; padding: 10px 6px; }
.app-shell.sidebar-collapsed .sidebar-menu .nav-link { justify-content: center; padding: 11px; }
.app-shell.sidebar-collapsed .sidebar-menu .nav-link i { margin: 0; width: auto; font-size: 1.25rem; }
.sidebar-menu .nav-link span.menu-text { transition: opacity 0.15s ease; }

.chart-card {
  background: #fff; border-radius: 16px; padding: 20px; box-shadow: 0 3px 14px rgba(10, 31, 68, 0.07);
  overflow-x: auto;
}
.chart-card-title { font-weight: 800; color: var(--navy-dark); font-size: 0.95rem; margin-bottom: 4px; }
.chart-legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

.live-search-box { position: relative; max-width: 320px; }
.live-search-box input { padding-left: 38px; border-radius: 10px; border: 1px solid #dfe6ef; }
.live-search-box i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #9aa7ba; }

.welcome-banner {
  background: linear-gradient(120deg, var(--navy-dark), var(--navy-light));
  border-radius: 16px; padding: 20px 24px; color: #fff; margin-bottom: 20px;
  box-shadow: 0 4px 14px rgba(10,31,68,0.15);
}
.welcome-banner h4 { font-weight: 800; margin: 0 0 4px; }
.welcome-banner p { margin: 0; color: #dce8fb; font-size: 0.9rem; }

/* =========================================================
   PATCH BARU: Accordion Detail Pengambilan Barang per Departemen
   ========================================================= */
.detail-dept-item {
  border: 1px solid #eef1f6;
  border-radius: 10px !important;
  margin-bottom: 8px;
  overflow: hidden;
}
.detail-dept-item .accordion-button {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--navy-dark);
  background: #f8fafd;
  padding: 12px 16px;
}
.detail-dept-item .accordion-button:not(.collapsed) {
  background: var(--navy-light);
  color: #fff;
  box-shadow: none;
}
.detail-dept-item .accordion-button:not(.collapsed) .badge {
  background: rgba(255,255,255,0.2) !important;
  color: #fff !important;
  border-color: transparent !important;
}
.detail-dept-item .accordion-button:focus { box-shadow: none; }
.detail-dept-item .accordion-button::after { margin-left: 8px; }
.detail-dept-item .table { font-size: 0.85rem; }
.detail-dept-item .table thead th { background: #f3f7fd; font-size: 0.75rem; }

@media (max-width: 991px) {
  .app-shell { position: relative; }
  .top-header { padding: 0 20px; }
}

/* =========================================================
   RESPONSIVE MOBILE (HP) - sidebar jadi drawer slide dari kiri
   ========================================================= */
@media (max-width: 768px) {
  .app-shell { flex-direction: row; }

  .sidebar {
    position: fixed; top: 0; left: -240px; height: 100%; width: 240px;
    z-index: 1050; box-shadow: 4px 0 20px rgba(0,0,0,0.25);
  }
  .app-shell.sidebar-mobile-open .sidebar { left: 0; }

  .sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(10, 31, 68, 0.45); z-index: 1040;
  }
  .app-shell.sidebar-mobile-open .sidebar-overlay { display: block; }

  .main-panel { width: 100%; }

  .top-header { height: auto; min-height: 64px; padding: 10px 16px; flex-wrap: nowrap; }
  .jago-brand h1 { font-size: 0.95rem; }
  .jago-brand p { font-size: 0.55rem; }

  .live-clock-box { display: none; }
  .user-menu-info { display: none !important; }

  .content-area { padding: 16px; }

  .stat-value { font-size: 1.4rem; }
  .stat-icon { width: 44px; height: 44px; font-size: 1.1rem; }
  .stat-card { padding: 14px; gap: 12px; }

  .notif-panel { width: 90vw; right: -70px; }
  .welcome-banner { padding: 16px 18px; }
}
