/* =============================================================================
   family-tree-houses.css  v6.0.0
   House system + integrated chat panel
   ============================================================================= */

/* --- Card / Grid --- */
.gp-fh-card-header { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.gp-fh-card-body { padding:20px; }
.gp-fh-subtitle { color:#64748b; font-size:14px; }
.gp-fh-houses-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(250px, 1fr)); gap:16px; }

/* --- House Cards --- */
.gp-fh-house-card { background:#fff; border:1px solid #e2e8f0; border-radius:10px; overflow:hidden; position:relative; transition:transform .15s, box-shadow .15s; }
.gp-fh-house-card:hover { transform:translateY(-2px); box-shadow:0 8px 24px rgba(0,0,0,.06); }
.gp-fh-house-inner { padding:20px; }
.gp-fh-house-name { margin:0 0 6px; font-size:17px; font-weight:600; color:#0f172a; }
.gp-fh-member-count { margin:0 0 10px; font-size:13px; color:#64748b; display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.gp-fh-house-desc { margin:0 0 14px; font-size:13px; color:#475569;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }

/* Card buttons row */
.gp-fh-card-buttons { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }

.gp-fh-view-btn { background:#f1f5f9; color:#0f172a; border:0; border-radius:6px; padding:8px 14px;
  font-size:13px; font-weight:500; cursor:pointer; transition:background .15s; }
.gp-fh-view-btn:hover { background:#e2e8f0; }

/* Chat button on cards */
.gp-fh-chat-btn {
  background:#eef2ff; color:#4338ca; border:0; border-radius:6px; padding:8px 14px;
  font-size:13px; font-weight:500; cursor:pointer; transition:all .15s;
  display:inline-flex; align-items:center; gap:5px;
}
.gp-fh-chat-btn:hover { background:#e0e7ff; color:#3730a3; }

/* System house tints */
.gp-fh-mother_house         { border-left:4px solid #ec4899; }
.gp-fh-grandmother_house    { border-left:4px solid #8b5cf6; }
.gp-fh-grand_maternal_house { border-left:4px solid #06b6d4; }

/* Custom house themes */
.gp-fh-custom-default { border-left:4px solid #64748b; }
.gp-fh-custom-purple  { border-left:4px solid #8b5cf6; background:linear-gradient(180deg,#faf7ff 0%,#fff 60%); }
.gp-fh-custom-teal    { border-left:4px solid #14b8a6; background:linear-gradient(180deg,#f0fdfa 0%,#fff 60%); }
.gp-fh-custom-amber   { border-left:4px solid #f59e0b; background:linear-gradient(180deg,#fffbeb 0%,#fff 60%); }
.gp-fh-custom-rose    { border-left:4px solid #f43f5e; background:linear-gradient(180deg,#fff1f2 0%,#fff 60%); }

.gp-uh-card-actions { position:absolute; top:12px; right:12px; display:flex; gap:4px; opacity:0; transition:opacity .15s; }
.gp-fh-house-card:hover .gp-uh-card-actions { opacity:1; }
.gp-uh-icon-btn { width:28px; height:28px; border-radius:6px; border:0; background:rgba(255,255,255,.9);
  color:#475569; display:inline-flex; align-items:center; justify-content:center; cursor:pointer; font-size:12px; }
.gp-uh-icon-btn:hover { background:#fff; color:#0f172a; box-shadow:0 1px 4px rgba(0,0,0,.08); }
.gp-uh-pending-badge { background:#fef3c7; color:#92400e; padding:2px 8px; border-radius:10px; font-size:11px; font-weight:600; }

/* --- Modals --- */
.gp-fh-modal-overlay { position:fixed; inset:0; z-index:9999; background:rgba(15,23,42,.55);
  backdrop-filter:blur(2px); display:flex; align-items:center; justify-content:center; padding:20px; }
.gp-fh-modal { background:#fff; border-radius:12px; width:100%; max-width:640px; max-height:90vh;
  display:flex; flex-direction:column; overflow:hidden; box-shadow:0 20px 48px rgba(0,0,0,.18); }
.gp-fh-modal-header { display:flex; align-items:center; justify-content:space-between;
  padding:12px 20px; border-bottom:1px solid #e2e8f0; gap:12px; flex-wrap:wrap; }
.gp-fh-modal-title { margin:0; font-size:16px; font-weight:600; color:#0f172a;
  display:flex; align-items:center; gap:6px; }
.gp-fh-modal-close { width:32px; height:32px; border:0; border-radius:8px; background:#f1f5f9; color:#475569; cursor:pointer; flex-shrink:0; }
.gp-fh-modal-close:hover { background:#e2e8f0; color:#0f172a; }
.gp-fh-modal-body { padding:20px; overflow-y:auto; flex:1; }
.gp-fh-modal-footer { padding:14px 20px; border-top:1px solid #e2e8f0; background:#f8fafc;
  display:flex; justify-content:flex-end; gap:8px; }

/* --- Modal Tabs (Members / Chat) --- */
.gp-fh-modal-tabs {
  display:flex; gap:2px; background:#f1f5f9; border-radius:8px; padding:2px;
}
.gp-fh-mtab {
  background:transparent; border:0; padding:7px 14px; font-size:13px; font-weight:500;
  color:#64748b; cursor:pointer; border-radius:6px; transition:all .15s;
  display:inline-flex; align-items:center; gap:5px; position:relative;
}
.gp-fh-mtab:hover { color:#0f172a; }
.gp-fh-mtab.active { background:#fff; color:#0f172a; box-shadow:0 1px 3px rgba(0,0,0,.08); }

.gp-fh-tab-panel { /* controlled by JS show/hide */ }

/* Unread dot on chat tab */
.gp-chat-unread-dot {
  width:8px; height:8px; border-radius:50%; background:#ef4444;
  display:inline-block; position:absolute; top:6px; right:6px;
}

/* --- Buttons --- */
.gp-btn { background:#0f172a; color:#fff; border:0; border-radius:8px; padding:8px 14px;
  font-size:13px; font-weight:500; cursor:pointer; display:inline-flex; align-items:center; gap:6px; transition:background .15s; }
.gp-btn:hover { background:#1e293b; }
.gp-btn-secondary { background:#f1f5f9; color:#0f172a; }
.gp-btn-secondary:hover { background:#e2e8f0; }
.gp-btn-sm { padding:4px 10px; font-size:12px; }
.gp-btn-success { background:#16a34a !important; color:#fff !important; }

/* --- Form rows --- */
.gp-uh-form-row { margin-bottom:14px; }
.gp-uh-form-row label { display:block; font-size:12px; font-weight:600; color:#475569;
  margin-bottom:4px; text-transform:uppercase; letter-spacing:.04em; }
.gp-uh-form-row input, .gp-uh-form-row textarea, .gp-uh-form-row select {
  width:100%; padding:9px 12px; border:1px solid #cbd5e1; border-radius:6px;
  font-size:14px; font-family:inherit; background:#fff; }
.gp-uh-form-row input:focus, .gp-uh-form-row textarea:focus, .gp-uh-form-row select:focus {
  outline:0; border-color:#6366f1; box-shadow:0 0 0 3px rgba(99,102,241,.15); }

/* --- Tabs (member picker) --- */
.gp-uh-tabs { display:flex; border-bottom:1px solid #e2e8f0; margin:-4px 0 14px; }
.gp-uh-tab { background:transparent; border:0; padding:10px 16px; font-size:13px; font-weight:500;
  color:#64748b; cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-1px; }
.gp-uh-tab:hover { color:#0f172a; }
.gp-uh-tab.active { color:#4f46e5; border-bottom-color:#4f46e5; }
.gp-uh-tab-content { display:none; }
.gp-uh-tab-content.active { display:block; }

#gp-uh-search { width:100%; padding:10px 12px; border:1px solid #cbd5e1; border-radius:6px;
  font-size:14px; margin-bottom:10px; }
.gp-uh-search-results { max-height:360px; overflow-y:auto; }
.gp-uh-pick-row { display:grid; grid-template-columns:1fr auto; align-items:center;
  gap:12px; padding:10px 12px; border:1px solid #f1f5f9; border-radius:8px;
  margin-bottom:6px; cursor:pointer; font-size:14px; transition:background .15s, border-color .15s; }
.gp-uh-pick-row:hover { background:#f8fafc; border-color:#e2e8f0; }
.gp-uh-pick-row:has(input[type="checkbox"]) { grid-template-columns:auto 1fr auto; }
.gp-uh-pick-selected { background:#eff6ff !important; border-color:#93c5fd !important; }
.gp-uh-pick-name { color:#0f172a; font-weight:500; }
.gp-uh-pick-hint { color:#64748b; font-size:12px; text-align:right; }

/* --- Member list --- */
.gp-fh-member-list { display:flex; flex-direction:column; gap:8px; }
.gp-fh-member-row { display:flex; align-items:center; gap:12px; padding:10px 12px;
  border:1px solid #f1f5f9; border-radius:8px; transition:background .15s; cursor:pointer; }
.gp-fh-member-row:hover { background:#f8fafc; border-color:#e2e8f0; }
.gp-fh-member-row.gp-uh-pending { opacity:.75; background:#fffbeb; border-color:#fde68a; }
.gp-fh-member-avatar { width:36px; height:36px; border-radius:50%; background:#e0e7ff; color:#3730a3;
  display:flex; align-items:center; justify-content:center; font-size:14px; font-weight:600; flex-shrink:0; }
.gp-fh-member-info { flex:1; min-width:0; }
.gp-fh-member-name { font-size:14px; color:#0f172a; display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
.gp-fh-member-meta { font-size:12px; color:#64748b; margin-top:2px; }

/* --- Badges --- */
.gp-fh-badge { display:inline-block; font-size:11px; padding:2px 8px; border-radius:10px;
  background:#f1f5f9; color:#475569; font-weight:500; }
.gp-fh-badge-pending  { background:#fef3c7; color:#92400e; }
.gp-fh-badge-contact  { background:#ede9fe; color:#5b21b6; }
.gp-fh-badge-source   { background:#e0f2fe; color:#075985; }
.gp-fh-badge-self, .gp-fh-badge-mother  { background:#fce7f3; color:#9d174d; }
.gp-fh-badge-father   { background:#dbeafe; color:#1e40af; }
.gp-fh-badge-spouse   { background:#fef3c7; color:#92400e; }
.gp-fh-badge-son, .gp-fh-badge-daughter, .gp-fh-badge-child { background:#d1fae5; color:#065f46; }
.gp-fh-badge-creator  { background:#fce7f3; color:#9d174d; }
.gp-fh-badge-admin    { background:#e0f2fe; color:#075985; }
.gp-fh-badge-system   { background:#ede9fe; color:#5b21b6; }

.gp-uh-remove-btn { width:28px; height:28px; border-radius:6px; border:0;
  background:transparent; color:#94a3b8; cursor:pointer; }
.gp-uh-remove-btn:hover { background:#fee2e2; color:#b91c1c; }

/* --- Profile modal --- */
.gp-uh-profile-head { display:flex; gap:14px; align-items:flex-start;
  padding-bottom:14px; border-bottom:1px solid #e2e8f0; margin-bottom:14px; }
.gp-uh-profile-info { flex:1; min-width:0; }
.gp-uh-profile-name { margin:0 0 6px; font-size:17px; color:#0f172a; }
.gp-uh-profile-badges { display:flex; flex-wrap:wrap; gap:4px; margin-bottom:6px; }
.gp-uh-profile-meta { margin:0; font-size:13px; color:#64748b; }
.gp-uh-profile-table { width:100%; border-collapse:collapse; margin-bottom:14px; }
.gp-uh-profile-table tr td { padding:8px 0; font-size:13px; border-bottom:1px solid #f1f5f9; }
.gp-uh-profile-table tr td:first-child { color:#64748b; width:90px;
  text-transform:uppercase; font-size:11px; letter-spacing:.04em; }
.gp-uh-profile-table tr td:last-child { color:#0f172a; }
.gp-uh-profile-notes, .gp-uh-profile-houses { margin-top:14px; padding-top:14px; border-top:1px solid #f1f5f9; }
.gp-uh-profile-notes strong, .gp-uh-profile-houses strong { display:block; font-size:11px;
  color:#64748b; text-transform:uppercase; letter-spacing:.04em; margin-bottom:6px; }
.gp-uh-profile-notes p { margin:0; font-size:13px; color:#334155; line-height:1.5; }
.gp-uh-profile-houses > div { display:flex; flex-wrap:wrap; gap:4px; }
.gp-uh-profile-invite { margin-top:14px; padding-top:14px; border-top:1px solid #f1f5f9; }
.gp-uh-invite-hint { font-size:12px; color:#64748b; margin:0 0 8px; }

/* --- States --- */
.gp-fh-state-msg { padding:30px 20px; text-align:center; color:#64748b; font-size:14px; }
.gp-fh-state-msg i { font-size:1.5em; margin-bottom:10px; display:block; }
.gp-fh-state-msg p { margin:0; }
.gp-fh-state-error { color:#dc2626; }
.gp-fh-state-error i { color:#dc2626; }
.gp-fh-empty { padding:30px 20px; text-align:center; color:#94a3b8;
  background:#f8fafc; border-radius:8px; font-size:14px; }
.gp-fh-empty p { margin:0; }


/* =============================================================================
   CHAT PANEL (v6) — inside the modal
   ============================================================================= */

.gp-chat-panel {
  display:flex; flex-direction:column; height:460px;
  background:#f0f2f5;
}

/* Messages container */
.gp-chat-messages {
  flex:1; overflow-y:auto; padding:16px;
  display:flex; flex-direction:column; gap:4px;
  background:#e5ddd5;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80"><rect fill="%23e5ddd5" width="80" height="80"/><circle fill="%23d1c4b8" opacity=".04" cx="40" cy="40" r="24"/></svg>');
}

.gp-chat-empty {
  flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center;
  color:#94a3b8; font-size:14px; text-align:center;
}
.gp-chat-empty p { margin:4px 0 0; }

/* Message row */
.gp-chat-msg {
  display:flex; max-width:75%; gap:6px; align-items:flex-start;
  animation: gp-chat-slide-in .2s ease-out;
}
@keyframes gp-chat-slide-in {
  from { opacity:0; transform:translateY(6px); }
  to   { opacity:1; transform:translateY(0); }
}

.gp-chat-msg-other { align-self:flex-start; }
.gp-chat-msg-own   { align-self:flex-end; flex-direction:row-reverse; }

/* Avatar */
.gp-chat-msg-avatar {
  width:28px; height:28px; border-radius:50%;
  background:linear-gradient(135deg,#667eea,#764ba2);
  color:#fff; display:flex; align-items:center; justify-content:center;
  font-size:12px; font-weight:600; flex-shrink:0; margin-top:2px;
}

.gp-chat-msg-body { display:flex; flex-direction:column; min-width:0; }

.gp-chat-msg-sender {
  font-size:11px; font-weight:600; color:#4338ca; margin-bottom:2px; margin-left:6px;
}
.gp-chat-msg-own .gp-chat-msg-sender { display:none; }

/* Reply context */
.gp-chat-msg-reply {
  background:rgba(0,0,0,.06); border-left:3px solid #4338ca;
  padding:4px 8px; border-radius:4px; margin-bottom:3px; margin-left:6px;
  font-size:12px; max-width:260px; overflow:hidden;
}
.gp-chat-msg-reply strong { color:#4338ca; display:block; font-size:11px; margin-bottom:1px; }
.gp-chat-msg-reply span { color:#64748b; display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* Message row (bubble + meta) */
.gp-chat-msg-row {
  display:inline-flex; align-items:flex-start; gap:5px;
}

/* Bubble */
.gp-chat-msg-bubble {
  padding:7px 11px; border-radius:8px; font-size:14px; line-height:1.45;
  box-shadow:0 1px 2px rgba(0,0,0,.08); word-wrap:break-word; max-width:340px;
}
.gp-chat-msg-bubble p { margin:0; }

.gp-chat-msg-other .gp-chat-msg-bubble {
  background:#fff; color:#0f172a; border-bottom-left-radius:2px;
}
.gp-chat-msg-own .gp-chat-msg-bubble {
  background:#d9fdd3; color:#0f172a; border-bottom-right-radius:2px;
}

.gp-chat-edited { font-size:10px; color:#94a3b8; font-style:italic; margin-left:4px; }

/* Meta (time + reply button) */
.gp-chat-msg-meta {
  display:inline-flex; align-items:center; gap:3px;
  opacity:0; transition:opacity .15s; flex-shrink:0;
}
.gp-chat-msg:hover .gp-chat-msg-meta { opacity:1; }

.gp-chat-msg-time { font-size:10px; color:#94a3b8; white-space:nowrap; }

.gp-chat-reply-btn {
  width:20px; height:20px; border-radius:50%; border:0;
  background:rgba(0,0,0,.05); color:#94a3b8; cursor:pointer;
  display:flex; align-items:center; justify-content:center; transition:all .15s;
}
.gp-chat-reply-btn:hover { background:rgba(0,0,0,.1); color:#4338ca; transform:scale(1.1); }
.gp-chat-reply-btn i { font-size:11px; }

/* Input area */
.gp-chat-input-area {
  border-top:1px solid #e2e8f0; background:#f8fafc; padding:0;
}

.gp-chat-reply-bar {
  display:flex; align-items:center; padding:8px 14px;
  background:rgba(67,56,202,.08); border-left:3px solid #4338ca;
  gap:8px;
}
.gp-chat-reply-content { flex:1; min-width:0; }
.gp-chat-reply-name { font-size:12px; font-weight:600; color:#4338ca; display:block; }
.gp-chat-reply-text { font-size:12px; color:#64748b; display:block; white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis; max-width:300px; }
.gp-chat-reply-cancel {
  width:24px; height:24px; border-radius:50%; border:0;
  background:transparent; color:#94a3b8; cursor:pointer; font-size:14px;
  display:flex; align-items:center; justify-content:center;
}
.gp-chat-reply-cancel:hover { color:#0f172a; }

.gp-chat-input-row {
  display:flex; align-items:flex-end; gap:8px;
  padding:10px 14px;
}

.gp-chat-input {
  flex:1; border:1px solid #e2e8f0; border-radius:18px;
  padding:9px 14px; font-size:14px; font-family:inherit;
  resize:none; outline:0; max-height:100px; line-height:1.4;
  background:#fff; transition:border-color .15s;
}
.gp-chat-input:focus { border-color:#6366f1; box-shadow:0 0 0 3px rgba(99,102,241,.1); }
.gp-chat-input:disabled { opacity:.5; cursor:not-allowed; }

.gp-chat-send-btn {
  width:36px; height:36px; border-radius:50%; border:0;
  background:#4338ca; color:#fff; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition:all .15s; flex-shrink:0;
}
.gp-chat-send-btn:hover { background:#3730a3; transform:scale(1.05); }
.gp-chat-send-btn:disabled { background:#cbd5e1; cursor:not-allowed; transform:none; }
.gp-chat-send-btn i { font-size:14px; }

/* Scrollbar */
.gp-chat-messages::-webkit-scrollbar { width:5px; }
.gp-chat-messages::-webkit-scrollbar-track { background:transparent; }
.gp-chat-messages::-webkit-scrollbar-thumb { background:rgba(0,0,0,.15); border-radius:3px; }
.gp-chat-messages::-webkit-scrollbar-thumb:hover { background:rgba(0,0,0,.25); }


/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 600px) {
  .gp-fh-houses-grid { grid-template-columns:1fr; }
  .gp-fh-modal { max-height:100vh; border-radius:0; }
  .gp-fh-modal-overlay { padding:0; }
  .gp-uh-card-actions { opacity:1; }
  .gp-fh-modal-header { flex-wrap:wrap; }
  .gp-fh-modal-tabs { order:10; width:100%; margin-top:8px; }
  .gp-chat-panel { height:380px; }
  .gp-chat-msg { max-width:88%; }
  .gp-chat-msg-bubble { max-width:260px; }
}