/* ============================================================
   THEME.CSS — Modern Blue Dashboard
   Sistem Monitoring Indikator Mutu Rumah Sakit
   Redesign tampilan saja — TIDAK mengandung logic apapun.
   ============================================================ */

:root {
  --color-primary: #2563EB;
  --color-secondary: #3B82F6;
  --color-success: #22C55E;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;
  --color-bg: #F8FAFC;
  --color-card: #FFFFFF;
  --color-border: #E5E7EB;
  --color-text: #111827;
  --color-text-secondary: #6B7280;

  --radius-card: 16px;
  --radius-btn: 10px;
  --radius-input: 10px;
  --shadow-soft: 0 8px 24px rgba(0,0,0,.06);
  --shadow-hover: 0 12px 32px rgba(0,0,0,.10);

  --sidebar-width: 260px;
  --sidebar-width-collapsed: 84px;
  --topbar-height: 70px;
}

/* ============================================================
   BASE
   ============================================================ */
* { box-sizing: border-box; }

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'Inter', 'Segoe UI', sans-serif;
  font-size: 14.5px;
}

a { text-decoration: none; }

.text-muted, .text-secondary { color: var(--color-text-secondary) !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

.app-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  transition: margin-left .25s ease;
}
.app-shell.collapsed .app-main { margin-left: var(--sidebar-width-collapsed); }

.app-content {
  padding: 28px 32px 48px;
  flex: 1;
  width: 100%;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.app-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: #FFFFFF;
  border-right: 1px solid var(--color-border);
  z-index: 1030;
  display: flex;
  flex-direction: column;
  transition: width .25s ease;
  overflow-x: hidden;
}
.app-shell.collapsed .app-sidebar { width: var(--sidebar-width-collapsed); }

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  white-space: nowrap;
}
.sidebar-brand .brand-icon {
  width: 38px; height: 38px;
  min-width: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.sidebar-brand .brand-text { font-weight: 700; font-size: 15.5px; color: var(--color-text); overflow: hidden; }
.sidebar-brand .brand-text small { display: block; font-size: 11px; font-weight: 400; color: var(--color-text-secondary); }
.app-shell.collapsed .brand-text { display: none; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
}
.sidebar-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #9CA3AF;
  font-weight: 700;
  margin: 18px 10px 8px;
  white-space: nowrap;
}
.app-shell.collapsed .sidebar-section-title { display: none; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-btn);
  color: #374151;
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 3px;
  white-space: nowrap;
  position: relative;
  transition: background .15s ease, color .15s ease;
}
.sidebar-link i { font-size: 17px; color: var(--color-primary); width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { background: #EFF6FF; color: var(--color-primary); }
.sidebar-link.active {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37,99,235,.28);
}
.sidebar-link.active i { color: #fff; }
.sidebar-link .badge-count {
  margin-left: auto;
  background: var(--color-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}
.sidebar-link.active .badge-count { background: rgba(255,255,255,.28); }
.app-shell.collapsed .sidebar-link span.link-label,
.app-shell.collapsed .sidebar-link .badge-count { display: none; }
.app-shell.collapsed .sidebar-link { justify-content: center; }

.sidebar-user {
  border-top: 1px solid var(--color-border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-user .avatar-sm {
  width: 36px; height: 36px; min-width:36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.sidebar-user .user-meta { overflow: hidden; white-space: nowrap; }
.sidebar-user .user-meta strong { display: block; font-size: 13px; color: var(--color-text); }
.sidebar-user .user-meta small { font-size: 11.5px; color: var(--color-text-secondary); }
.app-shell.collapsed .sidebar-user .user-meta { display: none; }

/* ============================================================
   TOPBAR
   ============================================================ */
.app-topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 1020;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.sidebar-toggle-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--color-border);
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-secondary);
  cursor: pointer;
}
.sidebar-toggle-btn:hover { background: #F1F5F9; }
.page-title-block h1 {
  font-size: 19px;
  font-weight: 700;
  margin: 0;
  color: var(--color-text);
  display: flex; align-items: center; gap: 10px;
}
.page-title-block h1 i { color: var(--color-primary); font-size: 18px; }
.page-title-block .page-date { font-size: 12px; color: var(--color-text-secondary); }

.topbar-right { display: flex; align-items: center; gap: 18px; }
.period-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: #F1F5F9; color: var(--color-text);
  font-size: 13px; font-weight: 600;
  padding: 8px 16px; border-radius: 20px;
  border: 1px solid var(--color-border);
}
.period-chip i { color: var(--color-primary); }
.topbar-icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-secondary);
  background: #F8FAFC;
  position: relative;
  font-size: 17px;
  border: none;
  cursor: pointer;
}
.topbar-icon-btn:hover { background: #EFF6FF; color: var(--color-primary); }
.topbar-icon-btn .dot {
  position: absolute; top: 7px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-danger);
  border: 2px solid #fff;
}
.topbar-profile { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.topbar-profile .avatar-sm {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.topbar-profile .profile-meta strong { display: block; font-size: 13.5px; line-height: 1.2; }
.topbar-profile .profile-meta small { font-size: 11px; color: var(--color-text-secondary); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card) !important;
  box-shadow: var(--shadow-soft);
  transition: box-shadow .2s ease, transform .2s ease;
}
.card-header {
  background: #fff !important;
  color: var(--color-text) !important;
  border-bottom: 1px solid var(--color-border) !important;
  border-radius: var(--radius-card) var(--radius-card) 0 0 !important;
  font-weight: 600;
  padding: 16px 22px;
}
.card-header.bg-primary, .card-header.bg-secondary,
.card-header.bg-success, .card-header.bg-danger, .card-header.bg-info {
  background: #fff !important;
  color: var(--color-text) !important;
  border-left: 3px solid var(--color-primary);
}
.card-body { padding: 22px; }

/* KPI stat cards */
.kpi-card {
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border);
  background: #fff;
  box-shadow: var(--shadow-soft);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  transition: transform .2s ease, box-shadow .2s ease;
  height: 100%;
}
.kpi-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.kpi-card .kpi-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.kpi-card .kpi-icon.icon-primary { background: #DBEAFE; color: var(--color-primary); }
.kpi-card .kpi-icon.icon-success { background: #DCFCE7; color: #16A34A; }
.kpi-card .kpi-icon.icon-warning { background: #FEF3C7; color: #D97706; }
.kpi-card .kpi-icon.icon-danger  { background: #FEE2E2; color: #DC2626; }
.kpi-card .kpi-icon.icon-info    { background: #E0E7FF; color: #4338CA; }
.kpi-card .kpi-label { font-size: 12.5px; color: var(--color-text-secondary); font-weight: 600; margin-bottom: 4px; text-transform: uppercase; letter-spacing:.02em;}
.kpi-card .kpi-value { font-size: 26px; font-weight: 800; color: var(--color-text); line-height: 1.1; }
.kpi-card .kpi-sub { font-size: 12px; color: var(--color-text-secondary); margin-top: 2px; }

/* legacy .stat-card kept as alias so old markup still looks right */
.stat-card {
  border-radius: var(--radius-card) !important;
  border: 1px solid var(--color-border) !important;
  border-left: 4px solid var(--color-primary) !important;
  box-shadow: var(--shadow-soft);
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.stat-card.border-success { border-left-color: var(--color-success) !important; }
.stat-card.border-info { border-left-color: #6366F1 !important; }
.stat-card.border-warning { border-left-color: var(--color-warning) !important; }
.stat-card.border-danger { border-left-color: var(--color-danger) !important; }
.stat-card.border-primary { border-left-color: var(--color-primary) !important; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  border-radius: var(--radius-btn) !important;
  font-weight: 600;
  font-size: 13.5px;
  padding: 9px 18px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all .18s ease;
  position: relative;
  overflow: hidden;
}
.btn-primary { background: var(--color-primary) !important; border-color: var(--color-primary) !important; }
.btn-primary:hover { background: #1D4ED8 !important; border-color: #1D4ED8 !important; transform: translateY(-1px); }
.btn-success { background: var(--color-success) !important; border-color: var(--color-success) !important; }
.btn-success:hover { background: #16A34A !important; border-color: #16A34A !important; transform: translateY(-1px); }
.btn-danger { background: var(--color-danger) !important; border-color: var(--color-danger) !important; }
.btn-danger:hover { background: #DC2626 !important; border-color: #DC2626 !important; transform: translateY(-1px); }
.btn-warning { background: var(--color-warning) !important; border-color: var(--color-warning) !important; color:#fff !important; }
.btn-warning:hover { background: #D97706 !important; border-color: #D97706 !important; color:#fff !important; }
.btn-outline-primary { color: var(--color-primary) !important; border-color: var(--color-primary) !important; }
.btn-outline-primary:hover { background: var(--color-primary) !important; }
.btn-secondary { background: #64748B !important; border-color: #64748B !important; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* button ripple */
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.55);
  transform: scale(0);
  animation: ripple-anim .5s ease-out;
  pointer-events: none;
}
@keyframes ripple-anim { to { transform: scale(3); opacity: 0; } }

/* ============================================================
   FORMS
   ============================================================ */
.form-label { font-weight: 600; font-size: 13px; color: var(--color-text); margin-bottom: 6px; }
.form-control, .form-select {
  border-radius: var(--radius-input) !important;
  border: 1px solid var(--color-border);
  min-height: 44px;
  font-size: 14px;
  padding: 8px 14px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea.form-control { min-height: 90px; }
.form-text { font-size: 12px; color: var(--color-text-secondary); }

/* realtime percentage preview box */
.realtime-preview {
  border-radius: var(--radius-input);
  border: 1.5px dashed var(--color-secondary);
  background: #EFF6FF;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.realtime-preview .rt-label { font-size: 12.5px; color: var(--color-text-secondary); font-weight: 600; }
.realtime-preview .rt-value { font-size: 24px; font-weight: 800; color: var(--color-primary); }

/* ============================================================
   TABLES
   ============================================================ */
.table-responsive { border-radius: var(--radius-card); overflow: hidden; border: 1px solid var(--color-border); }
.table { margin-bottom: 0; }
.table thead th {
  background: #F1F5F9;
  color: #475569;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .03em;
  font-weight: 700;
  border-bottom: none;
  padding: 13px 16px;
  white-space: nowrap;
}
.table tbody td { padding: 13px 16px; vertical-align: middle; font-size: 13.5px; border-color: var(--color-border); }
.table-hover tbody tr:hover { background: #F8FAFC; }
.table-striped tbody tr:nth-of-type(odd) { background: #FBFCFD; }
.table thead th.sticky-col, thead.sticky-top th { position: sticky; top: 0; z-index: 2; }

/* search / pagination */
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.table-search { position: relative; max-width: 320px; width: 100%; }
.table-search input {
  border-radius: 20px !important;
  padding-left: 38px !important;
  border: 1px solid var(--color-border);
  min-height: 40px;
}
.table-search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--color-text-secondary); }

.pagination .page-link {
  border-radius: 8px !important;
  margin: 0 3px;
  border: 1px solid var(--color-border);
  color: var(--color-text);
}
.pagination .page-item.active .page-link { background: var(--color-primary); border-color: var(--color-primary); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  border-radius: 20px !important;
  font-weight: 600;
  font-size: 11.5px;
  padding: 5px 11px;
}
.badge.bg-success { background: var(--color-success) !important; }
.badge.bg-warning { background: var(--color-warning) !important; color:#fff !important; }
.badge.bg-danger { background: var(--color-danger) !important; }
.badge.bg-primary { background: var(--color-primary) !important; }
.badge.bg-info { background: #6366F1 !important; }
.badge.bg-secondary { background: #94A3B8 !important; }

/* ============================================================
   ALERTS (kept as fallback; toast is primary now)
   ============================================================ */
.alert { border-radius: 12px; border: 1px solid transparent; }
.alert-success { background: #F0FDF4; color: #166534; border-color: #BBF7D0; }
.alert-danger  { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.alert-warning { background: #FFFBEB; color: #92400E; border-color: #FDE68A; }
.alert-info    { background: #EFF6FF; color: #1E40AF; border-color: #BFDBFE; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-stack {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.app-toast {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-left: 4px solid var(--color-primary);
  animation: toast-in .25s ease;
  font-size: 13.5px;
}
.app-toast.toast-success { border-left-color: var(--color-success); }
.app-toast.toast-danger { border-left-color: var(--color-danger); }
.app-toast.toast-warning { border-left-color: var(--color-warning); }
.app-toast i { font-size: 18px; margin-top: 1px; }
.app-toast.toast-success i { color: var(--color-success); }
.app-toast.toast-danger i { color: var(--color-danger); }
.app-toast.toast-warning i { color: var(--color-warning); }
.app-toast.toast-info i { color: var(--color-primary); }
.app-toast .toast-close { margin-left: auto; cursor: pointer; color: #9CA3AF; background:none; border:none; }
@keyframes toast-in { from { opacity:0; transform: translateX(30px);} to {opacity:1; transform:translateX(0);} }
@keyframes toast-out { to { opacity:0; transform: translateX(30px);} }

/* ============================================================
   PROGRESS / LOADING / SKELETON
   ============================================================ */
.progress { border-radius: 20px; height: 10px; background: #E5E7EB; }
.progress-bar { background: var(--color-primary); }

.spinner-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,.7);
  display:flex; align-items:center; justify-content:center; z-index: 3000;
}
.spinner-brand { width: 44px; height: 44px; border: 4px solid #DBEAFE; border-top-color: var(--color-primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   MODAL - pastikan stacking order & interaktivitas selalu benar
   (mencegah "seluruh halaman tidak bisa diklik" akibat backdrop
   nyangkut di atas modal atau z-index ketimpa aturan lain)
   ============================================================ */
.modal { z-index: 1055; }
.modal-backdrop { z-index: 1050; }
.modal-dialog, .modal-content { position: relative; z-index: 1; pointer-events: auto; }

.skeleton {
  background: linear-gradient(90deg, #EEF2F6 25%, #E2E8F0 37%, #EEF2F6 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* empty state */
.empty-state { text-align:center; padding: 48px 20px; color: var(--color-text-secondary); }
.empty-state i { font-size: 42px; color: #CBD5E1; margin-bottom: 12px; display:block; }
.empty-state strong { color: var(--color-text); display:block; margin-bottom:4px; font-size:15px; }

/* tooltip tweak */
.tooltip-inner { border-radius: 8px; font-size: 12px; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
.fade-in { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity:0; transform: translateY(6px);} to { opacity:1; transform: translateY(0);} }
.slide-in { animation: slideIn .3s ease both; }
@keyframes slideIn { from { opacity:0; transform: translateX(-10px);} to { opacity:1; transform: translateX(0);} }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-primary) 0%, #1E3A8A 100%);
  padding: 24px;
}
.login-card {
  border-radius: 20px !important;
  border: none;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow: hidden;
  max-width: 420px;
  width: 100%;
}
.login-card .login-icon {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color:#fff; display:flex; align-items:center; justify-content:center;
  font-size: 28px; margin: 0 auto 14px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991px) {
  .app-sidebar { transform: translateX(-100%); width: var(--sidebar-width); transition: transform .25s ease; }
  .app-shell.sidebar-open .app-sidebar { transform: translateX(0); }
  .app-main { margin-left: 0 !important; }
  .app-shell.collapsed .brand-text,
  .app-shell.sidebar-open .brand-text { display: block; }
  .app-shell .sidebar-link span.link-label { display: inline; }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 1025;
  }
  .app-shell.sidebar-open .sidebar-backdrop { display: block; }
}
@media (max-width: 576px) {
  .app-content { padding: 18px 14px 36px; }
  .kpi-card { flex-direction: row; }
  .app-topbar { padding: 0 14px; }
  .topbar-profile .profile-meta { display: none; }
}
