/*
============================================================
 Table Laporan Harian (Proporsional Header)
------------------------------------------------------------
Fungsi:
- Membuat header tabel laporan.php proporsional, horizontal, dan tidak squished/vertikal
- Menyamakan tampilan header dengan PDF (laporan_pdf.php)
============================================================
*/
.laporan-table {
  table-layout: fixed;
  width: 100%;
}
.laporan-table th {
  white-space: normal;
  overflow-wrap: break-word;
  text-align: center;
}
/*
============================================================
 Dashboard Tab & Subtab Styles
------------------------------------------------------------
Fungsi:
- .tab-nav: Container bar navigasi tab utama (horizontal, scrollable jika overflow)
- .tab-btn: Tombol tab utama, dengan highlight tab aktif
- .subtab-nav: Container subtab (submenu) di bawah tab utama, horizontal, bisa wrap
- .subtab-btn: Tombol subtab, dengan highlight subtab aktif
- .subtab-btn[style*='bold']: Style khusus subtab yang sedang aktif (via JS inline style)

Responsif:
- @media (max-width:500px), (max-height:750px):
  - Mengecilkan padding, font, dan margin tab/subtab untuk layar kecil/mobile
  - iframe dan .card juga diatur agar proporsional di mobile

- .sidebar: Memastikan sidebar tetap scrollable penuh pada layar apapun
============================================================
*/
/* Sidebar content wrapper agar sidebar scrollable penuh dan submenu juga scrollable */
.sidebar-content {
  height: 100%;
  max-height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Scrollable submenu (khusus menu panjang seperti Laporan) */
.submenu.scrollable {
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #16a34a #065f46;
}
.submenu.scrollable::-webkit-scrollbar {
  width: 6px;
}
.submenu.scrollable::-webkit-scrollbar-thumb {
  background: #16a34a;
  border-radius: 4px;
}
.submenu.scrollable::-webkit-scrollbar-track {
  background: #065f46;
}
/* Table content red for emergency protocol */
.table-red td, .table-red th {
  color: #dc2626 !important;
}
/* === Global Reset & Box Model === */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  min-height: 100vh;
  width: 100%;
  font-family: sans-serif;
  overflow-y: auto; /* allows vertical scroll */
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* === Layout & Flex === */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; height: 100vh; }
.flex-row { display: flex; flex-direction: row; flex-grow: 1; height: 100%; }

.grid { display: grid; }
.place-items-center { place-items: center; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.mx-auto { margin-left: auto; margin-right: auto; }

.h-screen { height: 100vh; }
@media (min-width: 769px) {
  .min-h-screen { min-height: 100vh; }
}
.w-full { width: 100%; }
.max-w-md { max-width: 100%; }

/* === Spacing === */
.p-8 { padding: 2rem; }
.px-8 { padding-left: 2rem; padding-right: 2rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-20 { margin-top: 5rem; }
.space-y-6 > :not([hidden]) ~ :not([hidden]) { margin-top: 1.5rem; }
.space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: 1rem; }
.space-y-2 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.5rem; }

/* === Typography === */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-sm { font-size: 0.875rem; }
.text-2xl { font-size: 1.5rem; }
.font-semibold { font-weight: 600; }
.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.05em; }

/* === Colors === */
.bg-blue-900 { background-color: #51e7f1; }
.bg-white { background-color: #ffffff; }
.bg-green-100 { background-color: #d1fae5; }
.bg-green-600 { background-color: #16a34a; }
.bg-green-700 { background-color: #15803d; }
.bg-red-600 { background-color: #dc2626; }

.text-white { color: #ffffff; }
.text-green-900 { color: #064e3b; }
.text-green-800 { color: #065f46; }
.text-gray-900 { color: #111827; }

/* === Border === */
.border { border-width: 1px; border-style: solid; }
.border-green-400 { border-color: #34d399; }
.border-green-600 { border-color: #16a34a; }

/* === Rounded & Shadow === */
.rounded { border-radius: 0.25rem; }
.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.shadow-xl {
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1),
              0 10px 10px -5px rgba(0,0,0,0.04);
}

/* === Form Focus === */
.focus\:outline-none:focus { outline: none; }
.focus\:ring-2:focus {
  box-shadow: 0 0 0 2px rgba(34,197,94,0.5);
}

/* === Transitions === */
.transition-colors {
  transition-property: background-color, border-color, color;
  transition-duration: 0.3s;
}
.duration-300 { transition-duration: 0.3s; }
.hover\:bg-green-700:hover { background-color: #15803d; }

/* === Components === */
canvas {
  width: 100% !important;
  max-width: 100%;
  max-height: 300px;
  display: block;
}

iframe {
  width: 100%;
  max-width: 100%;
  height: 300px;
  border: 1px solid #ccc;
  border-radius: 8px;
  display: block;
}

table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  display: block;
  max-height: 300px;
  overflow-y: auto;
}

th, td {
  padding: 0.5rem;
  border: 1px solid #ccc;
  text-align: left;
}

th {
  background-color: #d1fae5;
  color: #065f46;
}

/* === Main Content === */
.main-content {
  flex: 1 1 0%;
  min-height: 0;
  min-width: 0;
  padding: 1rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.flex-row {
  display: flex;
  flex-direction: row;
  flex: 1 1 0%;
  min-height: 0;
  height: 100%;
}
.flex-col {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

/* === Footer === */
.footer {
  background-color: #f3f4f6;
  text-align: center;
  padding: 0.5rem;
  border-top: 1px solid #e5e7eb;
  width: 100%;
  flex-shrink: 0;
}
.footer.dark-mode {
  background-color: #1f2937;
  color: #f3f4f6;
  border-color: #374151;
}

/*
============================================================
 Sidebar Styles (REFACTORED - Phase 1)
------------------------------------------------------------
Fungsi:
- Mobile (≤1024px): Slide-in sidebar dengan hamburger toggle
- Tablet (769-1024px): Persistent sidebar (NEW - fixes breakpoint gap)
- Desktop (≥1025px): Persistent sidebar, hamburger hidden
- WCAG 2.1 Level AA compliant
- iOS 15+ dynamic viewport support (100dvh)
- GPU-accelerated animations
- Touch gesture support (swipe-to-close)
============================================================
*/

/* === Base Sidebar (Desktop Default) === */
.sidebar {
  width: 220px;
  background: #065f46;
  color: white;
  flex-shrink: 0;
  overflow-y: auto;
  height: 100%;
  position: relative;
}

/* Menu list structure */
.sidebar-content {
  display: flex;
  flex-direction: column;
}

.menu-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.menu-item {
  margin: 0;
  padding: 0;
}

.menu-button {
  width: 100%;
  background: transparent;
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s ease;
  font-size: 0.95rem;
}

.menu-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.menu-button:focus-visible {
  outline: 2px solid #fbbf24;
  outline-offset: -2px;
}

.menu-button.active {
  background: rgba(255, 255, 255, 0.15);
  border-left: 4px solid #fbbf24;
  padding-left: calc(1rem - 4px);
}

.menu-button.active:hover {
  background: rgba(255, 255, 255, 0.25);
}

.menu-icon {
  flex-shrink: 0;
  font-size: 1.2rem;
}

.menu-label {
  flex: 1;
}

.menu-button.menu-link {
  text-decoration: none;
}

/* Scrollbar styling for menu lists */
.sidebar .menu-list {
  scrollbar-width: thin;
  scrollbar-color: #16a34a #065f46;
}

.sidebar .menu-list::-webkit-scrollbar {
  width: 6px;
}

.sidebar .menu-list::-webkit-scrollbar-thumb {
  background: #16a34a;
  border-radius: 4px;
}

.sidebar .menu-list::-webkit-scrollbar-track {
  background: #065f46;
}

/* === Mobile/Tablet: Fixed slide-in sidebar (≤1024px) === */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100dvh;           /* iOS fix: dynamic viewport height */
    width: 80vw;
    max-width: 320px;
    background: #065f46;
    color: white;
    z-index: 1000;
    transform: translate3d(-100%, 0, 0);  /* GPU accelerated */
    transition: transform 0.25s cubic-bezier(.4, 0, .2, 1);
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.12);
    -webkit-overflow-scrolling: touch;    /* iOS smooth scroll */
  }

  .sidebar.open {
    transform: translate3d(0, 0, 0);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.2);
  }

  .sidebar .menu-close {
    display: block;
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 1010;
  }

  .menu-toggle {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1100;
    background-color: #2c3e50;
    color: white;
    border: none;
    padding: 5px 5px;
    font-size: 20px;
    border-radius: 2px;
    cursor: pointer;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: none;
    z-index: 900;
  }

  .sidebar-overlay.open {
    display: block;
  }

  .main-content {
    padding-bottom: 3.5rem;
  }

  .flex-row {
    flex-direction: column;
    height: auto;
  }
}

/* === Tablet: 769px - 1024px (Persistent sidebar - FIX FOR BREAKPOINT GAP) === */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar {
    position: static;
    width: 160px;
    height: auto;
    transform: none;
    z-index: auto;
    box-shadow: none;
    display: block !important;
  }

  .sidebar .menu-close {
    display: none;
  }

  .menu-toggle {
    display: none !important;
  }

  .sidebar-overlay {
    display: none !important;
  }

  .flex-row {
    display: flex;
  }

  .main-content {
    flex: 1;
    padding: 1rem;
  }
}

/* === Desktop: 1025px+ (Persistent sidebar) === */
@media (min-width: 1025px) {
  .sidebar {
    display: block;
    position: static;
    width: 220px;
    height: auto;
    transform: none;
    z-index: auto;
    box-shadow: none;
  }

  .sidebar .menu-close {
    display: none;
  }

  .menu-toggle {
    display: none;
  }

  .sidebar-overlay {
    display: none !important;
  }

  .flex-row {
    display: flex;
  }

  .main-content {
    flex: 1;
    padding: 1rem;
  }
}

/* === Respect User Motion Preferences === */
@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none !important;
  }

  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* === Large Screens (Ultrawide) === */
@media (min-width: 1920px) {
  .sidebar {
    width: 280px;
  }
}

/* === Screen Reader Only (sr-only utility) === */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/*
============================================================
 Main Content & Layout Flexbox
------------------------------------------------------------
Fungsi:
- .main-content: Area utama untuk konten halaman, fleksibel memenuhi sisa ruang
- .flex-row, .flex-col: Utility flexbox untuk layout baris/kolom
- .h-screen, .min-h-screen: Utility tinggi penuh viewport
============================================================
*/

/* === Main Content === */
.main-content {
  flex: 1 1 0%;
  min-height: 0;
  min-width: 0;
  padding: 1rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.flex-row {
  display: flex;
  flex-direction: row;
  flex: 1 1 0%;
  min-height: 0;
  height: 100%;
}
.flex-col {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

/*
============================================================
 Footer Styles
------------------------------------------------------------
Fungsi:
- .footer: Area footer di bawah main-content, selalu menempel bawah
- .footer.dark-mode: Footer versi dark mode
============================================================
*/

/* === Footer === */
.footer {
  background-color: #f3f4f6;
  text-align: center;
  padding: 0.5rem;
  border-top: 1px solid #e5e7eb;
  width: 100%;
  flex-shrink: 0;
}
.footer.dark-mode {
  background-color: #1f2937;
  color: #f3f4f6;
  border-color: #374151;
}

/*
============================================================
 Table & Table Responsive
------------------------------------------------------------
Fungsi:
- table, th, td: Style tabel data, padding, border, warna header
- .table-responsive: Membuat tabel bisa discroll horizontal di layar kecil
============================================================
*/

/* === Components === */
canvas {
  width: 100% !important;
  max-width: 100%;
  max-height: 300px;
  display: block;
}

iframe {
  width: 100%;
  max-width: 100%;
  height: 300px;
  border: 1px solid #ccc;
  border-radius: 8px;
  display: block;
}

table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  display: block;
  max-height: 300px;
  overflow-y: auto;
}

th, td {
  padding: 0.5rem;
  border: 1px solid #ccc;
  text-align: left;
}

th {
  background-color: #d1fae5;
  color: #065f46;
}

/* Make tables horizontally scrollable on small screens */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive table { min-width: 600px; }

/*
============================================================
 Utility Classes (Spacing, Typography, Color, Border, etc)
------------------------------------------------------------
Fungsi:
- .p-8, .px-8, .py-6, .mt-4, dst: Utility padding/margin
- .text-center, .text-sm, .font-semibold, dst: Utility text/typography
- .bg-*, .text-*, .border-*, .rounded-*, .shadow-xl: Utility warna, border, radius, shadow
============================================================
*/

/* === Spacing === */
.p-8 { padding: 2rem; }
.px-8 { padding-left: 2rem; padding-right: 2rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-20 { margin-top: 5rem; }
.space-y-6 > :not([hidden]) ~ :not([hidden]) { margin-top: 1.5rem; }
.space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: 1rem; }
.space-y-2 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.5rem; }

/* === Typography === */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-sm { font-size: 0.875rem; }
.text-2xl { font-size: 1.5rem; }
.font-semibold { font-weight: 600; }
.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.05em; }

/* === Colors === */
.bg-blue-900 { background-color: #51e7f1; }
.bg-white { background-color: #ffffff; }
.bg-green-100 { background-color: #d1fae5; }
.bg-green-600 { background-color: #16a34a; }
.bg-green-700 { background-color: #15803d; }
.bg-red-600 { background-color: #dc2626; }

.text-white { color: #ffffff; }
.text-green-900 { color: #064e3b; }
.text-green-800 { color: #065f46; }
.text-gray-900 { color: #111827; }

/* === Border === */
.border { border-width: 1px; border-style: solid; }
.border-green-400 { border-color: #34d399; }
.border-green-600 { border-color: #16a34a; }

/* === Rounded & Shadow === */
.rounded { border-radius: 0.25rem; }
.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.shadow-xl {
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1),
              0 10px 10px -5px rgba(0,0,0,0.04);
}

/* === Form Focus === */
.focus\:outline-none:focus { outline: none; }
.focus\:ring-2:focus {
  box-shadow: 0 0 0 2px rgba(34,197,94,0.5);
}

/* === Transitions === */
.transition-colors {
  transition-property: background-color, border-color, color;
  transition-duration: 0.3s;
}
.duration-300 { transition-duration: 0.3s; }
.hover\:bg-green-700:hover { background-color: #15803d; }

/* === Dashboard Tab & Subtab === */
.tab-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #e5e7eb;
  overflow-x: auto;
}
.tab-btn {
  background: none;
  border: none;
  padding: 0.7rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  color: #065f46;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: border 0.2s, color 0.2s;
  outline: none;
}
.tab-btn.active {
  color: #16a34a;
  border-bottom: 3px solid #16a34a;
  background: #f0fdf4;
}
.subtab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #e5e7eb;
  overflow-x: auto;
}
.subtab-btn {
  background: none;
  border: none;
  padding: 0.5rem 0.9rem;
  font-size: 0.97rem;
  color: #065f46;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: border 0.2s, color 0.2s;
  outline: none;
}
.subtab-btn[style*='bold'] {
  color: #16a34a;
  border-bottom: 2px solid #16a34a;
  background: #f0fdf4;
}

@media (max-width: 500px), (max-height: 750px) {
  html, body {
    width: 100vw;
    min-width: 100vw;
    max-width: 100vw;
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    overflow-x: hidden;
  }
  .main-content {
    padding: 0.5rem 0.2rem 0.5rem 0.2rem;
    font-size: 0.97rem;
  }
  .tab-nav {
    gap: 0.1rem;
    font-size: 0.93rem;
    margin-bottom: 0.7rem;
    padding-left: 0.2rem;
    padding-right: 0.2rem;
  }
  .tab-btn {
    padding: 0.5rem 0.6rem;
    font-size: 0.97rem;
  }
  .subtab-nav {
    gap: 0.1rem;
    font-size: 0.93rem;
    margin-bottom: 0.5rem;
    padding-left: 0.1rem;
    padding-right: 0.1rem;
  }
  .subtab-btn {
    padding: 0.4rem 0.5rem;
    font-size: 0.95rem;
  }
  h1, h2, h3 {
    font-size: 1.1rem !important;
  }
  .card {
    padding: 0.7rem;
    margin-bottom: 0.7rem;
  }
  iframe {
    height: 320px;
    min-height: 200px;
    max-height: 350px;
  }
}

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
  }
  .flex-row {
    flex-direction: column;
  }
}

@media (max-width: 768px) {
  .flex-row {
    flex-direction: column;
    height: auto;
  }

  .sidebar {
    width: 100%;
    height: auto;
    padding: 1rem;
  }

  .main-content {
    padding: 1rem;
    height: auto;
  }

  canvas,
  iframe,
  table {
    max-width: 100%;
    height: auto;
  }

  .text-2xl {
    font-size: 1.25rem;
  }

  .p-8, .px-8, .py-6 {
    padding: 1rem;
  }

  .toggle-btn {
    position: static;
    margin-bottom: 1rem;
    width: 100%;
  }
}

/* === Responsive Breakpoints
------------------------------------------------------------
Fungsi:
- @media (max-width:768px):
  - Mengatur ulang layout sidebar, main-content, flex-row, dsb untuk mobile
- @media (min-width:1025px):
  - Sidebar hidden di desktop, hanya muncul jika .open
============================================================
*/