/* ============================================================
   HOA Management System — Stylesheet
   Clean, utilitarian, professional
   ============================================================ */

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

:root {
  --sidebar-w: 240px;
  --topbar-h: 56px;

  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface2: #f9fafb;
  --border: #e2e5ea;
  --border-strong: #c8cdd6;

  --text: #1a1d23;
  --text-2: #4b5563;
  --text-3: #9ca3af;

  --primary: #1e40af;
  --primary-hover: #1d3a9e;
  --primary-light: #dbeafe;

  --green: #16a34a;
  --green-bg: #dcfce7;
  --yellow: #b45309;
  --yellow-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --blue: #2563eb;
  --blue-bg: #dbeafe;

  --sidebar-bg: #111827;
  --sidebar-text: #d1d5db;
  --sidebar-active: #1e40af;
  --sidebar-hover: rgba(255,255,255,0.06);

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);

  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', monospace;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.hoa-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon { font-size: 24px; }

.logo-name {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

.logo-sub {
  font-size: 11px;
  color: var(--sidebar-text);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.3);
  padding: 16px 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: var(--sidebar-hover); }

.nav-item.active {
  background: rgba(30, 64, 175, 0.25);
  color: #93c5fd;
  border-left-color: var(--primary);
  font-weight: 500;
}

.nav-item.disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.nav-icon { font-size: 14px; width: 18px; }

.badge-coming {
  margin-left: auto;
  font-size: 9px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.5);
  padding: 1px 6px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.health-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}

.health-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}

.health-dot.offline { background: #f87171; }

/* ============================================================
   MOBILE TOPBAR
   ============================================================ */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--sidebar-bg);
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 101;
}

.mobile-title { color: #fff; font-weight: 600; font-size: 15px; }

.hamburger {
  background: none; border: none;
  color: #fff; font-size: 20px;
  cursor: pointer; padding: 4px;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 32px;
  max-width: 1400px;
}

.page { animation: fadeIn 0.2s ease; }
.page.hidden { display: none; }

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

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--text-2);
  margin-top: 2px;
  font-size: 14px;
}

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

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: var(--font);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface2); }

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

.btn-sm {
  padding: 4px 10px;
  font-size: 12.5px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 5px;
  font-size: 15px;
  transition: background 0.15s;
}
.btn-icon:hover { background: var(--bg); }

/* ============================================================
   INPUTS
   ============================================================ */
.search-input, .filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13.5px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.search-input { width: 200px; }
.search-input:focus, .filter-select:focus { border-color: var(--primary); }

/* ============================================================
   DASHBOARD STATS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-card.loading {
  color: var(--text-3);
  text-align: center;
  padding: 32px;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 6px;
}

.stat-icon {
  font-size: 24px;
  float: right;
  margin-top: -4px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.card-header h3 { font-size: 15px; font-weight: 600; }
.card-label { font-size: 12px; color: var(--text-3); }

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

.list-container { padding: 8px 0; }

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.list-item:last-child { border-bottom: none; }
.list-item-main { font-weight: 500; }
.list-item-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }

.empty-state-sm {
  padding: 24px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface2); }

.loading-row { text-align: center; color: var(--text-3); padding: 32px !important; }

.td-mono {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

/* ============================================================
   BADGES / STATUS PILLS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-active { background: var(--green-bg); color: var(--green); }
.badge-inactive { background: var(--border); color: var(--text-3); }
.badge-pending { background: var(--yellow-bg); color: var(--yellow); }
.badge-expired { background: var(--border); color: var(--text-3); }
.badge-revoked { background: var(--red-bg); color: var(--red); }
.badge-visitor { background: var(--blue-bg); color: var(--blue); }
.badge-assigned { background: var(--primary-light); color: var(--primary); }
.badge-available { background: var(--green-bg); color: var(--green); }
.badge-occupied { background: var(--red-bg); color: var(--red); }

/* ============================================================
   PARKING GRID
   ============================================================ */
.parking-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.parking-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.parking-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.parking-card.occupied { border-color: #fca5a5; }
.parking-card.available { border-color: #86efac; }

.spot-number {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 4px;
}

.spot-type-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 10px;
}

.spot-unit {
  font-size: 12.5px;
  color: var(--text-2);
  margin-top: 6px;
}

.spot-plate {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-top: 4px;
}

.spot-status-dot {
  position: absolute;
  top: 12px; right: 12px;
  width: 9px; height: 9px;
  border-radius: 50%;
}

.spot-status-dot.green { background: #4ade80; }
.spot-status-dot.red { background: #f87171; }

/* ============================================================
   PLATE LOOKUP
   ============================================================ */
.lookup-container {
  max-width: 680px;
}

.lookup-search-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.plate-input-wrapper {
  display: flex;
  gap: 12px;
  align-items: center;
}

.plate-input {
  flex: 1;
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 500;
  padding: 14px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.15s;
}

.plate-input:focus { border-color: var(--primary); }

.lookup-result {
  margin-top: 16px;
}

.lookup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.lookup-card.found { border-color: #86efac; }
.lookup-card.not-found { border-color: var(--border); }

.lookup-status {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lookup-details { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; margin-top: 16px; }
.lookup-detail { font-size: 13px; }
.lookup-detail-label { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
.lookup-detail-value { font-weight: 500; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  backdrop-filter: blur(2px);
}

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

.modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -48%);
  width: 560px;
  max-width: calc(100vw - 32px);
  max-height: 90vh;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  overflow: hidden;
  flex-direction: column;
}

.modal.modal-sm { width: 420px; }

.modal.active {
  display: flex;
  animation: modalIn 0.2s cubic-bezier(.34,1.56,.64,1);
}

@keyframes modalIn {
  from { transform: translate(-50%, -46%); opacity: 0; }
  to { transform: translate(-50%, -50%); opacity: 1; }
}

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

.modal-header h2 { font-size: 17px; font-weight: 600; }

.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 18px;
  padding: 4px 8px; border-radius: 5px;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--bg); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 64px; }

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

.form-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0 12px; }

.form-section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 12px;
}

/* ============================================================
   PASS DISPLAY
   ============================================================ */
.pass-display {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}

.pass-code-display {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0.12em;
  background: rgba(255,255,255,0.15);
  padding: 12px 24px;
  border-radius: var(--radius);
  margin: 12px 0;
  display: inline-block;
}

.pass-details-display {
  font-size: 13px;
  opacity: 0.85;
  margin-top: 12px;
  line-height: 1.8;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius);
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease;
  max-width: 340px;
  min-width: 220px;
}

.toast.success { background: #166534; }
.toast.error { background: #991b1b; }
.toast.info { background: #1e40af; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-topbar { display: flex; }
  .main-content { margin-left: 0; padding: 80px 16px 24px; }
  .two-col-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .plate-input-wrapper { flex-direction: column; }
  .plate-input { font-size: 22px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .parking-grid { grid-template-columns: 1fr 1fr; }
  .page-actions { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
}
