/* ==========================================================================
   Dashboard V2 – SISGRE1
   Flat Design 2.0: Leve, Fluido, Moderno
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --dash-sidebar-w: 260px;
  --dash-sidebar-collapsed: 72px;
  --dash-topbar-h: 60px;
  --dash-bg: #f8fafc;
  --dash-surface: #ffffff;
  --dash-surface-hover: #f1f5f9;
  --dash-text: #0f172a;
  --dash-text-secondary: #475569;
  --dash-text-muted: #94a3b8;
  --dash-border: #e2e8f0;
  --dash-border-light: #f1f5f9;
  
  --dash-primary: #3b82f6;
  --dash-primary-light: #dbeafe;
  --dash-primary-dark: #2563eb;
  --dash-success: #10b981;
  --dash-success-light: #d1fae5;
  --dash-warning: #f59e0b;
  --dash-warning-light: #fef3c7;
  --dash-danger: #ef4444;
  --dash-danger-light: #fee2e2;
  --dash-info: #06b6d4;
  --dash-info-light: #cffafe;
  --dash-purple: #8b5cf6;
  --dash-purple-light: #ede9fe;
  
  --dash-radius: 12px;
  --dash-radius-sm: 8px;
  --dash-radius-lg: 16px;
  --dash-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
  --dash-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.03);
  --dash-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --dash-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  
  --dash-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --dash-transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--dash-bg);
  color: var(--dash-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.dash-wrapper {
  display: flex;
  min-height: 100vh;
  background: var(--dash-bg);
}

/* ---------- Sidebar ---------- */
.dash-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--dash-sidebar-w);
  background: var(--dash-surface);
  border-right: 1px solid var(--dash-border);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transition: transform var(--dash-transition-slow), width var(--dash-transition-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

.dash-sidebar::-webkit-scrollbar {
  width: 4px;
}

.dash-sidebar::-webkit-scrollbar-thumb {
  background: var(--dash-border);
  border-radius: 4px;
}

.dash-sidebar-logo {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--dash-border);
  flex-shrink: 0;
  height: var(--dash-topbar-h);
}

.dash-sidebar-logo img {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.dash-sidebar-logo .logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--dash-text);
  letter-spacing: -0.02em;
}

.dash-sidebar-logo .logo-sub {
  font-size: 0.65rem;
  color: var(--dash-text-muted);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Navigation */
.dash-nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.dash-nav-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dash-text-muted);
  padding: 8px 12px 8px;
  margin-top: 8px;
}

.dash-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--dash-radius-sm);
  color: var(--dash-text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--dash-transition);
  margin-bottom: 2px;
  position: relative;
}

.dash-nav-item i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.dash-nav-item:hover {
  background: var(--dash-surface-hover);
  color: var(--dash-text);
}

.dash-nav-item.active {
  background: var(--dash-primary-light);
  color: var(--dash-primary-dark);
  font-weight: 600;
}

.dash-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--dash-primary);
  border-radius: 0 3px 3px 0;
}

/* Sidebar Footer */
.dash-sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--dash-border);
  flex-shrink: 0;
}

.dash-sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--dash-text-secondary);
  font-size: 0.875rem;
}

.dash-sidebar-footer .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--dash-primary), var(--dash-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
  flex-shrink: 0;
}

/* ---------- Main Area ---------- */
.dash-main {
  flex: 1;
  margin-left: var(--dash-sidebar-w);
  transition: margin-left var(--dash-transition-slow);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar ---------- */
.dash-topbar {
  height: var(--dash-topbar-h);
  background: var(--dash-surface);
  border-bottom: 1px solid var(--dash-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1040;
  flex-shrink: 0;
}

.dash-topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dash-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--dash-text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--dash-radius-sm);
  transition: all var(--dash-transition);
}

.dash-menu-toggle:hover {
  background: var(--dash-surface-hover);
  color: var(--dash-text);
}

.dash-greeting {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--dash-text);
}

.dash-greeting span {
  font-weight: 400;
  color: var(--dash-text-muted);
}

.dash-topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dash-topbar-btn {
  position: relative;
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: var(--dash-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dash-text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--dash-transition);
}

.dash-topbar-btn:hover {
  background: var(--dash-surface-hover);
  color: var(--dash-primary);
}

.dash-topbar-btn .badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--dash-danger);
  border-radius: 50%;
  border: 2px solid var(--dash-surface);
}

.dash-topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--dash-primary), var(--dash-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  transition: box-shadow var(--dash-transition);
  margin-left: 8px;
  text-decoration: none;
}

.dash-topbar-avatar:hover {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ---------- Content ---------- */
.dash-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.dash-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.dash-page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--dash-text);
  letter-spacing: -0.02em;
}

.dash-page-subtitle {
  font-size: 0.85rem;
  color: var(--dash-text-muted);
  margin-top: 2px;
}

.dash-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.dash-last-update {
  font-size: 0.75rem;
  color: var(--dash-text-muted);
  margin-top: 4px;
}

/* ---------- KPI Cards ---------- */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.dash-kpi-card {
  background: var(--dash-surface);
  border-radius: var(--dash-radius);
  padding: 20px;
  border: 1px solid var(--dash-border);
  position: relative;
  transition: all var(--dash-transition);
  animation: dashFadeInUp 0.4s ease both;
}

.dash-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--dash-shadow-md);
  border-color: var(--dash-primary-light);
}

.dash-kpi-card:nth-child(1) { animation-delay: 0.05s; }
.dash-kpi-card:nth-child(2) { animation-delay: 0.08s; }
.dash-kpi-card:nth-child(3) { animation-delay: 0.11s; }
.dash-kpi-card:nth-child(4) { animation-delay: 0.14s; }
.dash-kpi-card:nth-child(5) { animation-delay: 0.17s; }
.dash-kpi-card:nth-child(6) { animation-delay: 0.2s; }
.dash-kpi-card:nth-child(7) { animation-delay: 0.23s; }
.dash-kpi-card:nth-child(8) { animation-delay: 0.26s; }

.dash-kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dash-kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
}

.dash-kpi-change {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
}

.dash-kpi-change.up {
  color: var(--dash-success);
  background: var(--dash-success-light);
}

.dash-kpi-change.down {
  color: var(--dash-danger);
  background: var(--dash-danger-light);
}

.dash-kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--dash-text);
  line-height: 1.1;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.dash-kpi-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--dash-text-muted);
}

/* ---------- Chart Cards ---------- */
.dash-chart-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.dash-chart-grid.cols-2 {
  grid-template-columns: 1.5fr 1fr;
}

.dash-chart-grid.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.dash-chart-card {
  background: var(--dash-surface);
  border-radius: var(--dash-radius);
  border: 1px solid var(--dash-border);
  overflow: hidden;
  animation: dashFadeInUp 0.4s ease both;
  animation-delay: 0.3s;
}

.dash-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
}

.dash-chart-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--dash-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-chart-title i {
  color: var(--dash-primary);
}

.dash-chart-subtitle {
  font-size: 0.75rem;
  color: var(--dash-text-muted);
  margin-top: 2px;
}

.dash-chart-body {
  padding: 16px 20px 20px;
  position: relative;
}

.dash-chart-body canvas {
  width: 100% !important;
}

/* Gauge */
.dash-gauge-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
}

.dash-gauge-info h3 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--dash-primary);
  margin: 0;
}

.dash-gauge-info p {
  font-size: 0.8rem;
  color: var(--dash-text-muted);
  margin: 4px 0 0;
}

.dash-gauge-canvas {
  width: 120px;
  height: 70px;
  flex-shrink: 0;
}

/* ---------- Bottom Grid ---------- */
.dash-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* ---------- Notifications ---------- */
.dash-notif-card {
  background: var(--dash-surface);
  border-radius: var(--dash-radius);
  border: 1px solid var(--dash-border);
  overflow: hidden;
  animation: dashFadeInUp 0.4s ease both;
  animation-delay: 0.4s;
}

.dash-notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--dash-border);
}

.dash-notif-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--dash-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-notif-title i {
  color: var(--dash-warning);
}

.dash-notif-badge {
  background: var(--dash-danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

.dash-notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
}

.dash-notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--dash-border-light);
  transition: background var(--dash-transition);
  cursor: default;
}

.dash-notif-item:last-child {
  border-bottom: none;
}

.dash-notif-item:hover {
  background: var(--dash-surface-hover);
}

.dash-notif-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.dash-notif-icon.info {
  background: var(--dash-info-light);
  color: var(--dash-info);
}

.dash-notif-icon.success {
  background: var(--dash-success-light);
  color: var(--dash-success);
}

.dash-notif-icon.warning {
  background: var(--dash-warning-light);
  color: var(--dash-warning);
}

.dash-notif-icon.danger {
  background: var(--dash-danger-light);
  color: var(--dash-danger);
}

.dash-notif-text {
  flex: 1;
  min-width: 0;
}

.dash-notif-text strong {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--dash-text);
  display: block;
  margin-bottom: 2px;
}

.dash-notif-text span {
  font-size: 0.75rem;
  color: var(--dash-text-muted);
}

.dash-notif-time {
  font-size: 0.7rem;
  color: var(--dash-text-muted);
  flex-shrink: 0;
  margin-top: 2px;
}

/* ---------- Buttons ---------- */
.dash-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--dash-radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--dash-transition);
  text-decoration: none;
}

.dash-btn-primary {
  background: var(--dash-primary);
  color: #fff;
}

.dash-btn-primary:hover {
  background: var(--dash-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.dash-btn-outline {
  background: transparent;
  color: var(--dash-text-secondary);
  border: 1px solid var(--dash-border);
}

.dash-btn-outline:hover {
  background: var(--dash-surface-hover);
  color: var(--dash-text);
}

/* ---------- Animations ---------- */
@keyframes dashFadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Overlay ---------- */
.dash-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1045;
  backdrop-filter: blur(2px);
}

.dash-overlay.active {
  display: block;
}

/* ---------- Notifications Toast ---------- */
.dash-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--dash-surface);
  border-radius: var(--dash-radius-sm);
  box-shadow: var(--dash-shadow-lg);
  border: 1px solid var(--dash-border);
  padding: 14px 16px;
  min-width: 280px;
  max-width: 360px;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: slideInRight 0.25s ease-out;
}

.dash-notification-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--dash-text);
}

.dash-notification-content i {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.dash-notification-success .dash-notification-content i { color: var(--dash-success); }
.dash-notification-error .dash-notification-content i { color: var(--dash-danger); }
.dash-notification-info .dash-notification-content i { color: var(--dash-info); }

.dash-notification-close {
  background: none;
  border: none;
  color: var(--dash-text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: all var(--dash-transition);
  flex-shrink: 0;
}

.dash-notification-close:hover {
  background: var(--dash-surface-hover);
  color: var(--dash-text);
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---------- Loading ---------- */
.dash-loading {
  position: relative;
  overflow: hidden;
}

.dash-loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  animation: loading 1.2s infinite;
}

@keyframes loading {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* ---------- Skip Link ---------- */
.dash-skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--dash-primary);
  color: #fff;
  padding: 8px 14px;
  z-index: 9999;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 0 0 6px 0;
  transition: top 0.2s;
}

.dash-skip-link:focus {
  top: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .dash-chart-grid.cols-2 {
    grid-template-columns: 1fr;
  }
  
  .dash-bottom-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 992px) {
  .dash-sidebar {
    transform: translateX(-100%);
  }
  
  .dash-sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.15);
  }
  
  .dash-main {
    margin-left: 0;
  }
  
  .dash-menu-toggle {
    display: flex;
  }
  
  .dash-content {
    padding: 20px;
  }
  
  .dash-bottom-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .dash-topbar {
    padding: 0 16px;
  }
  
  .dash-greeting {
    font-size: 0.85rem;
  }
  
  .dash-content {
    padding: 16px;
  }
  
  .dash-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .dash-kpi-card {
    padding: 16px;
  }
  
  .dash-kpi-value {
    font-size: 1.4rem;
  }
  
  .dash-kpi-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  
  .dash-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .dash-header-actions {
    width: 100%;
  }
  
  .dash-header-actions .dash-btn {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .dash-kpi-grid {
    grid-template-columns: 1fr;
  }
  
  .dash-topbar-right .dash-topbar-btn:not(:first-child) {
    display: none;
  }
}

/* ---------- Print ---------- */
@media print {
  .dash-sidebar, .dash-topbar, .dash-overlay, .dash-menu-toggle, .dash-notification { display: none !important; }
  .dash-main { margin-left: 0 !important; }
  .dash-kpi-card, .dash-chart-card, .dash-notif-card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}

/* ---------- Utility Colors for KPIs ---------- */
.kpi-primary { --kpi-color: var(--dash-primary); }
.kpi-success { --kpi-color: var(--dash-success); }
.kpi-warning { --kpi-color: var(--dash-warning); }
.kpi-danger { --kpi-color: var(--dash-danger); }
.kpi-info { --kpi-color: var(--dash-info); }
.kpi-purple { --kpi-color: var(--dash-purple); }

.dash-kpi-card.kpi-primary .dash-kpi-icon { background: var(--dash-primary); }
.dash-kpi-card.kpi-success .dash-kpi-icon { background: var(--dash-success); }
.dash-kpi-card.kpi-warning .dash-kpi-icon { background: var(--dash-warning); }
.dash-kpi-card.kpi-danger .dash-kpi-icon { background: var(--dash-danger); }
.dash-kpi-card.kpi-info .dash-kpi-icon { background: var(--dash-info); }
.dash-kpi-card.kpi-purple .dash-kpi-icon { background: var(--dash-purple); }
