/* ==========================================================================
   Mali Manager — Design System CSS
   Comprehensive stylesheet for Owner, Tenant, and Admin portals
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. GOOGLE FONTS IMPORT
   -------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* --------------------------------------------------------------------------
   2. CSS CUSTOM PROPERTIES (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
  /* Typography */
  --font-heading: 'DM Serif Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;

  /* Portal-agnostic neutral palette */
  --color-white: #ffffff;
  --color-off-white: #f8f9fa;
  --color-light-grey: #e9ecef;
  --color-mid-grey: #adb5bd;
  --color-grey: #95a5a6;
  --color-dark: #1a1a2e;

  /* Status colours */
  --color-success: #2ecc71;
  --color-success-bg: #d5f5e3;
  --color-warning: #f39c12;
  --color-warning-bg: #fef9e7;
  --color-danger: #e74c3c;
  --color-danger-bg: #fdedec;
  --color-info: #3498db;
  --color-info-bg: #ebf5fb;
  --color-partial: #2980b9;
  --color-partial-bg: #d6eaf8;

  /* Default accent (overridden by portal class) */
  --accent: #2A9D8F;
  --accent-dark: #21867a;
  --accent-light: #e0f5f3;
  --portal-bg: #FAFAF8;
  --sidebar-bg: #ffffff;
  --sidebar-text: #1a1a2e;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10), 0 4px 10px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.14), 0 6px 14px rgba(0, 0, 0, 0.06);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s ease;

  /* Sidebar */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 70px;
  --topnav-height: 64px;
  --bottomnav-height: 64px;
}

/* --------------------------------------------------------------------------
   3. PORTAL THEME CLASSES (apply to <body>)
   -------------------------------------------------------------------------- */
body.portal-owner {
  --accent: #2A9D8F;
  --accent-dark: #21867a;
  --accent-rgb: 42, 157, 143;
  --accent-light: #e0f5f3;
  --portal-bg: #FAFAF8;
  --sidebar-bg: #ffffff;
  --sidebar-text: #1a1a2e;
  --sidebar-active-bg: #e0f5f3;
  --sidebar-active-text: #2A9D8F;
}

body.portal-tenant {
  --accent: #16a34a;
  --accent-dark: #15803d;
  --accent-rgb: 22, 163, 74;
  --accent-light: #dcfce7;
  --accent-tenant: #16a34a;
  --portal-bg: #f0fdf4;
  --sidebar-bg: #ffffff;
  --sidebar-text: #1a1a2e;
  --sidebar-active-bg: #dcfce7;
  --sidebar-active-text: #16a34a;
}

body.portal-admin {
  --accent: #2A9D8F;
  --accent-dark: #21867a;
  --accent-rgb: 42, 157, 143;
  --accent-light: rgba(42, 157, 143, 0.15);
  --portal-bg: #111111;
  --sidebar-bg: #0a0a0a;
  --sidebar-text: #cbd5e1;
  --sidebar-active-bg: rgba(42, 157, 143, 0.12);
  --sidebar-active-text: #2A9D8F;
}

/* --------------------------------------------------------------------------
   4. BASE RESET & BODY
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--portal-bg, #FAFAF8);
  color: var(--color-dark);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.portal-admin {
  color: #e2e8f0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 400;
  line-height: 1.2;
}

/* --------------------------------------------------------------------------
   5. ANIMATIONS
   -------------------------------------------------------------------------- */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes shimmer {
  0% { background-position: -468px 0; }
  100% { background-position: 468px 0; }
}

.fade-in {
  animation: fadeIn 0.4s ease both;
}

.fade-in-up {
  animation: fadeInUp 0.5s ease both;
}

/* Staggered fade-in for lists */
.fade-in-stagger > * {
  animation: fadeInUp 0.4s ease both;
}

.fade-in-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.fade-in-stagger > *:nth-child(2) { animation-delay: 0.10s; }
.fade-in-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.fade-in-stagger > *:nth-child(4) { animation-delay: 0.20s; }
.fade-in-stagger > *:nth-child(5) { animation-delay: 0.25s; }
.fade-in-stagger > *:nth-child(6) { animation-delay: 0.30s; }

/* --------------------------------------------------------------------------
   6. CARD COMPONENTS
   -------------------------------------------------------------------------- */
.card-dph {
  background: var(--color-white);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: none;
  padding: var(--space-lg);
  transition: box-shadow var(--transition-base);
}

.card-dph:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transform: none;
}

body.portal-admin .card-dph {
  background: #1e1e1e;
  border-color: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

/* Stat card — large number display */
.stat-card {
  background: var(--color-white);
  border: 1px solid #e5e7eb;
  border-top: 3px solid var(--accent);
  border-radius: 8px;
  box-shadow: none;
  padding: 1.1rem 1.25rem 1rem;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition-base);
}

.stat-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transform: none;
}

.stat-card .stat-number {
  font-family: var(--font-body);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--color-dark);
  margin-bottom: var(--space-xs);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-grey);
}

.stat-card .stat-icon {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  font-size: 1.6rem;
  opacity: 0.07;
  color: var(--accent);
}

.stat-card .stat-change {
  font-size: 0.78rem;
  margin-top: var(--space-xs);
  color: var(--color-grey);
}

.stat-card.stat-accent {
  background: var(--accent);
  border-color: transparent;
}

.stat-card.stat-accent .stat-number,
.stat-card.stat-accent .stat-label,
.stat-card.stat-accent .stat-change {
  color: var(--color-white);
}

.stat-card.stat-accent .stat-icon {
  color: var(--color-white);
  opacity: 0.25;
}

body.portal-admin .stat-card {
  background: #1e1e1e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top: 3px solid #2A9D8F;
}

body.portal-admin .stat-card .stat-number {
  color: #2A9D8F;
}

body.portal-admin .stat-card .stat-icon {
  opacity: 0.14;
}

/* Balance cards */
.balance-card-clear {
  background: var(--color-success-bg);
  border: 1px solid #a9dfbf;
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

.balance-card-due {
  background: var(--color-warning-bg);
  border: 1px solid #f9e79f;
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

.balance-card-overdue {
  background: var(--color-danger-bg);
  border: 1px solid #f1948a;
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

.balance-card-clear .balance-amount,
.balance-card-due .balance-amount,
.balance-card-overdue .balance-amount {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.8rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.balance-card-clear .balance-amount { color: #1a7a45; }
.balance-card-due .balance-amount { color: #9a6a00; }
.balance-card-overdue .balance-amount { color: #c0392b; }

/* --------------------------------------------------------------------------
   7. STATUS PILLS
   -------------------------------------------------------------------------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.22em 0.75em;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  line-height: 1.4;
}

.status-pill::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill-paid {
  background-color: var(--color-success-bg);
  color: #1a6b40;
}

.pill-due {
  background-color: var(--color-warning-bg);
  color: #8a5a00;
}

.pill-overdue {
  background-color: var(--color-danger-bg);
  color: #a93226;
}

.pill-upcoming {
  background-color: #f2f3f4;
  color: #5d6d7e;
}

.pill-partial {
  background-color: var(--color-partial-bg);
  color: #1a5276;
}

.pill-active {
  background-color: var(--color-success-bg);
  color: #1a6b40;
}

.pill-inactive {
  background-color: #f2f3f4;
  color: #5d6d7e;
}

.pill-occupied {
  background-color: var(--color-info-bg);
  color: #1a5276;
}

.pill-vacant {
  background-color: var(--color-success-bg);
  color: #1a6b40;
}

.pill-maintenance {
  background-color: var(--color-warning-bg);
  color: #8a5a00;
}

/* --------------------------------------------------------------------------
   8. BUTTONS
   -------------------------------------------------------------------------- */
.btn-dph-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background-color: var(--accent);
  color: var(--color-white);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.25rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
}

.btn-dph-primary:hover {
  background-color: var(--accent-dark);
  border-color: var(--accent-dark);
  color: var(--color-white);
  box-shadow: 0 2px 8px rgba(var(--accent-rgb, 42, 157, 143), 0.25);
}

.btn-dph-primary:active {
  transform: translateY(0);
}

.btn-dph-primary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-dph-primary:disabled,
.btn-dph-primary.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-dph-outline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background-color: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.25rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  white-space: nowrap;
}

.btn-dph-outline:hover {
  background-color: var(--accent);
  color: var(--color-white);
}

.btn-dph-outline:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-dph-outline:active {
  transform: translateY(0);
}

/* Filled danger — use with btn-dph-primary for destructive primaries */
.btn-dph-primary.btn-dph-danger {
  background-color: var(--color-danger);
  border-color: var(--color-danger);
  color: var(--color-white);
}
.btn-dph-primary.btn-dph-danger:hover {
  background-color: #c0392b;
  border-color: #c0392b;
  color: var(--color-white);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.35);
}

/* Outline danger — use with btn-dph-outline for secondary destructive actions */
.btn-dph-outline.btn-dph-outline-danger {
  color: var(--color-danger);
  border-color: var(--color-danger);
}
.btn-dph-outline.btn-dph-outline-danger:hover {
  background-color: var(--color-danger);
  color: var(--color-white);
  border-color: var(--color-danger);
}
.btn-dph-outline.btn-dph-outline-danger:focus-visible {
  outline: 2px solid var(--color-danger);
}


/* Small button */
.btn-dph-sm {
  padding: 0.3rem 0.85rem;
  font-size: 0.8rem;
}

/* Forms used as button wrappers inside flex groups must not distort layout */
.d-flex > form {
  display: contents;
}

/* --------------------------------------------------------------------------
   9. LAYOUT — SIDEBAR
   -------------------------------------------------------------------------- */

/* Desktop: fixed left sidebar */
.layout-with-sidebar {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  transition: width var(--transition-base), transform var(--transition-base);
  overflow-x: hidden;
  overflow-y: auto;
}

body.portal-admin .sidebar {
  background: var(--sidebar-bg);
  border-right-color: rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

body.portal-admin .sidebar-brand {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

body.portal-admin .sidebar-brand .brand-tagline {
  color: #64748b;
}

.sidebar-brand .brand-name {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--accent);
  line-height: 1.1;
  text-decoration: none;
  display: block;
}

/* Sidebar brand row */
.sidebar-brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.sidebar-brand-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  object-fit: contain;
}
.sidebar-brand-row .brand-name {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.1rem;
  color: #1e4d5c;
  letter-spacing: -0.01em;
  line-height: 1;
}

body.portal-admin .sidebar-brand-row .brand-name {
  color: #f1f5f9;
}

.sidebar-brand .brand-tagline {
  font-size: 0.7rem;
  color: var(--color-grey);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}


.sidebar-nav {
  flex: 1;
  padding: var(--space-md) 0;
  list-style: none;
  margin: 0;
}

.sidebar-nav .nav-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-grey);
  padding: var(--space-md) var(--space-lg) var(--space-xs);
  margin-top: var(--space-sm);
}

.sidebar-nav .nav-item {
  margin: 2px var(--space-sm);
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav .nav-link .nav-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.sidebar-nav .nav-link:hover {
  background-color: var(--sidebar-active-bg, var(--accent-light));
  color: var(--accent);
}

.sidebar-nav .nav-link.active {
  background-color: var(--sidebar-active-bg, var(--accent-light));
  color: var(--sidebar-active-text, var(--accent));
  font-weight: 600;
}

body.portal-admin .sidebar-nav .nav-link {
  color: #94a3b8;
}

body.portal-admin .sidebar-nav .nav-link:hover,
body.portal-admin .sidebar-nav .nav-link.active {
  background-color: rgba(42, 157, 143, 0.12);
  color: #2A9D8F;
}

/* Sidebar user section at bottom */
.sidebar-user {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

body.portal-admin .sidebar-user {
  border-top-color: rgba(255, 255, 255, 0.06);
}

.sidebar-signout-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  transition: border-color var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast);
}

.sidebar-signout-btn:hover {
  border-color: rgba(248, 113, 113, 0.3);
  color: #f87171;
  background: rgba(248, 113, 113, 0.06);
}

.sidebar-signout-btn:focus-visible {
  outline: 2px solid #f87171;
  outline-offset: 2px;
}

body.portal-owner .sidebar-signout-btn {
  border-color: rgba(0, 0, 0, 0.12);
  color: var(--color-grey);
}

body.portal-owner .sidebar-signout-btn:hover {
  border-color: rgba(231, 76, 60, 0.3);
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.05);
}

body.portal-owner .sidebar-signout-btn:focus-visible {
  outline-color: #e74c3c;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-info .user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.portal-admin .user-info .user-name {
  color: #e2e8f0;
}

.user-info .user-role {
  font-size: 0.72rem;
  color: var(--color-grey);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --------------------------------------------------------------------------
   10. LAYOUT — MAIN CONTENT
   -------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-base);
}

.main-content-inner {
  flex: 1;
  padding: var(--space-xl) var(--space-xl);
  max-width: 1400px;
  width: 100%;
}

/* --------------------------------------------------------------------------
   11. PAGE HEADER
   -------------------------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}

.page-header .page-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: var(--color-dark);
  margin: 0;
  line-height: 1.15;
}

body.portal-admin .page-header .page-title,
body.portal-admin .page-title {
  color: var(--color-white);
}

.page-header .page-subtitle,
.page-subtitle {
  font-size: 0.88rem;
  color: var(--color-grey);
  margin-top: 2px;
}

.page-header .page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   12. MOBILE TOPBAR
   -------------------------------------------------------------------------- */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  height: var(--topnav-height);
  background: var(--sidebar-bg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: 900;
}

body.portal-admin .mobile-topbar {
  background: var(--sidebar-bg);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.mobile-topbar .brand-name {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--accent);
  text-decoration: none;
}

.hamburger-btn {
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 1.4rem;
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

body.portal-admin .hamburger-btn {
  color: #e2e8f0;
}

.hamburger-btn:hover {
  background-color: var(--accent-light);
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  backdrop-filter: blur(2px);
}

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

/* --------------------------------------------------------------------------
   13. BOTTOM NAV (Tenant mobile)
   -------------------------------------------------------------------------- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottomnav-height);
  background: var(--color-white);
  border-top: 1px solid var(--color-light-grey);
  z-index: 900;
  align-items: stretch;
}

.bottom-nav .bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--color-grey);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color var(--transition-fast);
  padding: var(--space-xs);
}

.bottom-nav .bottom-nav-item i {
  font-size: 1.2rem;
}

.bottom-nav .bottom-nav-item.active,
.bottom-nav .bottom-nav-item:hover {
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   14. TOP NAVBAR (Tenant portal)
   -------------------------------------------------------------------------- */
.tenant-topnav {
  background: var(--color-white);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding: 0 var(--space-xl);
  height: var(--topnav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

.tenant-topnav .navbar-brand-text {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--accent);
  text-decoration: none;
}

.tenant-topnav .nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  list-style: none;
  margin: 0;
  padding: 0;
}

.tenant-topnav .nav-links a {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--color-dark);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.tenant-topnav .nav-links a:hover,
.tenant-topnav .nav-links a.active {
  background-color: var(--accent-light);
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   15. EMPTY STATE
   -------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 3.5rem;
  color: var(--color-light-grey);
  margin-bottom: var(--space-lg);
  line-height: 1;
}

.empty-state .empty-title {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--color-dark);
  margin-bottom: var(--space-sm);
}

body.portal-admin .empty-state .empty-title {
  color: #e2e8f0;
}

.empty-state .empty-message {
  font-size: 0.9rem;
  color: var(--color-grey);
  max-width: 380px;
  line-height: 1.6;
  margin-bottom: var(--space-lg);
}

/* --------------------------------------------------------------------------
   16. TOAST / DJANGO MESSAGES
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 380px;
  width: calc(100vw - 2rem);
}

.dph-toast {
  background: var(--color-white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: var(--space-md) var(--space-lg);
  border-left: 4px solid var(--accent);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  animation: fadeIn 0.3s ease;
  font-size: 0.88rem;
}

.dph-toast.toast-success { border-left-color: var(--color-success); }
.dph-toast.toast-warning { border-left-color: var(--color-warning); }
.dph-toast.toast-danger  { border-left-color: var(--color-danger);  }
.dph-toast.toast-info    { border-left-color: var(--color-info);    }

.dph-toast .toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.dph-toast.toast-success .toast-icon { color: var(--color-success); }
.dph-toast.toast-warning .toast-icon { color: var(--color-warning); }
.dph-toast.toast-danger  .toast-icon { color: var(--color-danger);  }
.dph-toast.toast-info    .toast-icon { color: var(--color-info);    }

.dph-toast .toast-body {
  flex: 1;
  color: var(--color-dark);
}

.dph-toast .toast-close {
  background: none;
  border: none;
  color: var(--color-grey);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.dph-toast .toast-close:hover {
  color: var(--color-dark);
}

/* --------------------------------------------------------------------------
   17. FORM STYLING ENHANCEMENTS
   -------------------------------------------------------------------------- */
.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-dark);
  margin-bottom: 0.35rem;
}

body.portal-admin .form-label {
  color: #cbd5e1;
}

.form-control,
.form-select {
  border-radius: var(--radius-sm);
  border-color: var(--color-light-grey);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  font-family: var(--font-body);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 42, 157, 143), 0.15);
  outline: none;
}

body.portal-admin .form-control,
body.portal-admin .form-select {
  background: #262626;
  border-color: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

body.portal-admin .form-control::placeholder {
  color: #64748b;
}

body.portal-admin .form-control:focus,
body.portal-admin .form-select:focus {
  background: #262626;
  border-color: #2A9D8F;
  box-shadow: 0 0 0 3px rgba(42, 157, 143, 0.15);
  color: #e2e8f0;
}

/* --------------------------------------------------------------------------
   18. PROGRESS BAR
   -------------------------------------------------------------------------- */
.progress-dph {
  height: 5px;
  border-radius: 3px;
  background-color: var(--color-light-grey);
  overflow: hidden;
}

.progress-dph .progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width 0.8s ease;
}

/* --------------------------------------------------------------------------
   19. SECTION HEADERS
   -------------------------------------------------------------------------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.section-title {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-dark);
  margin: 0;
}

body.portal-admin .section-title {
  color: #e2e8f0;
}

/* --------------------------------------------------------------------------
   20. PAYMENT / TENANT LIST ITEMS
   -------------------------------------------------------------------------- */
.list-item-card {
  background: transparent;
  border: none;
  border-bottom: 1px solid #f3f4f6;
  border-radius: 0;
  padding: 0.65rem 0.25rem;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  transition: background var(--transition-fast);
}

.list-item-card:hover {
  background: #f9fafb;
  border-radius: 6px;
  box-shadow: none;
  transform: none;
}

body.portal-admin .list-item-card {
  background: #1e1e1e;
  border-color: rgba(255, 255, 255, 0.06);
}

.list-item-card .item-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.list-item-card .item-main {
  flex: 1;
  min-width: 0;
}

.list-item-card .item-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--color-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.portal-admin .list-item-card .item-name {
  color: #e2e8f0;
}

.list-item-card .item-sub {
  font-size: 0.78rem;
  color: var(--color-grey);
  margin-top: 1px;
}

.list-item-card .item-amount {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--color-dark);
  text-align: right;
  white-space: nowrap;
}

body.portal-admin .list-item-card .item-amount {
  color: #e2e8f0;
}

/* --------------------------------------------------------------------------
   21. ADMIN-SPECIFIC — SYSTEM BADGE
   -------------------------------------------------------------------------- */
.system-admin-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--accent);
  color: var(--color-dark);
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.2em 0.6em;
  border-radius: var(--radius-pill);
}

/* --------------------------------------------------------------------------
   22. TYPE BADGE (Property type, Room type, etc.)
   -------------------------------------------------------------------------- */
.type-badge {
  display: inline-block;
  padding: 0.2em 0.7em;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--accent-light);
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   23. COLLECTION RATE DISPLAY
   -------------------------------------------------------------------------- */
.collection-stat {
  text-align: center;
  padding: var(--space-md);
}

.collection-rate-number {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 3rem;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -0.03em;
}

.financial-figure {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--color-dark);
}

body.portal-admin .financial-figure {
  color: #2A9D8F;
}

/* --------------------------------------------------------------------------
   24. LANGUAGE TOGGLE
   -------------------------------------------------------------------------- */
.lang-toggle {
  background: none;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-pill);
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.lang-toggle:hover {
  background: var(--accent);
  color: var(--color-white);
}

/* --------------------------------------------------------------------------
   25. DIVIDER
   -------------------------------------------------------------------------- */
.dph-divider {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
  margin: var(--space-lg) 0;
}

body.portal-admin .dph-divider {
  border-top-color: rgba(255, 255, 255, 0.07);
}

/* --------------------------------------------------------------------------
   26. LOADING SKELETON
   -------------------------------------------------------------------------- */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 37%, #f0f0f0 63%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   27. RESPONSIVE BREAKPOINTS
   -------------------------------------------------------------------------- */

/* Tablet and below — sidebar becomes overlay */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 1001;
  }

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

  .main-content {
    margin-left: 0;
  }

  .mobile-topbar {
    display: flex;
  }

  .main-content-inner {
    padding: var(--space-lg) var(--space-md);
  }

  .page-header .page-title {
    font-size: 1.5rem;
  }

  .stat-card .stat-number {
    font-size: 1.8rem;
  }
}

/* Mobile */
@media (max-width: 767.98px) {
  .main-content-inner {
    padding: var(--space-md);
  }

  .tenant-topnav {
    padding: 0 var(--space-md);
  }

  .tenant-topnav .nav-links {
    display: none;
  }

  .tenant-topnav .nav-links.mobile-open {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--topnav-height);
    left: 0;
    right: 0;
    background: var(--color-white);
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-light-grey);
    box-shadow: var(--shadow-md);
    gap: 4px;
    z-index: 900;
  }

  /* Show bottom nav on mobile for tenant */
  .portal-tenant .bottom-nav {
    display: flex;
  }

  .portal-tenant .tenant-content {
    padding-bottom: calc(var(--bottomnav-height) + var(--space-md));
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .balance-card-clear,
  .balance-card-due,
  .balance-card-overdue {
    margin-bottom: var(--space-md);
  }

  .financial-figure {
    font-size: 1.3rem;
  }

  .collection-rate-number {
    font-size: 2.2rem;
  }

  .stat-card .stat-number {
    font-size: 1.6rem;
  }

  /* Section header wraps on mobile */
  .section-header {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--space-sm);
  }
}

/* Small phones (<576px) */
@media (max-width: 575.98px) {
  .main-content-inner {
    padding: var(--space-md) var(--space-sm);
  }

  .page-header .page-title {
    font-size: 1.25rem;
  }

  /* Cards — tighter padding on small phones */
  .card-dph {
    padding: 1rem;
  }

  .stat-card {
    padding: 0.85rem 1rem 0.8rem;
  }

  .stat-card .stat-number {
    font-size: 1.4rem;
  }

  .financial-figure {
    font-size: 1.05rem;
  }

  /* Revenue card stacks vertically on small phones */
  .revenue-card-flex {
    flex-direction: column !important;
    gap: 0.75rem;
  }

  .revenue-card-flex .revenue-card-right {
    text-align: left !important;
  }

  /* Property stat numbers scale down */
  .prop-stat-num {
    font-size: 1.25rem !important;
  }

  /* Touch targets — 44px min for primary actions */
  .btn-dph-primary,
  .btn-dph-outline {
    min-height: 44px;
  }

  /* Month filter input fills space */
  .month-filter-input {
    width: 100% !important;
    max-width: 180px;
  }

  /* List item cards — prevent cramping */
  .list-item-card {
    gap: 0.6rem;
  }

  .list-item-card .item-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.82rem;
  }

  /* Mobile topbar — tighter brand */
  .mobile-topbar .brand-name {
    font-size: 1rem !important;
  }
}

/* Large screens — extra padding */
@media (min-width: 1400px) {
  .main-content-inner {
    padding: var(--space-xl) var(--space-2xl);
  }
}

/* --------------------------------------------------------------------------
   28. UTILITY CLASSES
   -------------------------------------------------------------------------- */
.text-accent { color: var(--accent) !important; }
.bg-accent { background-color: var(--accent) !important; }
.text-muted-dph { color: var(--color-grey) !important; }
.font-heading { font-family: var(--font-heading) !important; }
.font-body { font-family: var(--font-body) !important; }

.rounded-dph { border-radius: var(--radius-md) !important; }
.rounded-lg-dph { border-radius: var(--radius-lg) !important; }

.shadow-dph { box-shadow: var(--shadow-md) !important; }

.gap-dph { gap: var(--space-md) !important; }

/* Truncate text */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Money display */
.money {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

/* Urgency carried by avatar + text colours — no side stripe */
.row-overdue,
.row-due {}

/* --------------------------------------------------------------------------
   29a. OWNER ROW — admin portal
   -------------------------------------------------------------------------- */
.admin-owner-row {
  transition: background-color var(--transition-fast);
}

body.portal-admin .admin-owner-row:hover {
  background: rgba(42, 157, 143, 0.04);
}

/* --------------------------------------------------------------------------
   29b. REDUCED MOTION
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .fade-in,
  .fade-in-up,
  .fade-in-stagger > * {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .sidebar,
  .nav-link,
  .btn-dph-primary,
  .btn-dph-outline,
  .btn-dph-danger,
  .stat-card,
  .card-dph,
  .list-item-card,
  .progress-dph .progress-bar-fill {
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------------------
   29. SCROLLBAR CUSTOMISATION (WebKit)
   -------------------------------------------------------------------------- */
.sidebar::-webkit-scrollbar,
.main-content::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 2px;
}

body.portal-admin .sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
}

/* --------------------------------------------------------------------------
   30. URGENCY CARDS — dashboard overdue / due-soon sections
   -------------------------------------------------------------------------- */
.card-dph.urgency-card-danger {
  background: #fff9f9;
  border-color: rgba(231, 76, 60, 0.2);
}

.card-dph.urgency-card-warning {
  background: #fffdf5;
  border-color: rgba(243, 156, 18, 0.2);
}

/* --------------------------------------------------------------------------
   31. LEDGER TABLE
   -------------------------------------------------------------------------- */
.ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.ledger-table thead tr {
  background: #f8f9fa;
}

.ledger-table th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-grey);
  padding: 0.55rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.ledger-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.ledger-table tbody tr:last-child td {
  border-bottom: none;
}

.ledger-table tbody tr:hover td {
  background: #f9fafb;
}

/* --------------------------------------------------------------------------
   32. CREDENTIAL ROW — tenant detail info pairs
   -------------------------------------------------------------------------- */
.credential-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f3f4f6;
}

.credential-row:last-child {
  border-bottom: none;
}

.credential-label {
  font-size: 0.82rem;
  color: var(--color-grey);
}

.credential-value {
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--color-dark);
  font-family: monospace;
}

/* --------------------------------------------------------------------------
   33. NAV TEAM DIVIDER — portal-aware separator above secondary nav items
   -------------------------------------------------------------------------- */
.nav-team-divider {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

body.portal-admin .nav-team-divider {
  border-top-color: rgba(255, 255, 255, 0.08);
}

/* --------------------------------------------------------------------------
   34. COLLAPSIBLE SECTION TOGGLE — e.g. "Former Tenants" reveal
   -------------------------------------------------------------------------- */
.collapsible-section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.collapsible-section-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.collapsible-section-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-grey);
}

.collapsible-chevron {
  color: var(--color-grey);
  font-size: 0.85rem;
  transition: transform 0.2s;
}

@media print {
  .sidebar,
  .mobile-topbar,
  .bottom-nav,
  .toast-container {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .card-dph {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }
}
