/* ============================================================
   PRIME PROPERTY PROS — Customer Portal Stylesheet
   Aesthetic: Warm, refined, approachable. Light theme.
   Fonts: Fraunces (display) + Lato (body)
   Palette: Warm cream bg · forest green accents · gold highlights
   ============================================================ */

:root {
  --green:       #2d6a3f;
  --green-mid:   #3d8a55;
  --green-light: #4a9068;
  --green-pale:  #edf7f0;
  --green-pale2: #d4ead9;
  --gold:        #2d6a3f;
  --gold-light:  rgba(255,255,255,0.85);
  --gold-pale:   #edf7f0;
  --cream:       #ffffff;
  --cream-dark:  #f4f6f4;
  --white:       #ffffff;
  --text:        #1a2e1f;
  --text-mid:    #3a5244;
  --text-muted:  #6b8a76;
  --border:      #e2e8e3;
  --border-dark: #c2d4c9;
  --red:         #c0392b;
  --red-pale:    #fcecea;
  --blue:        #1a5c8f;
  --blue-pale:   #e8f2fa;
  --sidebar-w:   260px;
  --topbar-h:    64px;
  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   20px;
  --shadow-sm:   0 1px 4px rgba(30,69,50,0.06);
  --shadow-md:   0 4px 16px rgba(30,69,50,0.1);
  --shadow-lg:   0 8px 32px rgba(30,69,50,0.14);
  --t:           0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Lato', system-ui, sans-serif;
  color: var(--text);
  background: var(--cream);
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { max-width: 100%; height: auto; display: block; }
input, select, textarea, button { font-family: inherit; }

/* ── Typography ───────────────────────────────────────────── */
h1 { font-family: 'Fraunces', Georgia, serif; font-size: 1.9rem; font-weight: 700; line-height: 1.2; }
h2 { font-family: 'Fraunces', Georgia, serif; font-size: 1.4rem; font-weight: 600; line-height: 1.3; }
h3 { font-family: 'Fraunces', Georgia, serif; font-size: 1.1rem; font-weight: 600; }
h4 { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
p { line-height: 1.7; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--green);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--t);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 199;
}
.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--white);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
}
.sidebar-logo em {
  font-style: italic;
  font-family: 'Fraunces', serif;
  color: var(--gold-light);
  font-size: 0.8rem;
  font-weight: 400;
}
.sidebar-logo-icon { font-size: 1.4rem; }
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  font-weight: 400;
  transition: var(--t);
  position: relative;
}
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.sidebar-link.active {
  background: rgba(255,255,255,0.12);
  color: var(--white);
  font-weight: 600;
}
.sidebar-link.active .sidebar-icon { opacity: 1; }
.sidebar-icon { font-size: 1rem; flex-shrink: 0; opacity: 0.7; }
.sidebar-badge {
  margin-left: auto;
  background: var(--gold);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 100px;
}
.sidebar-badge-blue { background: var(--blue); }
.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-customer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: var(--white);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-name { font-size: 0.85rem; color: var(--white); font-weight: 600; }
.sidebar-email { font-size: 0.72rem; color: rgba(255,255,255,0.5); }
.sidebar-logout {
  margin-top: auto;
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
  margin-top: auto;
  display: block;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
  padding: 6px 0;
  transition: color 0.2s;
}
.sidebar-logout:hover { color: rgba(255,255,255,0.8); }

/* ── Main layout ──────────────────────────────────────────── */
.portal-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.portal-topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.topbar-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.topbar-toggle span {
  display: block;
  width: 20px; height: 2px;
  background: var(--text);
  border-radius: 2px;
}
.topbar-title {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.topbar-right { margin-left: auto; }
.topbar-phone {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--green);
  background: var(--green-pale);
  padding: 6px 14px;
  border-radius: 100px;
}
.topbar-phone:hover { background: var(--green-pale2); }
.portal-content {
  flex: 1;
  padding: 32px;
  max-width: 1100px;
  width: 100%;
}

/* ── Cards & sections ─────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { margin: 0; }

/* ── KPI summary cards ────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--t);
}
.kpi-card:hover { box-shadow: var(--shadow-md); }
.kpi-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.kpi-value {
  font-family: 'Fraunces', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}
.kpi-sub { font-size: 0.78rem; color: var(--text-muted); }
.kpi-card.accent { border-left: 3px solid var(--green); }
.kpi-card.warning { border-left: 3px solid var(--gold); }
.kpi-card.danger  { border-left: 3px solid var(--red); }

/* ── Upcoming service widget ──────────────────────────────── */
.upcoming-card {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-mid) 100%);
  border-radius: var(--radius-lg);
  padding: 28px;
  color: var(--white);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.upcoming-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
}
.upcoming-card::after {
  content: '';
  position: absolute;
  bottom: -60px; right: 60px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
}
.upcoming-label { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255,255,255,0.6); font-weight: 700; margin-bottom: 6px; }
.upcoming-service { font-family: 'Fraunces', serif; font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.upcoming-date { font-size: 0.95rem; color: rgba(255,255,255,0.8); margin-bottom: 16px; }
.upcoming-status { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.15); padding: 5px 12px; border-radius: 100px; font-size: 0.78rem; font-weight: 600; }
.upcoming-status.green { background: rgba(255,255,255,0.2); }
.upcoming-none { color: rgba(255,255,255,0.7); font-size: 0.95rem; margin-bottom: 12px; }

/* ── Quick actions ────────────────────────────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.quick-btn {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 14px;
  text-align: center;
  cursor: pointer;
  transition: var(--t);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-mid);
}
.quick-btn:hover { border-color: var(--green); background: var(--green-pale); color: var(--green); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.quick-btn .icon { font-size: 1.5rem; }

/* ── Table ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--cream);
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
tbody tr:hover { background: var(--cream); }
tbody tr:last-child { border-bottom: none; }
tbody td {
  padding: 14px 16px;
  font-size: 0.9rem;
  color: var(--text);
  vertical-align: middle;
}
.td-muted { color: var(--text-muted); font-size: 0.82rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--t);
  white-space: nowrap;
  font-family: inherit;
}
.btn-green  { background: var(--green); color: var(--white); }
.btn-green:hover { background: var(--green-mid); }
.btn-gold   { background: var(--gold); color: var(--white); }
.btn-gold:hover { background: var(--gold-light); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-mid); }
.btn-outline:hover { border-color: var(--green); color: var(--green); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-danger { background: var(--red); color: var(--white); }

/* ── Forms ────────────────────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-row.single { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
label { font-size: 0.8rem; font-weight: 700; color: var(--text); }
.form-input {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--green); }
select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 100px; }

/* ── Alert ────────────────────────────────────────────────── */
.alert { padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 0.9rem; font-weight: 500; }
.alert-success { background: #e8f5e9; color: #2e7d32; border-left: 4px solid #2e7d32; }
.alert-error   { background: var(--red-pale); color: var(--red); border-left: 4px solid var(--red); }
.alert-info    { background: var(--blue-pale); color: var(--blue); border-left: 4px solid var(--blue); }
.alert-warning { background: var(--gold-pale); color: #7a5c10; border-left: 4px solid var(--gold); }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-family: 'Fraunces', serif; color: var(--text-mid); margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; }

/* ── Photo grid ───────────────────────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.photo-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--cream-dark);
  cursor: pointer;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  position: relative;
}
.photo-thumb:hover { opacity: 0.85; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-type-badge {
  position: absolute;
  top: 6px; left: 6px;
  background: rgba(0,0,0,0.6);
  color: var(--white);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 100px;
}

/* ── Message thread ───────────────────────────────────────── */
.thread-list { display: flex; flex-direction: column; gap: 0; }
.thread-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}
.thread-item:hover { background: var(--cream); }
.thread-item.unread { background: var(--green-pale); }
.thread-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--green);
  color: var(--white);
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.thread-info { flex: 1; min-width: 0; }
.thread-subject { font-weight: 600; font-size: 0.9rem; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-preview { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-meta { text-align: right; flex-shrink: 0; }
.thread-date { font-size: 0.75rem; color: var(--text-muted); }
.thread-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin: 4px auto 0; }

/* Chat bubbles */
.chat-window { display: flex; flex-direction: column; gap: 16px; padding: 20px; max-height: 450px; overflow-y: auto; }
.bubble { max-width: 70%; }
.bubble.mine { align-self: flex-end; }
.bubble.theirs { align-self: flex-start; }
.bubble-text {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.6;
}
.bubble.mine .bubble-text { background: var(--green); color: var(--white); border-bottom-right-radius: 4px; }
.bubble.theirs .bubble-text { background: var(--cream-dark); color: var(--text); border-bottom-left-radius: 4px; }
.bubble-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.bubble.mine .bubble-meta { text-align: right; }

/* ── Lightbox ─────────────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox-img { max-width: 90vw; max-height: 85vh; object-fit: contain; border-radius: 4px; }
.lightbox-close {
  position: absolute;
  top: 20px; right: 24px;
  color: var(--white);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  background: none;
  border: none;
}

/* ── Login page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  padding: 24px;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}
.login-top {
  background: var(--green);
  padding: 36px 36px 28px;
  text-align: center;
}
.login-logo { font-size: 2.5rem; margin-bottom: 12px; }
.login-title { font-family: 'Fraunces', serif; font-size: 1.5rem; font-weight: 700; color: var(--white); margin-bottom: 4px; }
.login-sub { font-size: 0.85rem; color: rgba(255,255,255,0.65); }
.login-body { padding: 32px 36px; }

/* ── Referral ─────────────────────────────────────────────── */
.referral-link-box {
  background: var(--green-pale);
  border: 2px dashed var(--green-light);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}
.referral-url {
  flex: 1;
  font-family: monospace;
  font-size: 0.88rem;
  color: var(--green);
  word-break: break-all;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open { display: block; }
  .portal-main { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .portal-content { padding: 20px 16px; }
  .portal-topbar { padding: 0 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .quick-actions { grid-template-columns: 1fr 1fr; }
}
