/* ==========================================================================
   RentPulse — Fluid 3D Glassmorphic & Room-Themed Responsive Styles
   ========================================================================== */

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

html {
  scroll-behavior: auto; /* Smooth scrolling powered by Lenis */
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: clip;
  position: relative;
  -webkit-font-smoothing: antialiased;
  transition: color 220ms ease;
}

/* Atmospheric Room Photography Layer behind Frosted Glass */
.room-backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: url("https://images.unsplash.com/photo-1522708323590-d24dbb6b0267?auto=format&fit=crop&w=1400&q=80");
  background-size: cover;
  background-position: center;
  opacity: var(--room-backdrop-opacity);
  filter: saturate(1.1) blur(3px);
  pointer-events: none;
  transition: opacity 350ms ease;
}

[data-theme="dark"] .room-backdrop {
  background-image: url("https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?auto=format&fit=crop&w=1400&q=80");
}

.ambient-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(110px);
  pointer-events: none;
  z-index: -1;
}
.orb-1 {
  width: min(520px, 80vw);
  height: min(520px, 80vw);
  background: var(--orb-1);
  top: -140px;
  right: -100px;
}
.orb-2 {
  width: min(460px, 75vw);
  height: min(460px, 75vw);
  background: var(--orb-2);
  bottom: -120px;
  left: -120px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.mono,
.num {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

/* Fluid Glassmorphic Surfaces (Zero Boxy Shadows) */
.glass-panel {
  background: var(--surface-glass);
  backdrop-filter: blur(22px) saturate(145%);
  -webkit-backdrop-filter: blur(22px) saturate(145%);
  border: 1px solid var(--border-glass);
  box-shadow: var(--halo-shadow);
}

.fluid-card {
  background: var(--surface-glass);
  backdrop-filter: blur(20px) saturate(145%);
  -webkit-backdrop-filter: blur(20px) saturate(145%);
  border: 1px solid var(--border-glass);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--halo-shadow);
  min-width: 0;
  max-width: 100%;
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1), border-color 220ms ease;
}

.fluid-card:hover {
  border-color: var(--border-soft);
}

/* Auth Split Hero (3D Room Diorama + Fluid Glass Login) */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
}

.auth-hero-grid {
  width: 100%;
  max-width: 1080px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 28px;
  align-items: center;
}

.studio-3d-card {
  border-radius: 32px;
  padding: 22px;
  position: relative;
  overflow: hidden;
}

.room-banner-photo {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  min-height: 360px;
  background: linear-gradient(160deg, rgba(14, 116, 112, 0.16), rgba(198, 107, 61, 0.18));
  border: 1px solid var(--border-glass);
}

.room-banner-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.28;
}

#room-3d-canvas {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 360px;
  display: block;
  cursor: grab;
  touch-action: none;
}

#room-3d-canvas:active {
  cursor: grabbing;
}

.studio-3d-overlay {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  pointer-events: none;
}

.glass-chip {
  pointer-events: auto;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
}

.auth-card {
  width: 100%;
  padding: 28px;
  border-radius: 32px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--tab-gap);
  padding: 5px;
  border-radius: 999px;
  background: var(--surface-pill);
  border: 1px solid var(--border-soft);
  margin-bottom: 20px;
}

.auth-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  height: var(--tab-height);
  padding: 0 var(--tab-pad-x);
  border-radius: 999px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  cursor: pointer;
  transition: all 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-tab.is-active {
  background: linear-gradient(135deg, var(--primary), var(--accent-warm));
  color: #ffffff;
  box-shadow: var(--halo-glow);
}

.otp-preview-box {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--primary-soft);
  border: 1px solid var(--border-soft);
  color: var(--primary-soft-ink);
  font-size: 12px;
  font-weight: 600;
  display: grid;
  gap: 8px;
}

/* App Shell */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border-glass);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent-warm));
  color: #ffffff;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: var(--halo-glow);
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.nav-stack {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  min-height: var(--tab-height);
  padding: 10px var(--tab-pad-x);
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-item:hover {
  background: var(--surface-pill);
  color: var(--ink);
}

.nav-item.is-active {
  background: linear-gradient(135deg, var(--primary-soft), rgba(198, 107, 61, 0.14));
  color: var(--primary-soft-ink);
  border-color: var(--border-soft);
}

.sidebar-foot {
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
  display: grid;
  gap: 8px;
}

.mode-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-pill);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  text-align: center;
}

/* Main Area & Floating Fluid Topbar */
.main-area {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}

.topbar {
  margin: 14px 24px 0;
  padding: 14px 22px;
  border-radius: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 14px;
  z-index: 40;
}

.topbar-title h1 {
  font-size: 20px;
  font-weight: 700;
}

.topbar-title p {
  font-size: 12px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.page-content {
  padding: 22px 24px 48px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  display: grid;
  gap: 22px;
  min-width: 0;
}

.page-content > section,
.grid-2 > *,
.grid-3 > *,
.form-grid > * {
  min-width: 0;
}

.card {
  background: var(--surface-glass);
  backdrop-filter: blur(22px) saturate(145%);
  -webkit-backdrop-filter: blur(22px) saturate(145%);
  border: 1px solid var(--border-glass);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--halo-shadow);
  min-width: 0;
  max-width: 100%;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
}

.card-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* Residence Hero Strip with Room Photo */
.residence-hero {
  position: relative;
  border-radius: 28px;
  overflow: hidden;
  padding: 24px;
  min-height: 150px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border: 1px solid var(--border-glass);
  box-shadow: var(--halo-shadow);
}

.residence-hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.residence-hero-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(110deg, rgba(13, 21, 34, 0.82) 0%, rgba(14, 116, 112, 0.56) 60%, rgba(198, 107, 61, 0.45) 100%);
}

.residence-hero-content {
  position: relative;
  z-index: 2;
  color: #ffffff;
}

.residence-hero-content h2 {
  font-size: 22px;
  font-weight: 700;
}

.residence-hero-content p {
  font-size: 13px;
  opacity: 0.9;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.kpi-card {
  border-radius: 24px;
  padding: 18px 20px;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-glass);
  box-shadow: var(--halo-shadow);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.kpi-card:hover {
  transform: translateY(-2px);
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 6px;
  letter-spacing: -0.02em;
}

.kpi-foot {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

/* Room Photo Thumb in Rooms Table */
.room-thumb {
  width: 48px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border-glass);
  flex-shrink: 0;
}

/* Fluid Glass Form Inputs */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--form-gap);
  align-items: start;
}

.field {
  display: grid;
  gap: 6px;
  align-content: start;
}

.field.is-full {
  grid-column: 1 / -1;
}

.field > label:not(.meter-input-pair):not(.bill-check-option):not(.check-chip) {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  min-height: var(--field-label-min-h);
  display: flex;
  align-items: center;
}

.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
  height: var(--control-height);
  width: 100%;
  box-sizing: border-box;
  padding: 9px 14px;
  border-radius: var(--control-radius);
  border: 1px solid var(--border-soft);
  background: var(--surface-input);
  font-size: 14px;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.field input[type="checkbox"],
.bill-check-option input[type="checkbox"],
.check-chip input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  flex-shrink: 0;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.field textarea {
  height: auto;
  min-height: var(--control-height);
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--primary);
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-pill);
  border: 1px solid var(--border-soft);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

/* Fluid Pill Buttons */
.btn {
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--surface-pill);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1), background-color 180ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent-warm));
  border-color: transparent;
  color: #ffffff;
  box-shadow: var(--halo-glow);
}

.btn-whatsapp {
  background: linear-gradient(135deg, #16a34a, #0e7470);
  border-color: transparent;
  color: #ffffff;
}

.btn-danger {
  color: var(--danger);
}

.btn-sm {
  min-height: 34px;
  padding: 5px 12px;
  font-size: 12px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-paid {
  background: var(--success-bg);
  color: var(--success);
}

.badge-partial,
.badge-awaiting {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-pending,
.badge-rejected {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-neutral {
  background: var(--surface-pill);
  color: var(--muted);
  border: 1px solid var(--border-soft);
}

/* Tables */
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 13px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Proof Verification Cards */
.proof-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--surface-pill);
  border: 1px solid var(--border-glass);
  flex-wrap: wrap;
}

.proof-thumb {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--border-soft);
  cursor: pointer;
  flex-shrink: 0;
}

.proof-cash-badge {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--surface-glass-strong);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

/* Breakdown & Formula Helpers */
.formula-hint {
  background: var(--surface-pill);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 11px 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.breakdown-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  border-radius: 16px;
  background: var(--surface-pill);
  border: 1px solid var(--border-glass);
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

.breakdown-row > div {
  min-width: 0;
  flex: 1;
}

.breakdown-row > div .mono {
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
}

.breakdown-row > .mono {
  white-space: nowrap;
  flex-shrink: 0;
  text-align: right;
}

/* Variable-Driven Aligned Meter & Multi-Bill Rows */
.meter-room-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--control-radius);
  background: var(--surface-pill);
  border: 1px solid var(--border-glass);
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.meter-room-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.meter-room-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--meter-pair-gap);
  align-items: end;
  min-width: 0;
}

.meter-input-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--field-label-min-h) var(--control-height-sm);
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  min-width: 0;
}

.meter-input-pair > span {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meter-input-pair > input {
  width: 100%;
  min-width: 0;
  height: var(--control-height-sm);
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--surface-input);
  font-size: 13px;
  box-sizing: border-box;
}

.bill-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
  gap: 8px;
}

.bill-check-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--control-height);
  padding: 8px 14px;
  border-radius: var(--control-radius);
  background: var(--surface-pill);
  border: 1px solid var(--border-soft);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.bill-check-option-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}

.breakdown-total {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-soft-ink);
  font-weight: 700;
}

.mobile-only-btn {
  display: none;
}

/* Modals & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 28, 0.56);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  padding: 24px;
  border-radius: 28px;
  max-height: 90vh;
  overflow-y: auto;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 120;
  background: var(--ink);
  color: var(--ink-inverse);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--halo-shadow);
}

/* User / Tenant Shell */
.user-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 68px;
  display: grid;
  gap: 20px;
}

/* Mobile Dock */
.mobile-nav {
  display: none;
}

@media (max-width: 960px) {
  .auth-hero-grid {
    grid-template-columns: 1fr;
  }
  .room-banner-photo,
  #room-3d-canvas {
    min-height: 250px;
    height: 250px;
  }
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .topbar {
    margin: 10px 12px 0;
    padding: 12px 14px;
    top: 10px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .kpi-value {
    font-size: 20px;
  }
  .grid-2,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .page-content {
    padding: 16px 12px 112px;
  }
  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 60;
    border-radius: 24px;
    padding: 6px 4px;
  }
  .mobile-nav button {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    border-radius: 18px;
  }
  .mobile-nav button.is-active {
    color: var(--primary);
    background: var(--primary-soft);
  }
  .mobile-only-btn {
    display: inline-flex;
  }
  .toast {
    bottom: 82px;
  }
}

@media print {
  .sidebar,
  .topbar-actions,
  .mobile-nav,
  .no-print {
    display: none !important;
  }
  body {
    background: #ffffff;
    color: #000000;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}
