@font-face {
  font-family: "Almarai";
  src: url("./Almarai-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

/* ========================================================================
   Design tokens
   ======================================================================== */

:root {
  /* Brand */
  --proptech-purple: #5b3a8c;
  --proptech-purple-deep: #3d2563;
  --proptech-purple-soft: #8b6dba;
  --proptech-purple-tint: #f4eefa;
  --proptech-blue: #2563eb;
  --proptech-blue-deep: #1e3a8a;
  --proptech-blue-tint: #eef2ff;

  /* Neutrals */
  --bg: #fafbfd;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-muted: #f6f7fb;
  --border: #e7e9f0;
  --border-strong: #d3d6e0;
  --text: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  /* Feedback */
  --success: #15803d;
  --success-bg: #f0fdf4;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;

  /* Shadows (layered) */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 6px 16px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 18px 40px rgba(91, 58, 140, 0.12), 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-purple-glow: 0 8px 28px rgba(91, 58, 140, 0.22);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 140ms;
  --duration-normal: 220ms;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Almarai", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.55;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================================================
   Top bar (logged-in pages)
   ======================================================================== */

.topbar {
  background: linear-gradient(135deg, var(--proptech-purple-deep) 0%, var(--proptech-purple) 55%, var(--proptech-blue) 100%);
  color: white;
  padding: 18px 32px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.topbar img { height: 32px; }
.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.topbar .topbar-divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.25);
  margin: 0 6px;
}
.topbar .topbar-context {
  font-size: 13.5px;
  opacity: 0.85;
  font-weight: 400;
}

.topbar .logout {
  margin-inline-start: auto;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition:
    background var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out);
}
.topbar .logout svg { width: 14px; height: 14px; }
.topbar .logout:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.55);
}

/* ========================================================================
   Page container + page header
   ======================================================================== */

.container { max-width: 1180px; margin: 0 auto; padding: 40px 28px 64px; }

.page-header {
  margin-bottom: 28px;
}
.page-header h2 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text);
}
.page-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14.5px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 32px 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.section-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.section-header .section-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  color: var(--proptech-blue);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: color var(--duration-normal) var(--ease-out);
}
.back-link svg { width: 14px; height: 14px; }
.back-link:hover { color: var(--proptech-blue-deep); }

/* ========================================================================
   Client cards (landing)
   ======================================================================== */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  box-shadow: var(--shadow-xs);
  transition:
    transform var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--proptech-purple-soft);
}

.card:focus-visible {
  outline: 2px solid var(--proptech-purple);
  outline-offset: 2px;
}

.card.disabled {
  opacity: 0.62;
  pointer-events: none;
  background: var(--surface-muted);
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.card-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--proptech-purple-tint) 0%, var(--proptech-blue-tint) 100%);
  color: var(--proptech-purple);
}
.card-icon svg { width: 20px; height: 20px; }

.card.disabled .card-icon {
  background: #eef0f5;
  color: var(--text-faint);
}

.card-title-block { flex: 1; min-width: 0; }
.card h3 {
  margin: 0 0 4px;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}
.card .meta {
  color: var(--text-muted);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.card .meta svg { width: 12px; height: 12px; opacity: 0.7; }

.card-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.1px;
}
.badge-active {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #bbf7d0;
}
.badge-pending {
  background: var(--surface-muted);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.card-arrow {
  color: var(--text-faint);
  transition:
    color var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
}
.card-arrow svg { width: 18px; height: 18px; }
.card:hover .card-arrow {
  color: var(--proptech-purple);
  transform: translateX(-3px); /* RTL: arrow points left, slides further left on hover */
}

/* ========================================================================
   Report list (per-client page)
   ======================================================================== */

.report-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-xs);
  transition:
    transform var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out);
  margin-bottom: 12px;
}
.report-row:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--proptech-purple-soft);
}
.report-row .card-icon { width: 38px; height: 38px; flex: 0 0 38px; }
.report-row-body { flex: 1; min-width: 0; }
.report-row-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}
.report-row-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}
.report-row-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.report-row-meta svg { width: 12px; height: 12px; }

/* ========================================================================
   Footer
   ======================================================================== */

.app-footer {
  text-align: center;
  padding: 28px 24px 36px;
  color: var(--text-faint);
  font-size: 12px;
}

/* ========================================================================
   Auth pages (login + totp) — split-screen layout
   ======================================================================== */

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  min-height: 100vh;
}

.auth-brand {
  background:
    radial-gradient(at 18% 20%, rgba(255, 255, 255, 0.10) 0px, transparent 55%),
    radial-gradient(at 85% 90%, rgba(37, 99, 235, 0.42) 0px, transparent 55%),
    linear-gradient(135deg, var(--proptech-purple-deep) 0%, var(--proptech-purple) 55%, var(--proptech-blue-deep) 100%);
  color: white;
  padding: 56px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.auth-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.045) 1px, transparent 0);
  background-size: 28px 28px;
  pointer-events: none;
}

.auth-brand-top {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}
.auth-brand-top img { height: 38px; }
.auth-brand-top .brand-name { font-size: 16px; font-weight: 700; opacity: 0.92; }

.auth-brand-mid { position: relative; max-width: 32em; }
.auth-brand-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  margin-bottom: 22px;
}
.auth-brand-eyebrow svg { width: 12px; height: 12px; }

.auth-brand-mid h2 {
  font-size: 40px;
  line-height: 1.2;
  margin: 0 0 16px;
  font-weight: 800;
  letter-spacing: -0.7px;
}
.auth-brand-mid p {
  font-size: 15px;
  line-height: 1.75;
  opacity: 0.86;
  margin: 0;
}

.auth-brand-bottom {
  position: relative;
  font-size: 12px;
  opacity: 0.7;
  letter-spacing: 0.5px;
}

.auth-form-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 408px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  box-shadow: var(--shadow-md);
}

.auth-card h2 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.auth-card .subtitle {
  margin: 0 0 26px;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.65;
}

.auth-card .field { display: block; margin-bottom: 18px; }
.auth-card .field label {
  display: block;
  font-size: 12.5px;
  margin-bottom: 7px;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.2px;
}
.auth-card .field input {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition:
    border-color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out);
}
.auth-card .field input::placeholder { color: var(--text-faint); }
.auth-card .field input:focus {
  outline: none;
  border-color: var(--proptech-purple);
  box-shadow: 0 0 0 4px rgba(91, 58, 140, 0.14);
}

/* TOTP code input — bigger, spaced, LTR */
.auth-card .field input.code {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 10px;
  text-align: center;
  direction: ltr;
  padding: 14px 12px;
}

.auth-card button[type="submit"] {
  width: 100%;
  padding: 13px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--proptech-purple) 0%, var(--proptech-blue) 100%);
  color: white;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: var(--shadow-purple-glow);
  transition:
    transform 50ms var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out),
    opacity var(--duration-normal) var(--ease-out);
}
.auth-card button[type="submit"]:hover {
  box-shadow: 0 12px 32px rgba(91, 58, 140, 0.32);
}
.auth-card button[type="submit"]:active { transform: translateY(1px); }
.auth-card button[type="submit"]:focus-visible {
  outline: 3px solid rgba(91, 58, 140, 0.4);
  outline-offset: 2px;
}
.auth-card button[type="submit"][disabled],
.auth-card button[type="submit"].loading {
  cursor: not-allowed;
  opacity: 0.78;
}

.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.auth-card button.loading .btn-spinner { display: inline-block; }

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

.auth-card .error {
  color: var(--danger);
  font-size: 12.5px;
  margin: 0 0 18px;
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: none;
  align-items: flex-start;
  gap: 8px;
}
.auth-card .error.visible { display: flex; }
.auth-card .error svg { width: 14px; height: 14px; flex: 0 0 14px; margin-top: 2px; }

.auth-card .back-link-secondary {
  display: block;
  text-align: center;
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--proptech-blue);
  text-decoration: none;
  font-weight: 500;
}
.auth-card .back-link-secondary:hover { text-decoration: underline; }

/* ========================================================================
   Mobile
   ======================================================================== */

@media (max-width: 820px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { padding: 32px 28px; min-height: 220px; }
  .auth-brand-mid h2 { font-size: 28px; }
  .auth-brand-mid p { font-size: 14px; }
  .auth-brand-bottom { display: none; }
  .auth-form-pane { padding: 32px 20px; }
  .auth-card { padding: 32px 24px; }
  .container { padding: 28px 18px 48px; }
  .page-header h2 { font-size: 24px; }
  .topbar { padding: 14px 18px; }
  .topbar h1 { font-size: 15px; }
  .topbar .topbar-context, .topbar .topbar-divider { display: none; }
}
