/**
 * MA-TEMA IZIN - Kabupaten Nias
 * Master Stylesheet
 */

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

:root {
  --font-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --primary-navy: #0B2456;
  --primary-blue: #1D4ED8;
  --primary-accent: #2B4BFF;
  --primary-light: #EBF3FC;
  --primary-hover: #1E3A8A;
  
  --bg-slate: #F4F7FC;
  --card-bg: #FFFFFF;
  --text-dark: #0F172A;
  --text-muted: #64748B;
  --border-color: #E2E8F0;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-pill: 50px;
  
  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 35px -10px rgba(11, 36, 86, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-slate);
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Base Card & Components */
.card-custom {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease-in-out;
}

.card-custom:hover {
  box-shadow: var(--shadow-md);
}

/* Buttons */
.btn-primary-custom {
  background-color: var(--primary-accent);
  color: #ffffff;
  border: none;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  transition: all 0.25s ease;
}

.btn-primary-custom:hover {
  background-color: var(--primary-hover);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(43, 75, 255, 0.25);
}

.btn-outline-custom {
  background-color: transparent;
  color: #334155;
  border: 1.5px solid #cbd5e1;
  font-weight: 600;
  border-radius: var(--radius-pill);
  padding: 10px 24px;
  transition: all 0.2s ease;
}

.btn-outline-custom:hover {
  background-color: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

/* Form Controls */
.form-control-custom {
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.95rem;
  color: #1e293b;
  transition: all 0.2s ease;
  background-color: #ffffff;
}

.form-control-custom:focus {
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 4px rgba(43, 75, 255, 0.12);
  outline: none;
}

.form-label-custom {
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
  display: block;
}

/* Status Badges */
.badge-role {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Dashboard Layout & Fixed Sidebar Utilities */
.dashboard-wrapper {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-slate);
  width: 100%;
}

.sidebar-fixed {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  height: 100vh;
  background-color: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  overflow-y: auto;
  z-index: 1030;
}

.main-content-fixed {
  margin-left: 280px;
  flex-grow: 1;
  min-height: 100vh;
  padding: 32px 40px;
  width: calc(100% - 280px);
}

@media (max-width: 991.98px) {
  .dashboard-wrapper {
    flex-direction: column;
  }
  .sidebar-fixed {
    position: relative;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .main-content-fixed {
    margin-left: 0;
    width: 100%;
    padding: 24px 16px;
  }
}

/* ==========================================================================
   Table Enhancer: Smooth Drag-to-Scroll & Responsive Tables
   ========================================================================== */
.table-responsive {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  transition: box-shadow 0.2s ease;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f8fafc;
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}

.table-responsive::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Drag-to-Scroll Hand Cursor (Tangan Terbuka saat Hover, Tangan Menggenggam saat Klik/Tahan/Drag) */
.table-responsive,
.drag-scroll-wrapper,
.table-responsive table,
.table,
table,
.table thead,
.table tbody,
.table tfoot,
.table tr,
.table th,
.table td,
table thead,
table tbody,
table tfoot,
table tr,
table th,
table td,
.table-hover tbody tr:hover,
.table-hover tbody tr:hover > * {
  cursor: grab !important;
  cursor: -webkit-grab !important;
}

/* Interactive elements retain clickable pointer or text input cursor */
.table-responsive a,
.table-responsive button,
.table-responsive .btn,
.table-responsive select,
.table-responsive input[type="checkbox"],
.table-responsive input[type="radio"],
.table-responsive label,
.table-responsive .dropdown,
.table-responsive .dropdown-menu,
.table-responsive .dropdown-item,
.table-responsive .btn-row-chevron,
.table-responsive .btn-log-chevron,
.table-responsive .badge[onclick],
.table-responsive [role="button"],
.table-responsive [onclick],
.table-responsive [data-no-drag],
.table-responsive [data-bs-toggle],
table a,
table button,
table .btn,
table select,
table input[type="checkbox"],
table input[type="radio"],
table label,
table .dropdown,
table .dropdown-menu,
table .dropdown-item,
table [role="button"],
table [onclick],
table [data-no-drag],
table [data-bs-toggle] {
  cursor: pointer !important;
}

.table-responsive input[type="text"],
.table-responsive input[type="search"],
.table-responsive input[type="email"],
.table-responsive input[type="password"],
.table-responsive input[type="number"],
.table-responsive textarea,
table input[type="text"],
table input[type="search"],
table input[type="email"],
table input[type="password"],
table input[type="number"],
table textarea {
  cursor: text !important;
}

/* Grabbing state when actively clicking and holding / dragging */
.table-responsive:active,
.drag-scroll-wrapper:active,
.table-responsive table:active,
.table:active,
table:active,
.table-responsive.is-dragging,
.table-responsive.is-dragging *,
.drag-scroll-wrapper.is-dragging,
.drag-scroll-wrapper.is-dragging * {
  cursor: grabbing !important;
  cursor: -webkit-grabbing !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

/* Scroll Shadow Gradients */
.table-responsive.is-scrollable.can-scroll-left {
  box-shadow: inset 14px 0 12px -10px rgba(0, 0, 0, 0.08);
}

.table-responsive.is-scrollable.can-scroll-right {
  box-shadow: inset -14px 0 12px -10px rgba(0, 0, 0, 0.08);
}

.table-responsive.is-scrollable.can-scroll-left.can-scroll-right {
  box-shadow: inset 14px 0 12px -10px rgba(0, 0, 0, 0.08), inset -14px 0 12px -10px rgba(0, 0, 0, 0.08);
}

/* Table Toolbar Top & Page Size Selector */
.table-toolbar-top {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 16px;
}

.table-page-size-select {
  font-weight: 600;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  transition: all 0.2s ease;
}

.table-page-size-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Table Row Transition */
.table-row-visible {
  animation: tableFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes tableFadeIn {
  from {
    opacity: 0.2;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pagination Styling */
.table-pagination-footer {
  border-top: 1px solid #f1f5f9;
}

.table-pagination-nav .pagination {
  gap: 3px;
}

.table-pagination-nav .page-link {
  color: #334155;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  background-color: #ffffff;
  transition: all 0.2s ease;
}

.table-pagination-nav .page-link:hover {
  background-color: #f1f5f9;
  color: #1d4ed8;
  border-color: #cbd5e1;
}

.table-pagination-nav .page-item.active .page-link {
  background-color: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.table-pagination-nav .page-item.disabled .page-link {
  color: #94a3b8;
  background-color: #f8fafc;
  border-color: #e2e8f0;
}

/* Pagination Pills Container & Elements */
.pagination-container {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.page-pill {
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  user-select: none;
}

.page-pill:hover:not(.disabled) {
  background-color: #f8fafc;
  color: #1d4ed8;
  border-color: #cbd5e1;
}

.page-pill.active {
  background-color: #2b4bff !important;
  border-color: #2b4bff !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(43, 75, 255, 0.25);
}

.page-pill.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ==========================================================================
   UNIVERSAL MOBILE RESPONSIVENESS & OFFCANVAS DRAWER SYSTEM
   ========================================================================== */

/* User Profile Header Badge & Bell */
.user-profile-btn {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 40px;
  padding: 6px 14px 6px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
}

.user-profile-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.user-avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #0b2456;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.notification-bell-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  text-decoration: none;
  position: relative;
  transition: all 0.2s ease;
}

.notification-bell-btn:hover {
  background: #f8fafc;
  color: #2b4bff;
  border-color: #c7d2fe;
}

/* Mobile Top Header (Fixed on Mobile/Tablet < 992px) */
.mobile-top-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 60px;
  z-index: 1045;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

.user-mobile-avatar-btn {
  width: 38px;
  height: 38px;
  border-radius: 50% !important;
  background-color: #0b2456 !important;
  color: #ffffff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-weight: 700 !important;
  font-size: 0.85rem !important;
  border: 1.5px solid #ffffff !important;
  box-shadow: 0 2px 6px rgba(11, 36, 86, 0.25) !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.user-mobile-avatar-btn:active,
.user-mobile-avatar-btn:focus {
  transform: scale(0.95);
}

/* Sidebar Backdrop Overlay */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s ease;
}

.sidebar-backdrop.show {
  opacity: 1;
  visibility: visible;
}

/* Sidebar Close Button inside Drawer */
.sidebar-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: auto;
}

.sidebar-close-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #ef4444;
}

/* Tablet & Mobile Screens (< 992px) */
@media (max-width: 991.98px) {
  .mobile-top-header {
    display: flex !important;
  }

  .dashboard-wrapper {
    flex-direction: column !important;
    width: 100% !important;
    overflow-x: hidden !important;
    position: relative !important;
    padding-top: 60px !important; /* Space for the fixed top navbar */
  }

  /* Automatically hide the duplicate desktop user profile pill & bells inside main-content on mobile */
  .main-content .user-profile-btn,
  .main-content .dropdown:has(.user-profile-btn),
  .main-content .notification-bell-btn,
  .main-content .top-nav > div:last-child,
  .main-content .top-nav .d-flex.align-items-center.gap-3,
  .main-content .top-nav .d-flex.align-items-center.gap-2.bg-white,
  .main-content > .d-flex:first-of-type > .d-flex.align-items-center.gap-3,
  .main-content .d-flex.justify-content-between.align-items-center.mb-4 > .d-flex.align-items-center.gap-3,
  .main-content .d-flex.align-items-center.justify-content-between.mb-4 > .d-flex.align-items-center.gap-3 {
    display: none !important;
  }


  /* Transform Sidebar into Slide-in Drawer */
  .sidebar,
  .sidebar-fixed,
  aside.sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: -320px !important;
    width: 280px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    z-index: 1060 !important;
    background: #ffffff !important;
    border-right: 1px solid #e2e8f0 !important;
    border-bottom: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 20px 16px !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    transition: left 0.32s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease !important;
  }

  .sidebar.show,
  .sidebar-fixed.show,
  aside.sidebar.show {
    left: 0 !important;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.35) !important;
  }

  .sidebar .sidebar-logo {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 20px !important;
    padding-bottom: 12px !important;
    border-bottom: 1px solid #f1f5f9 !important;
  }

  .sidebar-mascot {
    display: none !important; /* Hide mascot on small screens to save vertical scroll space */
  }

  .sidebar-footer-card {
    margin-top: auto !important;
    padding: 12px !important;
  }

  /* Main Content: Full Width on Mobile & Tablet */
  .main-content,
  .main-content-fixed,
  main.main-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    padding: 18px 14px !important;
    min-height: calc(100vh - 65px) !important;
    overflow-x: hidden !important;
    flex: 1 !important;
  }


  /* Top Nav Header & Page Header Rows */
  .top-nav-header,
  .page-header-row,
  .content-header-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  .top-nav-header > div:last-child,
  .page-header-actions {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .top-nav-header > div:last-child .btn,
  .page-header-actions .btn {
    flex: 1 1 auto !important;
    justify-content: center !important;
    text-align: center !important;
  }

  /* Stat / KPI Cards Responsiveness */
  .kpi-card {
    padding: 16px !important;
  }

  .kpi-card h2 {
    font-size: 1.5rem !important;
  }

  .kpi-badge-box {
    width: 38px !important;
    height: 38px !important;
    font-size: 0.95rem !important;
    border-radius: 8px !important;
    flex-shrink: 0 !important;
  }

  .stat-card-row,
  .kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
    gap: 12px !important;
  }

  /* Filter Bars & Toolbar */
  .filter-bar,
  .filter-row,
  .filter-card .row {
    row-gap: 10px !important;
  }

  .filter-actions,
  .filter-bar .d-flex.gap-2 {
    flex-wrap: wrap !important;
    width: 100% !important;
  }

  .filter-actions .btn,
  .filter-bar .d-flex.gap-2 .btn {
    flex: 1 1 auto !important;
  }

  /* Modals on Mobile */
  .modal-dialog {
    margin: 0.5rem auto !important;
    max-width: 95vw !important;
  }

  .modal-dialog.modal-lg,
  .modal-dialog.modal-xl {
    max-width: 96vw !important;
  }

  .modal-content {
    border-radius: 16px !important;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 14px 16px !important;
  }
}

/* Extra Small Mobile Devices (< 576px) */
@media (max-width: 575.98px) {
  .main-content,
  .main-content-fixed,
  main.main-content {
    padding: 14px 10px !important;
  }

  /* Compact Card Padding */
  .card,
  .card-custom {
    border-radius: 12px !important;
  }

  .card-body {
    padding: 14px 12px !important;
  }

  /* Typography Adjustments */
  h4, .h4 {
    font-size: 1.25rem !important;
  }

  h5, .h5 {
    font-size: 1.1rem !important;
  }

  h6, .h6 {
    font-size: 0.95rem !important;
  }

  /* Button Sizing */
  .btn-primary-custom,
  .btn-outline-custom,
  .btn-auth-submit {
    padding: 10px 16px !important;
    font-size: 0.88rem !important;
  }

  /* Tables Scroll Indicator on Mobile */
  .table-responsive {
    border-radius: 8px !important;
  }

  .table-responsive table {
    min-width: 600px; /* Ensures table columns don't crunch awkwardly and stay swipeable */
  }

  .table td, 
  .table th {
    padding: 10px 10px !important;
    font-size: 0.82rem !important;
  }

  /* Table Toolbar */
  .table-toolbar-top {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  .table-toolbar-top .d-flex {
    width: 100% !important;
    justify-content: space-between !important;
  }

  /* Pagination Stacking on Small Mobile */
  .table-pagination-footer {
    flex-direction: column !important;
    align-items: center !important;
    gap: 10px !important;
    text-align: center !important;
  }

  .table-pagination-nav {
    display: flex !important;
    justify-content: center !important;
    width: 100% !important;
  }

  .table-pagination-nav .pagination {
    flex-wrap: wrap !important;
    justify-content: center !important;
  }
}

