/* ═══════════════════════════════════════════════════════════════
   LeasePilot App Styles - Matching landing page design language
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --ink: #0a0f1a;
  --cream: #faf8f5;
  --amber: #e8a838;
  --amber-dark: #c78a1e;
  --amber-light: #fef3dc;
  --slate: #3d4f6f;
  --light-slate: #8a9bbd;
  --warm-gray: #f0ece6;
  --border: rgba(10, 15, 26, 0.08);
  --green: #2e7d32;
  --green-bg: #e8f5e9;
  --red: #c62828;
  --red-bg: #ffebee;
  --blue: #1565c0;
  --blue-bg: #e3f2fd;
  --shadow-sm: 0 1px 3px rgba(10, 15, 26, 0.04);
  --shadow-md: 0 4px 20px rgba(10, 15, 26, 0.06);
  --shadow-lg: 0 12px 40px rgba(10, 15, 26, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  line-height: 1.2;
}

/* ─── Layout ─────────────────────────────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 248px;
  background: var(--ink);
  color: white;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.2s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 8px;
  text-decoration: none;
  color: white;
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--amber);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo span {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
}

.nav-items {
  flex: 1;
  padding: 8px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  color: var(--light-slate);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.92rem;
  text-decoration: none;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: white;
}

.nav-item.active {
  background: rgba(232, 168, 56, 0.15);
  color: var(--amber);
  font-weight: 500;
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.main-content {
  flex: 1;
  margin-left: 248px;
  padding: 32px 40px;
  max-width: 1200px;
}

/* ─── Page Header ────────────────────────────────────────────── */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-header-sub {
  color: var(--slate);
  font-size: 0.92rem;
  margin-top: 4px;
}

/* ─── Buttons ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
  min-height: 44px;
}

.btn-primary {
  background: var(--amber);
  color: var(--ink);
}

.btn-primary:hover {
  background: var(--amber-dark);
}

.btn-secondary {
  background: white;
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--warm-gray);
}

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

.btn-danger:hover {
  background: #ffcdd2;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
  min-height: 36px;
}

.btn-ghost {
  background: transparent;
  color: var(--slate);
  padding: 6px 12px;
}

.btn-ghost:hover {
  background: var(--warm-gray);
}

/* ─── Cards ──────────────────────────────────────────────────── */

.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-body {
  padding: 24px;
}

/* ─── Stats Grid ─────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.stat-card-label {
  font-size: 0.82rem;
  color: var(--light-slate);
  margin-bottom: 8px;
  font-weight: 500;
}

.stat-card-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.stat-card-sub {
  font-size: 0.78rem;
  color: var(--slate);
  margin-top: 4px;
}

.stat-green { color: var(--green); }
.stat-red { color: var(--red); }
.stat-amber { color: var(--amber-dark); }

/* ─── Table ──────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 12px 16px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--warm-gray);
  border-bottom: 1px solid var(--border);
}

th:first-child { border-radius: var(--radius-sm) 0 0 0; }
th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

td {
  padding: 14px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(232, 168, 56, 0.03);
}

tr:last-child td {
  border-bottom: none;
}

/* ─── Status Badges ──────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
}

.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-light); color: var(--amber-dark); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-gray { background: var(--warm-gray); color: var(--slate); }

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ─── Forms ──────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--slate);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--ink);
  background: white;
  transition: border-color 0.15s ease;
  min-height: 44px;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(232, 168, 56, 0.1);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--light-slate);
  margin-top: 4px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--amber);
}

.form-check-label {
  font-size: 0.9rem;
}

/* ─── Messages / Inbox ───────────────────────────────────────── */

.message-list {
  list-style: none;
}

.message-item {
  display: flex;
  gap: 14px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s ease;
}

.message-item:hover {
  background: rgba(232, 168, 56, 0.03);
}

.message-item.unread {
  background: rgba(232, 168, 56, 0.05);
}

.message-item.unread .message-subject {
  font-weight: 600;
}

.message-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.message-dot.rent_reminder { background: var(--amber); }
.message-dot.overdue_notice { background: var(--red); }
.message-dot.payment_received { background: var(--green); }
.message-dot.general { background: var(--blue); }
.message-dot.system { background: var(--light-slate); }

.message-content {
  flex: 1;
  min-width: 0;
}

.message-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.message-subject {
  font-size: 0.9rem;
  color: var(--ink);
}

.message-time {
  font-size: 0.78rem;
  color: var(--light-slate);
  flex-shrink: 0;
}

.message-tenant {
  font-size: 0.8rem;
  color: var(--slate);
  margin-bottom: 4px;
}

.message-preview {
  font-size: 0.82rem;
  color: var(--light-slate);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-detail {
  padding: 24px;
}

.message-detail-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.message-detail-subject {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.message-detail-meta {
  display: flex;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--slate);
}

.message-detail-body {
  font-size: 0.92rem;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--ink);
}

/* ─── Empty State ────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--light-slate);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--slate);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9rem;
  max-width: 400px;
  margin: 0 auto 20px;
}

/* ─── Modal ──────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 26, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal {
  background: white;
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(10, 15, 26, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--light-slate);
  padding: 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--ink);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ─── Activity Feed ──────────────────────────────────────────── */

.activity-feed {
  list-style: none;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  flex-shrink: 0;
}

.activity-text {
  font-size: 0.88rem;
  color: var(--ink);
}

.activity-time {
  font-size: 0.75rem;
  color: var(--light-slate);
  margin-top: 2px;
}

/* ─── Payment Progress ───────────────────────────────────────── */

.progress-bar {
  height: 8px;
  background: var(--warm-gray);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* ─── Settings Toggle ────────────────────────────────────────── */

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

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

.setting-info h4 {
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 2px;
}

.setting-info p {
  font-size: 0.82rem;
  color: var(--light-slate);
}

.toggle {
  position: relative;
  width: 48px;
  height: 26px;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 26px;
  transition: 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}

.toggle input:checked + .toggle-slider {
  background: var(--amber);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* ─── Tenant Detail Header ───────────────────────────────────── */

.tenant-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.tenant-info h1 {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.tenant-meta {
  display: flex;
  gap: 16px;
  color: var(--slate);
  font-size: 0.88rem;
}

.tenant-actions {
  display: flex;
  gap: 8px;
}

/* ─── Grid layouts ───────────────────────────────────────────── */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

/* ─── Toast Notification ─────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--ink);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Hamburger (mobile) ─────────────────────────────────────── */

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--ink);
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--light-slate);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 24px 12px;
}

/* ─── Responsive ─────────────────────────────────────────────── */

@media (max-width: 900px) {
  .hamburger {
    display: flex;
  }

  .sidebar-close {
    display: block;
    text-align: right;
  }

  .sidebar {
    transform: translateX(-100%);
  }

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

  .main-content {
    margin-left: 0;
    padding: 72px 20px 32px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row, .form-row-3 {
    grid-template-columns: 1fr;
  }

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 72px 16px 24px;
  }
}

/* ─── Loading ────────────────────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--light-slate);
  gap: 8px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--warm-gray);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ─── Clickable rows ─────────────────────────────────────────── */

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td {
  background: rgba(232, 168, 56, 0.05);
}

/* ─── Number input arrows ────────────────────────────────────── */

.form-input[type="number"] {
  -moz-appearance: textfield;
}

.inline-number {
  width: 70px;
  display: inline-block;
  text-align: center;
  padding: 6px 8px;
  min-height: auto;
}

/* ─── Overdue list on dashboard ──────────────────────────────── */

.overdue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.overdue-item:last-child {
  border-bottom: none;
}

.overdue-tenant-info {
  display: flex;
  flex-direction: column;
}

.overdue-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.overdue-unit {
  font-size: 0.8rem;
  color: var(--light-slate);
}

.overdue-amount {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  color: var(--red);
}

/* ─── Message compose ────────────────────────────────────────── */

.compose-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
