/* ============================================
   SHE-Waste | PT Semen Padang
   Custom Styles (non-Tailwind)
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  --color-primary-500: #4CAF50;
  --color-primary-600: #43A047;
  --color-primary-800: #2E7D32;
  --color-primary-900: #1B5E20;
  --sidebar-width: 256px;
  --header-height: 56px;
  --bottom-nav-height: 64px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Loading Screen ---------- */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1B5E20 0%, #2E7D32 50%, #43A047 100%);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#loading-screen.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-pulse {
  animation: pulse-text 1.8s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ---------- Page Transitions ---------- */
.page-section {
  animation: page-fade-in 0.25s ease-out;
}

@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.page-enter {
  animation: fadeIn 0.3s ease;
}

/* ---------- Map Containers ---------- */
#map-petugas,
#map-admin,
.leaflet-container {
  width: 100%;
  min-height: 300px;
  z-index: 1;
}

#map-petugas {
  height: calc(100vh - var(--header-height) - var(--bottom-nav-height) - var(--safe-area-bottom));
}

#map-admin {
  height: calc(100vh - 120px);
  border-radius: 0.5rem;
}

/* Leaflet popup overrides */
.leaflet-popup-content-wrapper {
  border-radius: 0.75rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-content {
  margin: 12px 16px;
  font-family: inherit;
  line-height: 1.5;
}

/* ---------- Bottom Navigation ---------- */
#petugas-nav {
  padding-bottom: var(--safe-area-bottom);
  height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
}

.nav-tab {
  transition: color 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-tab:active {
  transform: scale(0.92);
}

.nav-tab.active svg {
  stroke-width: 2.5;
}

.nav-tab.active .nav-dot {
  transform: scale(1);
}

.nav-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-primary-600);
  transform: scale(0);
  transition: transform 0.2s ease;
}

/* ---------- Admin Sidebar ---------- */
#admin-sidebar {
  width: var(--sidebar-width);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#admin-content {
  margin-left: var(--sidebar-width);
  transition: margin-left 0.3s ease;
}

@media (max-width: 1023px) {
  #admin-sidebar {
    transform: translateX(-100%);
    position: fixed;
    z-index: 40;
  }

  #admin-sidebar.sidebar-open {
    transform: translateX(0);
  }

  #admin-content {
    margin-left: 0;
  }
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 35;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

.sidebar-link {
  transition: background-color 0.15s ease, padding-left 0.15s ease;
}

.sidebar-link:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-link.active {
  background-color: rgba(255, 255, 255, 0.12);
  border-left: 3px solid #66BB6A;
}

/* ---------- Custom Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #c4c4c4;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a0a0a0;
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: #c4c4c4 transparent;
}

/* ---------- Modal ---------- */
#modal-container {
  display: none;
}

/* ---------- Toast Notifications ---------- */
.toast {
  animation: toast-in 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.removing {
  animation: toast-out 0.25s ease-in forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(40px) scale(0.95); }
}

.animate-slide-in {
  animation: toast-in 0.3s ease forwards;
}

.animate-slide-out {
  animation: toast-out 0.3s ease forwards;
}

/* ---------- Form Styles ---------- */
.input-field {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-field:focus {
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

/* Password toggle */
.password-toggle {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Cards & Surfaces ---------- */
.card-hover {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card-hover:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ---------- Status Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
}

/* ---------- Print Styles (Laporan) ---------- */
@media print {
  body * {
    visibility: hidden;
  }

  #print-area,
  #print-area * {
    visibility: visible;
  }

  #print-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }

  #petugas-nav,
  #petugas-header,
  #admin-sidebar,
  #toast-container,
  #modal-container,
  .no-print {
    display: none !important;
  }

  @page {
    margin: 1.5cm;
  }
}

/* ---------- Utilities ---------- */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.safe-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Prevent layout shift on page load */
[class*="hidden"] {
  display: none !important;
}

/* Smooth global transitions */
html {
  scroll-behavior: smooth;
}

/* Disable touch highlight on mobile */
button, a, [role="button"] {
  -webkit-tap-highlight-color: transparent;
}

/* Image compression preview */
.img-preview {
  max-height: 200px;
  object-fit: cover;
  border-radius: 0.5rem;
}
