/* ============================================================
   Angkan — Custom overrides on top of Bootstrap 5 + FontAwesome 6
   Color palette derived from orchid.png (green orchid):
     Lip bright   #9ccc52   Emerald main  #3a8d75
     Deep teal    #1f4a40   Cream/gold    #c7a94e
     Gold deep    #8a7330   Fresh leaf    #5cae8e
   ============================================================ */

:root {
    --angkan-primary:    #3a8d75;   /* main emerald-teal green      */
    --angkan-primary-d:  #1f4a40;   /* deep shadow teal             */
    --angkan-primary-l:  #9ccc52;   /* bright orchid-lip highlight  */
    --angkan-bark:       #c7a94e;   /* warm cream-gold accent       */
    --angkan-bark-d:     #8a7330;   /* deep gold                    */
    --angkan-grass:      #5cae8e;   /* fresh leaf green             */
    --angkan-bg:         #f2f6f3;   /* very subtle green off-white  */
    --bs-primary:        #3a8d75;
    --bs-primary-rgb:    58, 141, 117;
    /* Gender hues — orchid palette (teal + gold), used site-wide */
    --male-color:        #2f8f7a;   /* teal-green                  */
    --female-color:      #c79a3e;   /* warm gold                   */
    --unknown-color:     #8a9a8e;   /* sage gray                   */
    /* Tree lineage colours — root / descendant / married-in */
    --lineage-root:         #c79a3e;   /* gold    — root ancestor      */
    --lineage-descendant:   #3a8d75;   /* emerald — blood descendant   */
    --lineage-inlaw:        #8a9a8e;   /* sage    — married-in / other */
    --lineage-root-l:       #f3e7c4;   /* pale gold    (hierarchy card)*/
    --lineage-descendant-l: #d7ebe4;   /* pale emerald (hierarchy card)*/
    --lineage-inlaw-l:      #e7ece9;   /* pale sage    (hierarchy card)*/
}

/* ── Bootstrap primary override ─────────────────────────── */
.btn-primary                { background-color: var(--angkan-primary)   !important; border-color: var(--angkan-primary)   !important; }
.btn-primary:hover,
.btn-primary:focus          { background-color: var(--angkan-primary-d) !important; border-color: var(--angkan-primary-d) !important; }
.btn-outline-primary        { color: var(--angkan-primary) !important; border-color: var(--angkan-primary) !important; }
.btn-outline-primary:hover  { background-color: var(--angkan-primary) !important; color: #fff !important; }
.text-primary               { color: var(--angkan-primary) !important; }
.bg-primary                 { background-color: var(--angkan-primary) !important; }
.border-primary             { border-color: var(--angkan-primary) !important; }
.text-success               { color: var(--angkan-primary) !important; }
.btn-success                { background-color: var(--angkan-grass) !important; border-color: var(--angkan-grass) !important; }
.btn-success:hover          { background-color: var(--angkan-primary) !important; border-color: var(--angkan-primary) !important; }

/* ── Body ────────────────────────────────────────────────── */
body { background-color: var(--angkan-bg) !important; }

/* ── Navbar ──────────────────────────────────────────────── */
.angkan-navbar {
    background: linear-gradient(135deg, var(--angkan-primary-d) 0%, var(--angkan-primary) 100%);
    border-bottom: 3px solid var(--angkan-bark);
}
.angkan-navbar .navbar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    letter-spacing: .02em;
}
/* Tree logo badge — white bg of tree-sm.png shown as a rounded icon chip */
.navbar-tree-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255,255,255,0.92);
    padding: 2px;
    flex-shrink: 0;
}
.angkan-navbar .nav-link          { transition: color .15s; }
.angkan-navbar .nav-link:hover    { color: var(--angkan-primary-l) !important; }
.angkan-navbar .nav-link.active   { color: var(--angkan-primary-l) !important; font-weight: 600; }

/* ── Footer ──────────────────────────────────────────────── */
.angkan-footer {
    background: linear-gradient(135deg, var(--angkan-primary-d) 0%, var(--angkan-primary) 100%);
    border-top: 3px solid var(--angkan-bark);
    color: rgba(255,255,255,.75);
}
.angkan-footer a { color: var(--angkan-primary-l); }
.angkan-footer a:hover { color: #fff; }
.footer-tree-logo {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255,255,255,0.9);
    padding: 2px;
    vertical-align: middle;
}

/* ── Auth / login page ───────────────────────────────────── */
.auth-wrapper {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-logo {
    width: 96px;
    height: 96px;
    border-radius: 16px;
    background: var(--angkan-bg);
    padding: 6px;
    border: 2px solid rgba(58,141,117,.2);
}
.auth-card {
    border-top: 4px solid var(--angkan-primary);
    border-radius: 12px;
}

/* ── Stat cards ──────────────────────────────────────────── */
.stat-card {
    border-top: 4px solid var(--angkan-primary);
    border-radius: 10px;
    transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(31,74,64,.15) !important; }

/* ── Person card (list / dashboard grid) ─────────────────── */
.person-card {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform .15s, box-shadow .15s;
    border-radius: 10px;
}
.person-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(31,74,64,.18);
    color: inherit;
    border-color: var(--angkan-primary-l) !important;
}

.person-avatar {
    width: 64px; height: 64px;
    border-radius: 50%;
    object-fit: cover;
}
.person-avatar-placeholder {
    width: 64px; height: 64px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; font-weight: 700; color: #fff;
    background: var(--unknown-color);
    margin: 0 auto;
}
.person-avatar-placeholder.male   { background: var(--male-color); }
.person-avatar-placeholder.female { background: var(--female-color); }

/* ── Person profile photo ────────────────────────────────── */
.profile-photo {
    width: 160px; height: 160px;
    border-radius: 12px;
    object-fit: cover;
    border: 3px solid var(--angkan-primary-l);
}
.profile-placeholder {
    width: 160px; height: 160px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 4rem; font-weight: 700; color: #fff;
    background: var(--unknown-color);
    border: 3px solid rgba(0,0,0,.1);
}
.profile-placeholder.male   { background: var(--male-color); }
.profile-placeholder.female { background: var(--female-color); }

/* ── Media thumbnail ─────────────────────────────────────── */
.media-thumb {
    width: 100px; height: 100px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    border: 2px solid rgba(58,141,117,.2);
}

/* ── Page section headings ───────────────────────────────── */
.section-heading {
    border-left: 4px solid var(--angkan-primary);
    padding-left: .75rem;
    color: var(--angkan-primary-d);
}

/* ── Cards / panels ──────────────────────────────────────── */
.card { border-radius: 10px; }

/* ── D3 Family Tree ──────────────────────────────────────── */
#tree-container {
    width: 100%;
    height: 680px;
    background: #eef4f1;  /* very light teal-green tint */
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(31,74,64,.12);
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(58,141,117,.2);
}
#tree-svg    { width: 100%; height: 100%; }
#tree-loading {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: #888;
}

.link              { stroke: #bbb; stroke-width: 1.5px; fill: none; }
.link-spouse       { stroke: var(--lineage-root); stroke-dasharray: 5,3; }
.link-parent_child { stroke: var(--angkan-primary); }

/* Force / network view — circle nodes (coloured by lineage, not gender) */
.node-circle             { stroke: #fff; stroke-width: 2; }
.lineage-root            { fill: var(--lineage-root); }
.lineage-descendant      { fill: var(--lineage-descendant); }
.lineage-inlaw           { fill: var(--lineage-inlaw); }

/* Hierarchy view — rectangle node cards (coloured by lineage, not gender) */
.node-rect                     { stroke: rgba(0,0,0,.12); stroke-width: 1;
                                 filter: drop-shadow(0 1px 2px rgba(0,0,0,.10)); }
.node-rect.lineage-root        { fill: var(--lineage-root-l); }       /* pale gold    */
.node-rect.lineage-descendant  { fill: var(--lineage-descendant-l); } /* pale emerald */
.node-rect.lineage-inlaw       { fill: var(--lineage-inlaw-l); }      /* pale sage    */

/* Search highlight / dim — shared between both views */
.node-highlight { stroke: #f59e0b !important; stroke-width: 2.5 !important; }
.node-dimmed    { opacity: .25; }

.node-label     { font-size: 11px; fill: #333; pointer-events: none; }
.node-dates     { font-size: 9px;  fill: #888; pointer-events: none; }
.node           { cursor: pointer; }

/* Marriage connector between couple cards */
.couple-line { stroke: var(--angkan-bark); stroke-width: 2; }

/* Expand / collapse indicator dot (hierarchy view) */
.expand-dot {
    fill: #fff;
    stroke: var(--angkan-primary);
    stroke-width: 2;
    cursor: pointer;
    transition: fill .2s, stroke .2s;
}
.expand-dot.is-collapsed { fill: var(--angkan-primary); }
.expand-count {
    font-size: 8px;
    font-weight: 700;
    fill: #fff;
    pointer-events: none;
}

.tree-tooltip {
    position: fixed;
    background: rgba(20,50,42,.92);
    color: #fff;
    padding: .4rem .75rem;
    border-radius: 6px;
    font-size: .82rem;
    pointer-events: auto;
    z-index: 9999;
    line-height: 1.6;
    max-width: 220px;
    border-left: 3px solid var(--angkan-primary-l);
}
.tooltip-link {
    color: var(--angkan-primary-l);
    text-decoration: none;
    font-weight: 600;
    font-size: .78rem;
}
.tooltip-link:hover { color: #fff; text-decoration: underline; }
