/* ============================================================
   Hive Dash – Client Portal (front end)
   Self-contained: unlike the admin build, this can't rely on
   admin.css's :root tokens (that stylesheet only loads in
   wp-admin), so the same dark palette is redeclared here,
   scoped under #hc-portal-app / .hcp-gate so it can't leak
   into the surrounding theme.
   ============================================================ */
#hc-portal-app, .hcp-gate {
  --bg:        #0d0f1a;
  --bg-2:      #131626;
  --bg-3:      #1a1e30;
  --bg-4:      #21263a;
  --border:    #2a3050;
  --text:      #e8ecf8;
  --text-2:    #9aa3c2;
  --text-3:    #5c6585;
  --accent:    #6366f1;
  --accent-h:  #818cf8;
  --accent-2:  #4f46e5;
  --green:     #10b981;
  --red:       #ef4444;
  --blue:      #3b82f6;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --font:      'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

#hc-portal-app *, .hcp-gate * { box-sizing: border-box; font-family: var(--font); }

#hc-portal-app {
  background: var(--bg); color: var(--text); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow); max-width: 960px; margin: 0 auto;
}

.hcp-topbar {
  display: flex; align-items: center; gap: 10px; padding: 16px 24px;
  background: var(--bg-2); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.hcp-title { font-size: 18px; font-weight: 700; letter-spacing: -.3px; margin-right: auto; }
.hcp-title span { color: var(--text-2); font-weight: 500; font-size: 13px; margin-left: 8px; }

.hcp-tabs { display: flex; gap: 4px; padding: 0 24px; background: var(--bg-2); border-bottom: 1px solid var(--border); overflow-x: auto; }
.hcp-tab {
  background: none; border: none; color: var(--text-2); font-family: var(--font); font-size: 13.5px; font-weight: 600;
  padding: 12px 16px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.hcp-tab:hover { color: var(--text); }
.hcp-tab.active { color: var(--accent-h); border-bottom-color: var(--accent); }
.hcp-badge {
  display: inline-block; margin-left: 6px; background: var(--red); color: #fff; font-size: 10.5px; font-weight: 700;
  border-radius: 999px; padding: 1px 6px;
}

.hcp-body { padding: 20px 24px 40px; }
.hcp-loading, .hcp-empty { color: var(--text-2); font-size: 13.5px; padding: 32px 0; text-align: center; }

.hcp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.hcp-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.hcp-card-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.hcp-card-sub { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }

.hcp-progress { height: 6px; background: var(--bg-4); border-radius: 4px; margin: 8px 0; overflow: hidden; }
.hcp-progress-bar { height: 100%; background: var(--accent); }

.hcp-status {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
  padding: 2px 8px; border-radius: 999px; background: var(--bg-4); color: var(--text-2); margin: 4px 0;
}
.hcp-status--accepted, .hcp-status--completed, .hcp-status--active { background: rgba(16,185,129,.15); color: var(--green); }
.hcp-status--declined, .hcp-status--cancelled { background: rgba(239,68,68,.15); color: var(--red); }
.hcp-status--sent, .hcp-status--planning { background: rgba(59,130,246,.15); color: var(--blue); }
.hcp-status--draft { background: rgba(154,163,194,.15); color: var(--text-2); }

.hcp-list { display: flex; flex-direction: column; gap: 8px; }
.hcp-row {
  display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 16px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; font-size: 13.5px;
}

.hcp-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 16px; }
.hcp-modal { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; max-width: 560px; width: 92%; max-height: 84vh; overflow-y: auto; position: relative; color: var(--text); }
.hcp-modal-close { position: absolute; top: 12px; right: 16px; background: none; border: none; color: var(--text-2); font-size: 20px; cursor: pointer; }
.hcp-modal-actions { display: flex; gap: 10px; margin-top: 16px; }

.hcp-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 12px 0; }
.hcp-table th, .hcp-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.hcp-quote-total { text-align: right; font-size: 13.5px; color: var(--text-2); margin-top: 8px; }
.hcp-quote-terms { font-size: 12.5px; color: var(--text-3); margin-top: 12px; white-space: pre-wrap; }

.hcp-chat { display: flex; flex-direction: column; height: 60vh; max-height: 520px; }
.hcp-chat-thread { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.hcp-bubble { align-self: flex-start; background: var(--bg-4); border-radius: var(--radius); padding: 8px 12px; font-size: 13px; max-width: 75%; }
.hcp-bubble--mine { align-self: flex-end; background: var(--accent-2); color: #fff; }
.hcp-bubble-time { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }
.hcp-bubble--mine .hcp-bubble-time { color: rgba(255,255,255,.7); }
.hcp-chat-form { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.hcp-chat-form textarea { flex: 1; resize: none; height: 44px; background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-family: var(--font); padding: 8px 10px; }

/* crm-btn / crm-toast are shared component classes defined in admin.css only —
   the front end has no guarantee that stylesheet is loaded, so the portal
   redeclares its own copies here rather than assuming they exist. */
.crm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--bg-4); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font); font-size: 13px; font-weight: 600; padding: 8px 14px;
  border-radius: var(--radius); cursor: pointer;
}
.crm-btn:hover { border-color: var(--border-2, var(--border)); }
.crm-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.crm-btn-primary:hover { background: var(--accent-h); }
.crm-btn-sm { padding: 5px 10px; font-size: 12.5px; }

.crm-toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 10000; display: flex; flex-direction: column; gap: 8px; }
.crm-toast {
  background: var(--bg-3, #1a1e30); color: #fff; padding: 10px 16px; border-radius: 8px;
  font-family: var(--font); font-size: 13px; box-shadow: 0 4px 24px rgba(0,0,0,.4);
}
.crm-toast.error { background: #7f1d1d; }

/* ── Photos ──────────────────────────────────────────────────── */
.hcp-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.hcp-photo-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.hcp-photo-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; cursor: pointer; }
.hcp-photo-caption { padding: 8px 10px; font-size: 12px; color: var(--text-2); }
.hcp-photo-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 20px; cursor: zoom-out; }
.hcp-photo-lightbox img { max-width: 100%; max-height: 90vh; border-radius: var(--radius); }

/* ── Site Diary ──────────────────────────────────────────────── */
.hcp-diary-entry { background: var(--bg-2); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; }
.hcp-diary-date { font-size: 11.5px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 4px; }
.hcp-diary-proj { color: var(--text-2); font-weight: 500; }
.hcp-diary-text { font-size: 13.5px; white-space: pre-wrap; }

/* ── Invoices ────────────────────────────────────────────────── */
.hcp-invoice-amount { font-family: 'SF Mono', 'Consolas', monospace; font-weight: 700; }

/* ── Change Requests ─────────────────────────────────────────── */
.hcp-cr-form { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 16px; }
.hcp-cr-form label { display: block; font-size: 12px; color: var(--text-2); margin: 10px 0 4px; }
.hcp-cr-form label:first-child { margin-top: 0; }
.hcp-cr-form select, .hcp-cr-form input[type="text"], .hcp-cr-form textarea {
  width: 100%; background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--font); font-size: 13.5px; padding: 8px 10px;
}
.hcp-cr-form textarea { resize: vertical; min-height: 70px; }
.hcp-cr-note { font-size: 12.5px; color: var(--text-2); background: var(--bg-3); border-radius: var(--radius); padding: 8px 10px; margin-top: 8px; }


.hcp-gate {
  max-width: 380px; margin: 40px auto; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px; color: var(--text); text-align: center;
}
.hcp-gate-msg { font-size: 14px; color: var(--text-2); margin: 0 0 16px; }
.hcp-gate #hcp-login-form { text-align: left; }
.hcp-gate #hcp-login-form p { margin: 0 0 12px; }
.hcp-gate #hcp-login-form label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 4px; }
.hcp-gate #hcp-login-form input[type="text"],
.hcp-gate #hcp-login-form input[type="password"] {
  width: 100%; background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--font); font-size: 13.5px; padding: 8px 10px;
}
.hcp-gate #hcp-login-form .login-remember { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.hcp-gate #hcp-login-form .login-remember input { width: auto; }
.hcp-gate #hcp-login-form .login-submit input[type="submit"] {
  width: 100%; background: var(--accent); border: none; border-radius: var(--radius); color: #fff;
  font-family: var(--font); font-size: 13.5px; font-weight: 600; padding: 10px 14px; cursor: pointer;
}
.hcp-gate #hcp-login-form .login-submit input[type="submit"]:hover { background: var(--accent-h); }
.hcp-gate-lost { margin: 14px 0 0; font-size: 12.5px; }
.hcp-gate-lost a { color: var(--accent-h); text-decoration: none; }
.hcp-gate-lost a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .hcp-row { grid-template-columns: 1fr; }
}
