/* =========================================================================
   Rumah Jok Pontianak - Panel Admin V2
   styles.css - gaya kustom (pelengkap utilitas Tailwind dari CDN)

   Urutan bagian:
     1. Dasar (dasar halaman, select, area sentuh)
     2. Menu dropdown / menu tekan
     3. Tabel menjadi kartu di layar ponsel (.rt)
     4. Modal, toast, sidebar
     5. Gerbang login
     6. Gaya cetak / PDF (@media print)
   ========================================================================= */

/* ---------- 1. Dasar ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
body {
  background: #f6f7f9;
  color: #0f172a;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
.tap {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* Panah select seragam, ganti panah bawaan peramban */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2364748b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8.5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  background-size: 1.05rem 1.05rem;
  padding-right: 2.4rem !important;
  cursor: pointer;
}
select::-ms-expand {
  display: none;
}
select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
/* Menu dropdown */
/* ---------- 2. Menu dropdown / menu tekan ---------- */
.menu-pop {
  animation: menuIn 0.16s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
@keyframes menuIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.75rem;
  border-radius: 0.75rem;
  padding: 0.625rem 0.75rem;
  text-align: left;
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
  transition: background-color 0.12s;
}
.menu-item:hover,
.menu-item:focus-visible {
  background: #f1f5f9;
  outline: none;
}
.menu-item svg {
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
  color: #94a3b8;
}
.menu-item.danger {
  color: #e11d48;
}
.menu-item.danger svg {
  color: #fb7185;
}
.menu-item.danger:hover {
  background: #fff1f2;
}
.menu-check {
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
  color: #4f46e5;
}
body.menu-open {
  overflow: hidden;
}
#menuScrim {
  opacity: 0;
  pointer-events: none;
  transition: 0.18s;
  z-index: 60;
}
#menuScrim.open {
  opacity: 1;
  pointer-events: auto;
}
@media (max-width: 640px) {
  .menu-sheet {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 1.25rem 1.25rem 0 0 !important;
    padding: 0.5rem 0.5rem calc(1rem + env(safe-area-inset-bottom)) !important;
    box-shadow: 0 -10px 40px rgba(15, 23, 42, 0.22) !important;
    max-height: 80vh;
    overflow-y: auto;
  }
  .menu-sheet.menu-pop {
    animation: sheetIn 0.2s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  }
  .menu-sheet .menu-item {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
    min-height: 48px;
  }
  .menu-sheet .menu-item > span:first-child {
    width: 0.75rem;
    height: 0.75rem;
  }
}
@keyframes sheetIn {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
/* Tabel menjadi kartu di layar ponsel */
/* ---------- 3. Tabel menjadi kartu di layar ponsel (.rt) ---------- */
@media (max-width: 639px) {
  .rt {
    min-width: 0 !important;
  }
  .rt thead {
    display: none;
  }
  .rt,
  .rt tbody,
  .rt tr,
  .rt td {
    display: block;
    width: auto;
  }
  .rt tbody tr {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
  }
  .rt tbody tr:last-child {
    border-bottom: 0;
  }
  .rt td {
    border: 0 !important;
    padding: 3px 0 !important;
    text-align: left !important;
    line-height: 1.45;
  }
  .rt td:empty {
    display: none;
  }
  .rt td[data-l]:not(:empty)::before {
    content: attr(data-l) ' · ';
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #94a3b8;
  }
  .rt td:first-child {
    padding-bottom: 6px !important;
    font-size: 15px;
    font-weight: 600;
  }
  .rt td:last-child {
    padding-top: 12px !important;
  }
  .rt td:last-child > div {
    justify-content: flex-start;
  }
  .rt td:last-child button {
    flex: 1 1 0;
    min-height: 42px;
    font-size: 12px;
  }
}
/* Area sentuh & modal di ponsel */
@media (max-width: 640px) {
  button {
    min-height: 42px;
  }
  [data-close],
  .remove,
  #openSidebar,
  #closeSidebar,
  #togglePass {
    min-width: 42px;
    display: inline-grid;
    place-items: center;
  }
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
  .toast {
    bottom: calc(88px + env(safe-area-inset-bottom)) !important;
  }
  @media (min-width: 1024px) {
    .toast {
      bottom: 1.25rem;
    }
  }
  .modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .modal-panel {
    border-radius: 20px 20px 0 0 !important;
    margin: 0 !important;
    max-height: 92vh;
    overflow-y: auto;
    width: 100% !important;
    max-width: 100% !important;
  }
  .modal-panel {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)) !important;
  }
}
/* ---------- 4. Modal, toast, sidebar, halaman ---------- */
.nav-active {
  background: #eef2ff;
  color: #3730a3;
}
.page {
  display: none;
  animation: in 0.25s ease both;
}
.page.active {
  display: block;
}
@keyframes in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.modal {
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
}
.modal.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-panel {
  transform: translateY(10px) scale(0.985);
  transition: 0.2s;
}
.modal.open .modal-panel {
  transform: none;
}
.toast {
  transform: translateY(14px);
  opacity: 0;
  pointer-events: none;
  transition: 0.25s;
}
.toast.show {
  transform: none;
  opacity: 1;
}
.sidebar-overlay {
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
}
.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
/* ---------- 5. Gerbang login ---------- */
#authGate {
  display: none;
}
body.locked #authGate {
  display: block;
}
body.locked #sidebar,
body.locked #sidebarOverlay,
body.locked main,
body.locked #mobileBar,
body.locked #menuScrim {
  display: none !important;
}
.invoice-paper {
  background: #fff;
  box-shadow: 0 12px 50px rgba(15, 23, 42, 0.09);
}
@media (max-width: 1023px) {
  #sidebar {
    transform: translateX(-100%);
    transition: 0.25s;
  }
  #sidebar.open {
    transform: none;
  }
}
/* ---------- 6. Gaya cetak / PDF ---------- */
@media print {
  @page {
    margin: 12mm;
  }
  body {
    background: #fff !important;
  }
  #sidebar,
  #sidebarOverlay,
  #mobileBar,
  header,
  .no-print,
  .modal,
  .toast {
    display: none !important;
  }
  .page {
    display: none !important;
    animation: none !important;
  }
  #page-invoice-detail {
    display: block !important;
  }
  .invoice-paper {
    position: static !important;
    width: auto !important;
    max-width: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }
}
