﻿/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */

textarea.auto-grow {
    field-sizing: content;
}

/* ---------------------------------------------------------------------------
   App shell — shadcn-style dashboard layout: a full-height sidebar on the left,
   a sticky top bar across the main area, and the scrollable main content below.
   --------------------------------------------------------------------------- */
body {
    background-color: var(--background);
}

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Full-width bar across the very top; the sidebar + content sit below it. */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    height: 3.6rem;
    padding-right: 1rem;
    background-color: var(--background);
    border-bottom: 1px solid var(--border);
}

.app-brand {
    display: flex;
    align-items: center;
    flex: 0 0 250px;            /* aligns the brand above the sidebar column */
    height: 100%;
    padding: 0 .75rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--foreground);
    text-decoration: none;
}

.app-body {
    display: flex;
    align-items: stretch;
    flex: 1 1 auto;
}

.app-sidebar {
    flex: 0 0 250px;
    width: 250px;
    align-self: flex-start;
    position: sticky;
    top: 3.6rem;                       /* below the top bar */
    height: calc(100vh - 3.6rem);
    overflow-y: auto;
    padding: .75rem;
    background-color: var(--sidebar);
    border-right: 1px solid var(--border);
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-content {
    flex: 1 1 auto;
    padding: 1.5rem;
}

.app-footer {
    padding: .75rem 1.5rem;
    border-top: 1px solid var(--border);
    font-size: .875rem;
}

/* The sidebar toggle only exists on narrow screens (sidebar-toggle.js). */
.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    margin-left: .5rem;
    padding: 0;
    color: var(--foreground);
    background: transparent;
    border: 0;
    border-radius: .375rem;
}

/* On narrow screens the sidebar is hidden behind the topbar toggle and opens as
   a scrollable panel below the topbar (z-index under the topbar's 1030). */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: inline-flex;
    }

    .app-brand {
        flex-basis: auto;
    }

    /* The sidebar lists these links; the topbar keeps only the login controls. */
    .top-links {
        display: none;
    }

    .app-sidebar {
        display: none;
        position: fixed;
        top: 3.6rem;
        bottom: 0;
        left: 0;
        z-index: 1020;
        max-width: 100%;
        height: auto;
        overflow-y: auto;
    }

    .app-sidebar.open {
        display: block;
    }
}

/* Bootstrap cards ship with no margin, so stacked cards touch. Give every card
   uniform bottom spacing app-wide rather than sprinkling mb-3 per view. */
.card {
    margin-bottom: 1rem;
}

/* Any table row that links to a detail page (handled by clickable-row.js). */
tr[data-href] {
    cursor: pointer;
}

/* Vertical timeline for a person's life events — one ring-dot per event on a line. */
.timeline {
    position: relative;
}

.timeline-item {
    position: relative;
    padding: 0 0 1.25rem 1.75rem;
}

    /* connector line — each item draws its own segment so first/last trim cleanly */
    .timeline-item::after {
        content: "";
        position: absolute;
        left: calc(.4rem - 1px);
        top: 0;
        bottom: 0;
        width: 2px;
        background: var(--border);
    }

    .timeline-item:first-child::after { top: .75rem; }
    .timeline-item:last-child::after { bottom: auto; height: .75rem; }
    .timeline-item:only-child::after { display: none; }

    /* the dot */
    .timeline-item::before {
        content: "";
        position: absolute;
        left: 0;
        top: .35rem;
        width: .8rem;
        height: .8rem;
        border-radius: 50%;
        background: var(--background);
        border: 2px solid var(--primary);
        z-index: 1;
    }

.homepage-content table {
    margin: 0 auto;
}


/*--- Link picker (search-or-create dropdown) — modern type-ahead ---*/
.SearchDropdown { position: relative; }
.SearchDropdown .SearchValue { border-radius: 8px; }

.SearchDropdown .dropdown-menu {
    width: 100%;
    border: 1px solid #e3e7ec;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(20, 30, 50, .12);
    padding: .3rem;
    margin-top: .25rem;
}

.SearchDropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: .55rem;
    border-radius: 7px;
    padding: .5rem .6rem;
    white-space: normal;
}

    .SearchDropdown a.dropdown-item { cursor: pointer; }
    .SearchDropdown a.dropdown-item:hover { background: #f2f6ff; }
    .SearchDropdown .dropdown-item.linked { color: #8a929c; }
    .SearchDropdown .dropdown-item.create { color: #1f6feb; font-style: italic; }

/* Type pill — shared by the dropdown results and the linked-row lists. */
.link-badge {
    font-size: .72rem;
    font-weight: 600;
    padding: .15rem .5rem;
    border-radius: 999px;
    background: #eef1f5;
    color: #55606c;
    white-space: nowrap;
}

    .link-badge.type-Person { background: #e8f0fe; color: #1a56db; }
    .link-badge.type-Document { background: #e9f7ef; color: #1e7e44; }
    .link-badge.type-Ticket { background: #fdecea; color: #b42318; }
    .link-badge.type-Bundle { background: #fef3e2; color: #b54708; }
    .link-badge.type-Event { background: #eef2ff; color: #4f46e5; }

/* linked-items list rows (shared link lists) */
.link-list .list-group-item a { text-decoration: none; }

/*--- Sortable table headers (<sort-col>) ---*/
.sort-col-link {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

    .sort-col-link .fa-sort {
        opacity: .3;           /* faded ⇅ hint on not-yet-sorted columns */
        font-size: .85em;
    }

    .sort-col-link .active {
        color: var(--bs-primary);
    }

    .sort-col-link:hover {
        color: var(--bs-primary);
    }

        .sort-col-link:hover .fa-sort {
            opacity: .7;
        }


/* ===========================================================================
   Color theme — neutral palette adopted from the design system supplied by the
   user (shadcn/ui "neutral", light mode). Bootstrap is a CSS-variable theme, so
   we point its --bs-* variables at this palette and add a handful of component
   overrides for the parts Bootstrap ships as compiled colors (button variants,
   active states, focus rings, the accordion chevron). OKLCH values are translated
   to their neutral-gray hex equivalents (e.g. oklch(0.205 0 0) → #171717).
   =========================================================================== */
:root {
    --radius: 0.625rem;

    --background: #ffffff;
    --foreground: #0a0a0a;
    --card: #ffffff;
    --card-foreground: #0a0a0a;
    --primary: #171717;          /* near-black — replaces Bootstrap's blue */
    --primary-foreground: #fafafa;
    --secondary: #f5f5f5;        /* light-gray surface */
    --secondary-foreground: #171717;
    --muted: #f5f5f5;
    --muted-foreground: #737373;
    --accent: #f5f5f5;
    --accent-foreground: #171717;
    --destructive: #dc2626;
    --border: #e5e5e5;
    --input: #e5e5e5;
    --ring: #a1a1a1;
    --sidebar: #fafafa;
    --sidebar-foreground: #0a0a0a;

    /* --- Map Bootstrap's global theme onto the palette --- */
    --bs-body-bg: var(--background);
    --bs-body-color: var(--foreground);
    --bs-emphasis-color: var(--foreground);
    --bs-secondary-bg: var(--secondary);
    --bs-tertiary-bg: var(--muted);
    --bs-secondary-color: var(--muted-foreground);
    --bs-tertiary-color: var(--muted-foreground);

    --bs-border-color: var(--border);
    --bs-border-radius: var(--radius);
    --bs-border-radius-sm: calc(var(--radius) - 4px);
    --bs-border-radius-lg: calc(var(--radius) + 2px);
    --bs-border-radius-xl: calc(var(--radius) + 4px);

    --bs-primary: var(--primary);
    --bs-primary-rgb: 23, 23, 23;

    --bs-link-color: var(--primary);
    --bs-link-color-rgb: 23, 23, 23;
    --bs-link-hover-color: #000000;
    --bs-link-hover-color-rgb: 0, 0, 0;
}

/* Primary action — solid near-black */
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-color: var(--primary-foreground);
    --bs-btn-hover-bg: #262626;
    --bs-btn-hover-border-color: #262626;
    --bs-btn-hover-color: var(--primary-foreground);
    --bs-btn-active-bg: #000000;
    --bs-btn-active-border-color: #000000;
    --bs-btn-active-color: var(--primary-foreground);
    --bs-btn-disabled-bg: var(--primary);
    --bs-btn-disabled-border-color: var(--primary);
    --bs-btn-disabled-color: var(--primary-foreground);
}

/* Secondary / light / outline-secondary — soft gray surfaces with a subtle border */
.btn-secondary,
.btn-light {
    --bs-btn-bg: var(--secondary);
    --bs-btn-border-color: var(--border);
    --bs-btn-color: var(--secondary-foreground);
    --bs-btn-hover-bg: #ececec;
    --bs-btn-hover-border-color: var(--border);
    --bs-btn-hover-color: var(--secondary-foreground);
    --bs-btn-active-bg: #e5e5e5;
    --bs-btn-active-border-color: var(--border);
    --bs-btn-active-color: var(--secondary-foreground);
}

.btn-outline-secondary {
    --bs-btn-color: var(--foreground);
    --bs-btn-border-color: var(--border);
    --bs-btn-hover-bg: var(--secondary);
    --bs-btn-hover-border-color: var(--border);
    --bs-btn-hover-color: var(--foreground);
    --bs-btn-active-bg: var(--secondary);
    --bs-btn-active-border-color: var(--border);
    --bs-btn-active-color: var(--foreground);
}

/* Destructive */
.btn-danger {
    --bs-btn-bg: var(--destructive);
    --bs-btn-border-color: var(--destructive);
    --bs-btn-hover-bg: #b91c1c;
    --bs-btn-hover-border-color: #b91c1c;
    --bs-btn-active-bg: #991b1b;
    --bs-btn-active-border-color: #991b1b;
}

/* Accordion (side menu): neutralise the blue active tint + chevron */
.accordion {
    --bs-accordion-active-bg: var(--secondary);
    --bs-accordion-active-color: var(--foreground);
    --bs-accordion-border-color: var(--border);
    --bs-accordion-btn-focus-box-shadow: 0 0 0 .2rem rgba(161, 161, 161, .35);
    --bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%230a0a0a'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
    --bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%230a0a0a'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

/* Neutral focus ring instead of Bootstrap blue */
.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.btn:focus-visible {
    border-color: var(--ring);
    box-shadow: 0 0 0 .2rem rgba(161, 161, 161, .35);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* Paginator — neutral palette (active page = solid primary, hover = accent). */
.pagination {
    --bs-pagination-color: var(--foreground);
    --bs-pagination-bg: var(--background);
    --bs-pagination-border-color: var(--border);
    --bs-pagination-hover-color: var(--foreground);
    --bs-pagination-hover-bg: var(--accent);
    --bs-pagination-hover-border-color: var(--border);
    --bs-pagination-focus-color: var(--foreground);
    --bs-pagination-focus-bg: var(--accent);
    --bs-pagination-focus-box-shadow: 0 0 0 .2rem rgba(161, 161, 161, .35);
    --bs-pagination-active-color: var(--primary-foreground);
    --bs-pagination-active-bg: var(--primary);
    --bs-pagination-active-border-color: var(--primary);
}

/* --- Top-bar user menu: avatar + name/email trigger with a dropdown --- */
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .25rem .5rem;
    border: 0;
    border-radius: .5rem;
    background: transparent;
    color: var(--foreground);
}

    .user-menu-btn:hover,
    .user-menu-btn:focus-visible {
        background-color: var(--accent);
        box-shadow: none;
    }

    .user-menu-btn.dropdown-toggle::after {
        display: none;   /* use our own chevron instead of Bootstrap's caret */
    }

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 2rem;
    width: 2rem;
    height: 2rem;
    border-radius: .5rem;          /* rounded-square avatar, shadcn style */
    background-color: var(--primary);
    color: var(--primary-foreground);
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    text-align: left;
}

.user-name {
    font-weight: 600;
    font-size: .85rem;
}

.user-email {
    font-size: .75rem;
    color: var(--muted-foreground);
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    white-space: nowrap;
}

/* Person tiles view: clamp every profile picture to a uniform tile-top so cards
   line up regardless of the source image's aspect ratio (issue #219). Crop to
   fill, anchored at the top so faces stay visible. */
.person-card-img {
    width: 100%;
    height: 240px;
    object-fit: cover;
    object-position: top center;
}

/* Document gallery (Views/Document/_Gallery.cshtml): a parent's documents and pictures
   as cards, filtered in the browser by features/document-gallery.js. */
.doc-gallery-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .9rem; }
.doc-gallery-search { max-width: 16rem; }
.doc-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .75rem; }
.doc-card { position: relative; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; background: #fff; overflow: hidden; display: flex; flex-direction: column; }
.doc-card[hidden] { display: none; }
.doc-card-thumb { display: grid; place-items: center; height: 7.5rem; background: #f8fafc; color: #94a3b8; font-size: 2.2rem; }
.doc-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-card-body { padding: .45rem .6rem .55rem; min-width: 0; }
.doc-card-name { display: block; font-weight: 500; font-size: .85rem; color: inherit; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card-meta { font-size: .75rem; color: #6b7280; }
.doc-card-unlink { position: absolute; top: .35rem; right: .45rem; background: rgba(255,255,255,.9); border-radius: 6px; padding: 0 .25rem; }
.doc-gallery-link { margin-top: 1rem; max-width: 32rem; }

/* Derived biography field (Views/Shared/_BiographyField.cshtml): a value with its
   sources in a tooltip, and unobtrusive markers for uncertainty, conflict and missing. */
.bio-value { line-height: 1.45; }
.bio-v { cursor: default; }
.bio-mark-uncertain { color: #d97706; font-size: .8em; margin-left: .3rem; }
.bio-mark-check { color: #dc2626; font-size: .8em; margin-left: .3rem; }
.bio-flag { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.bio-flag-conflict { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.bio-details { margin-top: .3rem; font-size: .85rem; }
.bio-details summary { color: #6b7280; cursor: pointer; font-size: .8rem; }
.bio-details .bio-value { margin-top: .25rem; padding-left: .6rem; border-left: 2px solid #fecaca; }
.bio-from { display: block; font-size: .75rem; color: #6b7280; }
.bio-why { display: block; font-size: .78rem; color: #6b7280; margin-top: .2rem; }
.bio-missing { color: #9ca3af; font-style: italic; cursor: default; }

/* Person ID indicator (Views/Shared/_PersonId.cshtml): a subdued icon before the bare number. */
.person-id-icon { color: #9ca3af; margin-right: .3rem; }
.person-id-number { color: #6b7280; font-size: .85em; }
.person-values { margin-left: .25rem; }
