/* TreeFamily — giao dien tieng Viet, chi dung phong he thong, khong tai
   bat ky tai nguyen ngoai nao (khong Google Fonts). */
:root {
  --bg: #f6f1e7; --card: #fffdf7; --ink: #2b2620; --muted: #7a6f60;
  --line: #e3d9c6; --brand: #8a5a2b; --brand-dark: #6f4520;
  --accent: #b7791f; --ok: #2e7d32; --danger: #b3261e; --blue: #1565c0;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.5;
}
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; color: var(--brand-dark); margin: 0 0 8px; }
h1 { font-size: 26px; } h2 { font-size: 22px; } h3 { font-size: 17px; }
a { color: var(--blue); }
.muted { color: var(--muted); font-size: 13px; }
.note { color: var(--muted); font-size: 12.5px; }
.error { color: var(--danger); min-height: 1.2em; }
.hidden { display: none !important; }
.uppercase { text-transform: uppercase; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: #2e3d2f; color: #f6f1e7; padding: 10px 18px;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-family: Georgia, serif; font-size: 19px; font-weight: bold; }
.top-right { display: flex; gap: 10px; align-items: center; }
.badge {
  background: #c62828; color: #fff; border-radius: 999px; min-width: 20px;
  text-align: center; font-size: 12px; padding: 1px 6px; font-weight: bold;
}
.view { padding: 20px 14px 60px; }
.wrap { max-width: 1060px; margin: 0 auto; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; margin-bottom: 14px;
}
.auth-card { max-width: 460px; margin: 30px auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
label { display: block; margin: 10px 0 4px; font-weight: 600; font-size: 13.5px; }
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=date], textarea, select {
  width: 100%; padding: 9px 10px; border: 1px solid #cbbfa8; border-radius: 7px;
  font: inherit; background: #fff; margin-top: 4px;
}
textarea { resize: vertical; }
.btn {
  border: 1px solid #cbbfa8; background: #fff; color: var(--ink);
  padding: 9px 16px; border-radius: 7px; cursor: pointer; font: inherit;
}
.btn:hover { background: #f0e8d8; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 12px; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.social { flex: 1; font-weight: 600; }
.btn.google { border-color: #db4437; color: #db4437; }
.btn.facebook { border-color: #1877f2; color: #1877f2; }
.social-row { display: flex; gap: 10px; margin: 10px 0; }
.divider { text-align: center; color: var(--muted); margin: 14px 0 4px; font-size: 13px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin: 14px 0; }
.tab {
  border: none; background: none; padding: 9px 14px; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent;
}
.tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); }
.tabpane { margin-top: 6px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.family-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: flex-start; }

.tree { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.gen-col { min-width: 210px; flex: 1; }
.gen-col h4 { margin: 4px 0 10px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.member-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; margin-bottom: 10px; cursor: pointer;
}
.member-card:hover { border-color: var(--brand); }
.member-card .name { font-weight: 700; font-family: Georgia, serif; }
.member-card .sub { font-size: 12.5px; color: var(--muted); }
.member-card.me { border: 2px solid var(--brand); }
.member-card.deceased { opacity: .75; }
.tag { display: inline-block; background: #e8e0cf; border-radius: 4px; padding: 0 6px; font-size: 12px; margin-left: 4px; }
.tag.pending { background: #fff3cd; color: #856404; }
.tag.admin { background: #dbeafe; color: #1e40af; }
.tag.approved { background: #dcfce7; color: #166534; }

.post { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
.post .head { display: flex; justify-content: space-between; gap: 8px; }
.post .author { font-weight: 700; }
.post .time { color: var(--muted); font-size: 12.5px; }
.post .body { white-space: pre-wrap; margin: 8px 0; }
.post .actions { display: flex; gap: 12px; align-items: center; }
.linklike { background: none; border: none; color: var(--blue); cursor: pointer; font: inherit; padding: 0; }
.linklike.liked { color: var(--danger); font-weight: 700; }
.comment { border-top: 1px solid var(--line); padding: 7px 0 0; margin-top: 8px; font-size: 14px; }
.comment-form { display: flex; gap: 8px; margin-top: 8px; }
.comment-form input { flex: 1; }

.chat-layout { display: grid; grid-template-columns: 280px 1fr; gap: 14px; }
@media (max-width: 700px) { .chat-layout { grid-template-columns: 1fr; } }
.conv-list { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.conv {
  padding: 11px 13px; border-bottom: 1px solid var(--line); cursor: pointer;
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
}
.conv:hover, .conv.active { background: #f0e8d8; }
.conv .last { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.chat-main { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; min-height: 420px; }
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.msg { max-width: 75%; padding: 8px 12px; border-radius: 12px; background: #efe7d6; align-self: flex-start; white-space: pre-wrap; }
.msg.mine { background: #dcead7; align-self: flex-end; }
.msg .time { font-size: 11px; color: var(--muted); display: block; margin-top: 3px; }
.chat-input { display: flex; gap: 8px; margin-top: 8px; }
.chat-input input { flex: 1; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px;
}
.modal-box {
  background: var(--card); border-radius: 12px; padding: 20px; width: 100%;
  max-width: 560px; max-height: 88vh; overflow-y: auto; position: relative;
}
.modal-close { position: absolute; top: 10px; right: 12px; border: none; background: none; font-size: 18px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .full { grid-column: 1 / -1; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; font-size: 14.5px; margin: 10px 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.timeline { list-style: none; padding-left: 16px; border-left: 2px solid #c9b896; margin: 8px 0 16px 4px; }
.timeline li { margin-bottom: 10px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: #7a6a4f; }
.rowline { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid #e8e0cf; font-size: 14.5px; }
.upcoming-item { padding: 8px 0; border-bottom: 1px solid #e8e0cf; }
.upcoming-item .when { font-weight: 700; color: var(--brand-dark); }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 10px; }
.album-file img, .album-file video { width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; }
.album-file .fname { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.qr-box { text-align: center; margin: 12px 0; }
.qr-box img { width: 180px; height: 180px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.history-text { white-space: pre-wrap; }

/* In pha do: chi in cay gia pha, an het cac phan khac. */
@media print {
  body { background: #fff; }
  .topbar, #familyTabs, #treeTools, .family-head, .btn, #tab-members, #tab-feed,
  #tab-chat, #tab-admin, #tab-events, #tab-history, #tab-albums, .modal { display: none !important; }
  #view-family { display: block !important; }
  #tab-tree { display: block !important; }
  .tree { overflow: visible; flex-wrap: wrap; }
  .gen-col { min-width: 180px; }
  .member-card { break-inside: avoid; }
}
