/* ============================================================
   SIAKAD - Custom Stylesheet
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0891b2;
  --dark: #1e293b;
  --light: #f8fafc;
  --sidebar-width: 260px;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #2563eb;
  --topbar-height: 60px;
  --border-radius: 0.5rem;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --transition: all .2s ease;
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: #f1f5f9;
  color: #334155;
  font-size: 0.9rem;
  line-height: 1.6;
}

a { text-decoration: none; color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ============================================================
   Layout
   ============================================================ */
.wrapper {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--topbar-height);
}

.sidebar-brand .brand-logo {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

.sidebar-brand .brand-text small {
  display: block;
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--sidebar-text);
  opacity: 0.8;
}

.sidebar-nav {
  padding: 1rem 0;
  flex: 1;
}

.nav-section-title {
  padding: 0.5rem 1.5rem 0.25rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
}

.sidebar-nav .nav-item { margin: 1px 0.75rem; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  color: var(--sidebar-text);
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
}

.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.4);
}

.sidebar-nav .nav-link .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-nav .nav-link .badge {
  margin-left: auto;
  font-size: 0.65rem;
}

/* Submenu */
.sidebar-nav .nav-item.has-submenu > .nav-link::after {
  content: '›';
  margin-left: auto;
  font-size: 1.1rem;
  transition: transform .2s;
}

.sidebar-nav .nav-item.has-submenu.open > .nav-link::after {
  transform: rotate(90deg);
}

.submenu {
  display: none;
  padding: 0.25rem 0;
}

.submenu.show { display: block; }

.submenu .nav-link {
  padding-left: 2.75rem;
  font-size: 0.825rem;
  color: #94a3b8;
}

.submenu .nav-link:hover { color: #fff; }
.submenu .nav-link.active { background: rgba(37,99,235,.3); color: #93c5fd; }

/* Sidebar footer */
.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-user .user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name {
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user .user-role {
  color: #64748b;
  font-size: 0.7rem;
}

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: var(--transition);
}

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 999;
  box-shadow: var(--shadow);
}

.topbar-toggle {
  background: none;
  border: none;
  padding: 0.4rem;
  border-radius: 6px;
  cursor: pointer;
  color: #64748b;
  font-size: 1.2rem;
  display: none;
  transition: var(--transition);
}

.topbar-toggle:hover { background: #f1f5f9; color: var(--dark); }

.topbar-title {
  font-weight: 600;
  color: var(--dark);
  font-size: 1rem;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-btn {
  background: none;
  border: none;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  color: #64748b;
  font-size: 1rem;
  transition: var(--transition);
  position: relative;
}

.topbar-btn:hover { background: #f1f5f9; color: var(--dark); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.topbar-user:hover { background: #f1f5f9; border-color: #e2e8f0; }

.topbar-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 0.8rem;
}

.topbar-user .user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--dark);
}

/* ============================================================
   Page Content
   ============================================================ */
.page-content {
  padding: 1.5rem;
  flex: 1;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--dark);
  margin: 0;
}

.page-header .breadcrumb {
  margin: 0;
  font-size: 0.8rem;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-header h5, .card-header h6 {
  margin: 0;
  font-weight: 600;
  color: var(--dark);
}

.card-body { padding: 1.25rem; }

/* Stat Cards */
.stat-card {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 1.25rem;
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-icon.purple { background: #f3e8ff; color: #9333ea; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.teal { background: #ccfbf1; color: #0d9488; }

.stat-info { flex: 1; min-width: 0; }
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--dark);
  line-height: 1;
}
.stat-label {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 0.25rem;
}
.stat-change {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================================
   Tables
   ============================================================ */
.table-responsive { border-radius: var(--border-radius); }

.table {
  margin: 0;
  font-size: 0.875rem;
}

.table thead th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid #e2e8f0;
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.table tbody td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.3em 0.65em;
  border-radius: 6px;
}

.badge-aktif      { background: #dcfce7; color: #15803d; }
.badge-tidak-aktif{ background: #fee2e2; color: #dc2626; }
.badge-lulus      { background: #dbeafe; color: #1d4ed8; }
.badge-pindah     { background: #fef9c3; color: #854d0e; }
.badge-keluar     { background: #f3e8ff; color: #7e22ce; }
.badge-gaib       { background: #fef3c7; color: #d97706; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  padding: 0.45rem 1rem;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

/* ============================================================
   Forms
   ============================================================ */
.form-control, .form-select {
  font-size: 0.875rem;
  border-color: #e2e8f0;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.35rem;
}

.input-group-text {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #64748b;
  font-size: 0.875rem;
}

/* ============================================================
   Alerts / Flash Messages
   ============================================================ */
.alert {
  border-radius: var(--border-radius);
  border: none;
  font-size: 0.875rem;
  padding: 0.875rem 1rem;
}

.alert-success { background: #dcfce7; color: #15803d; }
.alert-danger { background: #fee2e2; color: #dc2626; }
.alert-warning { background: #fef9c3; color: #854d0e; }
.alert-info { background: #dbeafe; color: #1d4ed8; }

/* ============================================================
   Login Page
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 50%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px rgba(0,0,0,.3);
}

.login-logo {
  width: 64px;
  height: 64px;
  background: var(--primary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: #fff;
  margin: 0 auto 1.5rem;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark);
  text-align: center;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: #64748b;
  text-align: center;
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

/* ============================================================
   Avatar
   ============================================================ */
.avatar {
  border-radius: 50%;
  object-fit: cover;
}

.avatar-sm { width: 32px; height: 32px; }
.avatar-md { width: 48px; height: 48px; }
.avatar-lg { width: 80px; height: 80px; }
.avatar-xl { width: 120px; height: 120px; }

.avatar-placeholder {
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* ============================================================
   Detail Page
   ============================================================ */
.detail-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  color: #fff;
  margin-bottom: 1.5rem;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 0.25rem;
}

.detail-value {
  font-size: 0.9rem;
  color: var(--dark);
  font-weight: 500;
}

/* ============================================================
   Tabs
   ============================================================ */
.nav-tabs {
  border-bottom: 2px solid #e2e8f0;
  gap: 0.25rem;
}

.nav-tabs .nav-link {
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: #64748b;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.6rem 1rem;
  border-radius: 0;
  transition: var(--transition);
}

.nav-tabs .nav-link:hover { color: var(--primary); background: transparent; }
.nav-tabs .nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
}

/* ============================================================
   Search & Filter Bar
   ============================================================ */
.search-bar {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--border-radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #94a3b8;
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h6 { color: #64748b; }

/* ============================================================
   Overlay (mobile sidebar)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}

.sidebar-overlay.show { display: block; }

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================================
   Utilities
   ============================================================ */
.text-muted { color: #94a3b8 !important; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-sm { font-size: 0.8rem; }
.rounded-lg { border-radius: var(--border-radius); }

/* Bootstrap 5.3 subtle colors fallback */
.bg-primary-subtle { background-color: #dbeafe !important; }
.bg-success-subtle { background-color: #dcfce7 !important; }
.bg-danger-subtle  { background-color: #fee2e2 !important; }
.bg-warning-subtle { background-color: #fef9c3 !important; }
.bg-info-subtle    { background-color: #dbeafe !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.show {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main-content {
    margin-left: 0;
  }

  .topbar-toggle {
    display: flex;
  }

  .page-content {
    padding: 1rem;
  }
}

@media (max-width: 575.98px) {
  .stat-card { padding: 1rem; }
  .stat-value { font-size: 1.4rem; }
  .stat-icon { width: 44px; height: 44px; font-size: 1.2rem; }
  .login-card { padding: 1.75rem 1.25rem; }
  .page-content { padding: 0.75rem; }
  .card-header { flex-wrap: wrap; }
  .topbar { padding: 0 1rem; }
}

/* ============================================================
   Print
   ============================================================ */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}
