/* Consolidated layout/shared styles for header, sidebar, footer and common components */

:root {
  --bg-dark: #000814;
  --bg-mid: #001d3d;
  --bg-deep: #003566;
  --accent-cyan: #00f2fe;
  --glass: rgba(255, 255, 255, 0.03);
  --glass-strong: rgba(255, 255, 255, 0.08);
  --muted: rgba(255, 255, 255, 0.7);
  --sidebar-w: 280px;
  --sidebar-collapsed-w: 84px;
}

html,
body {
  min-height: 100vh;
  background-attachment: fixed !important;
  font-family:
    "Plus Jakarta Sans",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial;
  margin: 0;
  padding: 0;
  color: #e6eef6;
  background: linear-gradient(
    -45deg,
    var(--bg-dark),
    var(--bg-mid),
    var(--bg-deep),
    var(--bg-dark)
  );
  background-size: 400% 400%;
  animation: gradientAnim 15s ease infinite;
}

@keyframes gradientAnim {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ===== SCROLLBAR (shared across site) ===== */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: #082444;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(#11dfff, #0b8fff);
  border-radius: 20px;
}
/* Sidebar and layout containers */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: linear-gradient(180deg, rgba(2, 34, 54, 1), rgba(2, 16, 36, 1));
  padding: 18px;
  color: #fff;
  overflow-y: auto;
  -ms-overflow-style: none; /* IE and Edge */
  scrollbar-width: none; /* Firefox */
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 1050;
  transition:
    width 0.3s ease,
    transform 0.3s ease;
}

.sidebar::-webkit-scrollbar {
  display: none; /* Chrome, Safari and Opera */
}

.brand-box {
  padding: 24px 18px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.brand-box img {
  width: 60px;
  border-radius: 8px;
  filter: drop-shadow(0 0 8px var(--accent-cyan));
  margin-top: 40px; /* lower Dishub logo further down per request */
}
.brand-box h5 {
  font-size: 16px;
  margin: 0;
}
.brand-box small {
  color: rgba(255, 255, 255, 0.6);
}

.nav-link {
  color: var(--muted);
  display: block;
  padding: 12px 16px;
  border-radius: 10px;
  margin: 6px 8px;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
  font-size: 0.95rem;
}
.nav-link i {
  width: 28px;
  color: var(--accent-cyan);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
/* Make Administrasi follow the same spacing as other nav items */
.sidebar .admin-link {
  padding: 12px 16px; /* same as .nav-link */
}
body.sidebar-collapsed .sidebar .admin-link {
  padding-left: 6px;
}
.nav-link:hover,
.nav-link.active {
  background: rgba(0, 242, 254, 0.07);
  color: #fff;
}

.submenu {
  list-style: none;
  padding-left: 42px;
  margin: 0;
}
.submenu .nav-link {
  margin: 0;
  padding: 8px 10px;
  font-size: 0.9rem;
}

/* Submenu items should not show icons (keep them text-only) */
.submenu .nav-link i {
  display: none;
}

.main-content {
  margin-left: var(--sidebar-w);
  padding: 30px;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

/* Sidebar toggle */
.sidebar-toggle-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.brand-box .sidebar-toggle-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
}

body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-w);
}
body.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-w);
}
body.sidebar-collapsed .brand-box h5,
body.sidebar-collapsed .brand-box small {
  font-size: 0;
}

/* Keep icons visible when collapsed; hide only the textual label */
.sidebar .nav-link {
  display: flex;
  align-items: center;
}
.sidebar .nav-link .nav-label {
  display: inline-block;
  margin-left: 8px;
}
body.sidebar-collapsed .sidebar .nav-link {
  justify-content: center;
  padding: 12px 0;
  margin: 6px 6px;
}
/* Ensure all icons occupy the same centered column when collapsed */
body.sidebar-collapsed .sidebar .nav-link i {
  width: 28px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Remove Bootstrap spacing utilities so icons truly center when collapsed */
body.sidebar-collapsed .sidebar .nav-link i {
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Ensure top-level nav anchors occupy full width and center their icon when collapsed */
body.sidebar-collapsed .sidebar nav {
  display: flex;
  flex-direction: column;
  align-items: center;
}

body.sidebar-collapsed .sidebar nav > a.nav-link,
body.sidebar-collapsed .sidebar nav > a.dropdown-toggle {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 10px 0 !important;
  margin: 6px 0 !important;
}

/* Remove any left/right padding exceptions for admin-link when collapsed */
body.sidebar-collapsed .sidebar .admin-link {
  padding-left: 0 !important;
  padding-right: 0 !important;
}
body.sidebar-collapsed .sidebar .nav-link .nav-label {
  display: none;
}
body.sidebar-collapsed .sidebar .submenu,
body.sidebar-collapsed .sidebar .collapse {
  display: none !important;
}

/* When sidebar is collapsed: hide dropdown carets and disable toggles
       so the sidebar shows icons only and submenus can't open. */
body.sidebar-collapsed .sidebar .nav-link.dropdown-toggle::after {
  display: none !important;
}
body.sidebar-collapsed .sidebar .nav-link.dropdown-toggle {
  pointer-events: none;
}

/* Glass card component used across app */
.glass-card {
  background: var(--glass);
  border: 1px solid var(--glass-strong);
  border-radius: 20px;
  padding: 22px;
  backdrop-filter: blur(10px);
  color: #fff;
  transition:
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}

/* Make table wrappers globally responsive so content can adjust when sidebar is visible */
.table-responsive {
  overflow-x: auto;
}

.main-content .table {
  min-width: 0;
  width: 100%;
}

.main-content .table tbody td {
  white-space: normal;
  word-break: break-word;
}

.main-content .table thead th {
  white-space: nowrap;
}

/* Custom pagination styling to match app theme */
.custom-pagination .page-item .page-link {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e6dddd;
  min-width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  margin-left: 6px;
}
.custom-pagination .page-item.active .page-link {
  background: linear-gradient(90deg, #18a0d1, #27e1ff);
  color: #fdfdfd;
  border-color: transparent;
}
.custom-pagination .page-item.disabled .page-link {
  opacity: 0.4;
  pointer-events: none;
}
.custom-pagination .page-link:hover {
  transform: translateY(-2px);
  transition: transform 120ms ease;
}

/* Ensure pagination container sits visually above footer */
.main-content .pagination {
  z-index: 2;
}

/* Back-to-Top button */
.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(90deg, var(--accent-cyan), #4facfe);
  color: #021024;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  z-index: 2200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    visibility 160ms;
}
.back-to-top i {
  font-size: 16px;
}
.back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.glass-card:hover {
  border-color: var(--accent-cyan);
}

.motto-box {
  background: linear-gradient(90deg, rgba(0, 242, 254, 0.12), transparent);
  border-left: 4px solid var(--accent-cyan);
  padding: 18px;
  border-radius: 0 12px 12px 0;
}
.motto-title {
  font-weight: 800;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 40px; /* lower Dishub logo further down */
  font-size: 1.6rem;
  font-weight: 700;
}

/* Form and button helpers used by many views */
.btn-premium {
  background: linear-gradient(90deg, var(--accent-cyan), #4facfe);
  color: #021024;
  border: none;
  border-radius: 10px;
  padding: 8px 18px;
}
.btn-premium:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 242, 254, 0.12);
}

.form-control,
.form-select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #fff;
  border-radius: 10px;
}

.print-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 52px;
}

footer,
.app-footer {
  text-align: center;
  margin-top: 60px;
  padding: 28px 0 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 2;
}

.app-footer .footer-title {
  color: var(--accent-cyan);
  font-weight: 700;
  font-style: bold;
  font-size: 1.1rem;
  margin-bottom: 10px;
}

.app-footer .footer-text {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.9rem;
}

.modal-content {
  background: linear-gradient(145deg, #082448, #0a325e) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 24px !important;
  color: #fff;
}

.modal .form-control,
.modal .form-select {
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: #fff !important;
}

.modal .form-control::placeholder,
.modal .form-select {
  color: rgba(255, 255, 255, 0.75) !important;
}

@media print {
  .no-print,
  .sidebar,
  #sidebarToggle,
  #mobileSidebarToggle,
  .sidebar-overlay,
  .back-to-top,
  .btn,
  .btn-premium,
  .print-btn {
    display: none !important;
  }

  body,
  .main-content,
  .glass-card,
  .table,
  .table-responsive {
    background: #fff !important;
    color: #000 !important;
  }

  .table th,
  .table td {
    color: #000 !important;
    border-color: #dcdcdc !important;
  }

  footer {
    color: #444 !important;
    border-top-color: #ccc !important;
  }
}

/* Responsive: mobile/tablet offcanvas behavior (max-width: 768px) */
@media (max-width: 768px) {
  /* Disable heavy body gradient animation on mobile to reduce constant repaints.
     Keep the gradient colors intact so the look stays the same as desktop. */
  body {
    animation: none;
    background: linear-gradient(
      -45deg,
      var(--bg-dark),
      var(--bg-mid),
      var(--bg-deep),
      var(--bg-dark)
    );
    background-size: 100% 100%;
  }

  /* Disable backdrop-filter on mobile (GPU-heavy on low-end devices) */
  .glass-card {
    backdrop-filter: none;
  }

  /* Hide sidebar off-canvas by default using transform for smooth animation */
  .sidebar {
    left: 0; /* keep anchored to left but hidden via transform */
    transform: translateX(-100%);
    width: var(--sidebar-w);
    transition: transform 0.32s ease;
    will-change: transform;
    z-index: 1050;
  }

  /* When open, slide into view */
  .sidebar.open,
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* Ensure main area occupies full width on mobile */
  .main-content {
    margin-left: 0;
  }
  footer {
    margin-left: 0;
  }

  /* When collapsed (desktop collapse toggled previously), keep full width for mobile */
  body.sidebar-collapsed .sidebar {
    width: var(--sidebar-w);
  }
  body.sidebar-collapsed .main-content {
    margin-left: 0;
  }

  /* Dark overlay behind the offcanvas sidebar */
  .sidebar-overlay {
    position: fixed;
    inset: 0; /* top:0; right:0; bottom:0; left:0 */
    background: rgba(0, 0, 0, 0.45);
    z-index: 1040; /* below .sidebar (1050) */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      opacity 0.28s ease,
      visibility 0s linear 0.28s;
  }
  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }

  /* Prevent background scroll while sidebar is open */
  body.sidebar-open {
    overflow: hidden;
  }

  /* Ensure sidebar is scrollable on mobile and uses momentum scrolling on iOS */
  .sidebar {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: 100vh;
  }

  /* Safety overrides: if desktop collapsed class leaks into mobile,
     keep sidebar items interactive and submenu visibility controlled by Bootstrap .show */
  body.sidebar-collapsed .sidebar .nav-link.dropdown-toggle {
    pointer-events: auto !important;
  }
  body.sidebar-collapsed .sidebar .nav-link .nav-label {
    display: inline-block !important;
  }
  body.sidebar-collapsed .sidebar .submenu {
    display: block !important;
  }
  body.sidebar-collapsed .sidebar .collapse.show {
    display: block !important;
  }
}

/* Mobile hamburger: left-middle position (slightly transparent) */
#mobileSidebarToggle {
  position: fixed;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1100;
  pointer-events: auto;
  touch-action: manipulation;
  background: rgba(20, 50, 80, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  /* backdrop-filter removed on mobile for performance; solid semi-transparent bg used instead */
  opacity: 0.9;
  transition:
    opacity 180ms ease,
    left 320ms ease;
}

/* Slight scale on hover */
#mobileSidebarToggle:hover {
  opacity: 1;
}

/* Respect user accessibility preference: disable all animations */
@media (prefers-reduced-motion: reduce) {
  body {
    animation: none;
  }
  .sidebar,
  #mobileSidebarToggle,
  .main-content,
  .back-to-top,
  .sidebar-overlay {
    transition: none !important;
  }
}

/* Adjust spacing and sizes when sidebar is collapsed to keep toggle, logo and icons balanced */
body.sidebar-collapsed .brand-box {
  padding: 12px 6px;
  gap: 6px;
  justify-content: center; /* center logo and toggle vertically */
}

body.sidebar-collapsed .brand-box img {
  width: 40px;
  margin-top: 0; /* remove extra top offset so image centers */
}

/* Nudge the Dishub logo down for better visual balance */
.brand-box img {
  margin-top: 18px;
}

body.sidebar-collapsed .brand-box img {
  margin-top: 40px; /* lowered further when sidebar is closed */
}

/* Make toggle smaller and nudge it inward when collapsed so it doesn't overlap */
/* Desktop-specific: keep internal toggle fixed at top above logo and unchanged when sidebar opens/closes */
@media (min-width: 769px) {
  .brand-box .sidebar-toggle-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    left: auto;
    width: 36px;
    height: 36px;
    z-index: 1060;
    transform: none;
  }

  body.sidebar-collapsed .brand-box .sidebar-toggle-btn {
    /* keep the same top position when collapsed on desktop */
    width: 30px;
    height: 30px;
    top: 12px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    border-radius: 8px;
  }
}

/* Slightly reduce nav-link vertical padding when collapsed for even spacing */
body.sidebar-collapsed .sidebar .nav-link {
  padding: 10px 0;
  margin: 6px 4px;
}

/* Ensure brand-box remains visually centered and doesn't collapse height too much */
.brand-box {
  min-height: 86px;
}

body.sidebar-collapsed .brand-box {
  min-height: 64px;
}

/* =========================================================
   RESPONSIVE OVERRIDES (MOBILE & TABLET)
========================================================= */
@media (max-width: 768px) {
  /* Typography responsiveness */
  .motto-title {
    font-size: 1.15rem !important;
    margin-top: 15px !important;
    line-height: 1.4;
  }
  .header-section h2 {
    font-size: 1.4rem !important;
  }
  .header-section h5 {
    font-size: 1rem !important;
  }

  /* Toolbar and Search Responsiveness */
  .search-container {
    flex-wrap: wrap !important;
    padding: 12px 16px !important;
    border-radius: 20px !important;
    gap: 12px !important;
  }

  .search-container .form-select,
  .search-container .form-control {
    width: 100% !important;
    max-width: none !important;
    margin-bottom: 0px;
    border-radius: 12px !important;
  }

  .search-container i.fa-filter {
    display: none; /* Hide icon to save space on mobile */
  }

  .search-container .btn {
    width: 100% !important;
    border-radius: 12px !important;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px !important;
  }

  /* Make action buttons block-level on mobile for better touch targets */
  .btn-premium,
  .print-btn,
  .btn-action-mobile {
    width: 100%;
    margin-bottom: 8px;
    text-align: center;
    justify-content: center;
    display: flex;
    align-items: center;
  }

  /* Adjust padding for main layout to avoid cramped edges */
  .main-content {
    padding: 16px !important;
  }
}
