/* ========================================================
   Kelola Kost - Main Stylesheet
   UI Redesign: Modern, Minimal, Professional Property Management SaaS
   STRICT RULE: All original brand & status colors are 100% preserved.
   ======================================================== */

/* Root & Global CSS Variables (Original Colors Preserved) */
:root {
  --color-asri-bg: #F8FAFC;
  --color-asri-card: #FFFFFF;
  --color-asri-border: #E2E8F0;
  --color-asri-text: #0F172A;
  --color-asri-muted: #64748B;
  --color-asri-primary: #00875A;
  --color-asri-primary-hover: #00704A;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
}

body {
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #F8FAFC;
  color: #0F172A;
  line-height: 1.5;
}

/* Custom Scrollbar (Preserves Original #CBD5E1 & #F1F5F9) */
.custom-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.custom-scroll::-webkit-scrollbar-thumb {
  background-color: #CBD5E1;
  border-radius: 9999px;
}

.custom-scroll::-webkit-scrollbar-thumb:hover {
  background-color: #94A3B8;
}

.custom-scroll::-webkit-scrollbar-track {
  background: #F1F5F9;
  border-radius: 9999px;
}

/* Sticky Table Header (Guarantees solid background during vertical scroll) */
thead.sticky, thead.sticky tr, thead.sticky th {
  background-color: #f1f5f9 !important;
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Accessible Selection */
::selection {
  background-color: #00875A;
  color: #FFFFFF;
}

/* Hide scrollbar utility */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Mobile & Touch Responsiveness Helpers */
html, body {
  overflow-x: clip;
}

button, input, select, textarea, a {
  touch-action: manipulation;
}

/* ========================================================
   FORM CONTROLS & MICRO-INTERACTIONS
   ======================================================== */

/* Smooth Transitions */
a, button, input, select, textarea {
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Active Press Feedback */
button:active, .active-press:active {
  transform: scale(0.98);
}

/* Accessible Focus States */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #00875A;
  outline-offset: 2px;
}

/* Form Controls Consistency */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  font-family: inherit;
  font-size: 0.8125rem; /* 13px desktop */
}

/* Senior Mobile Polish: Prevent iOS Auto-Zoom on Input Focus */
@media (max-width: 640px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important; /* 16px prevents iOS Safari from zooming viewport */
  }
}

/* Touch feedback and mobile smoothness */
* {
  -webkit-tap-highlight-color: transparent;
}
.overflow-x-auto, .overflow-y-auto {
  -webkit-overflow-scrolling: touch;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #00875A !important;
  box-shadow: 0 0 0 3px rgba(0, 135, 90, 0.12) !important;
  background-color: #FFFFFF !important;
}

/* Custom Date Picker Indicator */
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* Clean Checkbox */
input[type="checkbox"] {
  cursor: pointer;
  accent-color: #00875A;
}

/* ========================================================
   HEADER & NAVIGATION (Sticky Top Bar)
   ======================================================== */
header {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

/* ========================================================
   AUTH SCREEN & SLOGAN TYPOGRAPHY
   ======================================================== */
.slogan-title {
  font-family: 'Caveat', 'Plus Jakarta Sans', cursive, -apple-system, sans-serif;
  font-style: italic;
  transform: rotate(-2deg);
  transform-origin: left center;
  line-height: 1.15;
}

/* Tab Switcher Buttons Alignment */
#nav-tab-ops,
#nav-tab-report {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  user-select: none;
  cursor: pointer;
}

/* ========================================================
   METRIC & KPI SUMMARY CARDS
   ======================================================== */
#view-operasional section:first-of-type > div,
#view-laporan section:first-of-type > div {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.04);
}

#view-operasional section:first-of-type > div:hover,
#view-laporan section:first-of-type > div:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -4px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
}

/* ========================================================
   ROOM CARDS (GRID)
   ======================================================== */
#room-grid > div {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.04), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
}

#room-grid > div:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -4px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  border-color: #CBD5E1;
}

/* Action Buttons inside Room Cards */
#room-grid > div button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-weight: 700;
}

/* ========================================================
   TABLES & REPORTS
   ======================================================== */
table {
  border-collapse: separate;
  border-spacing: 0;
}

table thead th {
  font-size: 0.6875rem; /* 11px */
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap !important;
}

table tbody tr {
  transition: background-color 0.15s ease;
}

table tbody tr:hover {
  background-color: #F8FAFC;
}

/* Bulletproof table cell & status badge rules (Prevents text wrapping/clipping on mobile) */
#table-cashflow-body td,
#table-duration-body td,
#table-maintenance-body td {
  vertical-align: middle;
}

#table-cashflow-body td:nth-child(1),
#table-cashflow-body td:nth-child(2),
#table-cashflow-body td:nth-child(3),
#table-cashflow-body td:nth-child(5),
#table-cashflow-body td:nth-child(6),
#table-duration-body td:nth-child(1),
#table-duration-body td:nth-child(3),
#table-duration-body td:nth-child(4),
#table-duration-body td:nth-child(5),
#table-duration-body td:nth-child(6),
#table-maintenance-body td:nth-child(1),
#table-maintenance-body td:nth-child(2),
#table-maintenance-body td:nth-child(4),
#table-maintenance-body td:nth-child(5) {
  white-space: nowrap !important;
}

#table-cashflow-body span,
#table-duration-body span,
#table-maintenance-body span {
  white-space: nowrap !important;
}

.badge-cashflow-type {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  white-space: nowrap !important;
  padding: 2px 10px !important;
  border-radius: 9999px !important;
  font-size: 11px !important;
  line-height: 1.4 !important;
  font-weight: 600 !important;
  box-sizing: border-box !important;
}

/* ========================================================
   MODALS & ANIMATIONS
   ======================================================== */
@keyframes modalBackdropFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalDialogScaleIn {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Modal Open Animation */
[id^="modal-"]:not(.hidden) {
  animation: modalBackdropFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[id^="modal-"]:not(.hidden) > div {
  animation: modalDialogScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ========================================================
   TOAST NOTIFICATION ANIMATION
   ======================================================== */
@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#toast:not(.hidden) {
  display: flex !important;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#toast.hidden {
  display: none !important;
}

/* ========================================================
   PRINT VIEW CONFIGURATION (PRESERVED)
   ======================================================== */
@media print {
  body * {
    visibility: hidden;
  }
  #printable-report-paper, #printable-report-paper * {
    visibility: visible;
  }
  #printable-report-paper {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    background: #fff;
    color: #000;
    box-shadow: none !important;
    border: none !important;
  }
  .no-print {
    display: none !important;
  }
}


/* ========================================================
   MOBILE APP-LIKE ENHANCEMENTS
   ======================================================== */
@media (max-width: 640px) {
  body, #app-screen {
    overflow-x: hidden;
    position: relative;
    width: 100%;
  }

  nav.fixed.bottom-0 {
    padding-bottom: max(0.6rem, env(safe-area-inset-bottom)) !important;
  }

  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
}
