/*
 * Reunifyr — Custom Styles
 * Extends Bootstrap 5 with the navy/gold classic palette.
 */

/* ===== Design Tokens ===== */
:root {
    --primary-color: #1a3a5c;
    --primary-light: #1e4d78;
    --primary-medium: #2d6a9f;
    --primary-pale: #3d7eb5;
    --accent-color: #ffc107;
    --accent-soft: #fff3cd;
    --secondary-color: #6c757d;
    --surface-light: #f8f9fa;
    --surface-border: #dee2e6;
    --success-color: #198754;
    --danger-color: #dc3545;
}

/* ===== General ===== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    /* Safari dynamic viewport height */
    display: flex;
    flex-direction: column;
    margin: 0;
}

body>nav,
body>.flash-container,
body>footer {
    flex-shrink: 0;
}

body>main {
    flex: 1 1 auto;
    min-height: 0;
}

/* Tree fullscreen: card fills screen, container stretches */
.card:fullscreen,
.card:-webkit-full-screen {
    display: flex;
    flex-direction: column;
    background: #fff;
}

.card:fullscreen .card-body,
.card:-webkit-full-screen .card-body {
    flex: 1 1 auto;
    min-height: 0;
}

.card:fullscreen #treeContainer,
.card:-webkit-full-screen #treeContainer {
    height: 100% !important;
}

/* Full-viewport pages (hero carousel) */
body.fullvp {
    height: 100vh;
    overflow: hidden;
}

body.fullvp>main {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

@media (max-width: 767px) {
    body.fullvp {
        height: auto;
        overflow: auto;
    }

    body.fullvp>main {
        overflow: visible;
    }
}

body.fullvp>footer {
    margin-top: 0 !important;
    padding: 0.35rem 0 !important;
}

body.fullvp>footer p {
    font-size: 0.78rem;
}

body.fullvp>main.my-4 {
    margin-top: 0.25rem !important;
    margin-bottom: 0 !important;
}

/* ===== Standardized Page Header Bar ===== */
.section-title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid var(--primary-color);
}

.section-title-bar .section-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .section-title-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .section-title-bar .section-title {
        font-size: 1.5rem;
        line-height: 1.3;
        width: 100%;
    }
}

/* ===== Bootstrap Primary → Navy Override ===== */
.bg-primary {
    background-color: var(--primary-color) !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.border-primary {
    border-color: var(--primary-color) !important;
}

.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--primary-light) !important;
    border-color: var(--primary-light) !important;
}

.btn-outline-primary {
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #fff !important;
}

.card-header-navy {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: #fff;
}

/* ===== Navbar ===== */
.navbar {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    z-index: 1030;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.navbar.sticky-top {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.025em;
}

.nav-link {
    transition: all 0.3s ease;
    font-size: 0.92rem;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    white-space: nowrap;
}

.nav-link:hover {
    transform: translateY(-1px);
    color: var(--accent-color) !important;
}

.nav-link:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    border-radius: 4px;
}

.btn:focus-visible,
.btn-close:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* ===== Dropdown Headers ===== */
.navbar-nav .dropdown-menu .dropdown-header {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    padding: 0.5rem 1rem 0.25rem;
}

/* ===== Cards ===== */
.card {
    border-radius: 10px;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.card-header {
    font-weight: 600;
    border-top-left-radius: 10px !important;
    border-top-right-radius: 10px !important;
}

/* ===== Buttons ===== */
.btn {
    border-radius: 8px;
    padding: 0.5rem 1.5rem;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* ===== Hero / Jumbotron ===== */
.jumbotron {
    border-radius: 15px;
    background: linear-gradient(135deg, #1a3a5c 0%, #2d6a9f 100%);
    color: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.jumbotron.bg-light {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%) !important;
    color: #333;
}

/* ===== Forms ===== */
.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #ced4da;
    padding: 0.6rem 1rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(26, 58, 92, 0.15);
}

label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
}

/* ===== Tables ===== */
.table {
    border-radius: 10px;
    overflow: hidden;
}

.table thead {
    font-weight: 600;
}

.table tbody tr {
    transition: background-color 0.2s ease;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

/* ===== Family Tree ===== */
.family-card {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.family-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.generation-badge {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

/* ===== Photo Gallery ===== */
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    cursor: pointer;
}

.gallery-item img {
    transition: transform 0.3s ease;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* ===== Photo Albums ===== */
.album-card {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.album-card .album-cover {
    height: 200px;
    object-fit: cover;
    width: 100%;
}

.album-card .album-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: #fff;
    padding: 1rem;
}

/* ===== Memorial Pages ===== */
.memorial-hero {
    background: linear-gradient(135deg, #2c3e50 0%, #4a6741 100%);
    color: #fff;
    padding: 3rem 0;
    text-align: center;
}

.memorial-photo {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.8);
    object-fit: cover;
    margin: 0 auto;
}

.memorial-dates {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-top: 0.5rem;
}

.memorial-bio {
    font-size: 1.05rem;
    line-height: 1.8;
}

.timeline-event {
    position: relative;
    padding-left: 2rem;
    margin-bottom: 1.5rem;
    border-left: 3px solid var(--primary-color);
}

.timeline-event::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 0.3rem;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--primary-color);
}

/* ===== Contact Directory ===== */
.contact-card {
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    padding: 1.25rem;
    transition: all 0.3s ease;
}

.contact-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* ===== Footer ===== */
footer {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.2);
}

/* ===== Alerts ===== */
.alert {
    border-radius: 10px;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ===== Breadcrumbs ===== */
.breadcrumb {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

/* ===== Badges ===== */
.badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-weight: 500;
}

/* ===== Shadows ===== */
.shadow-sm {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08) !important;
}

.shadow {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.shadow-lg {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

/* ===== Hover Effects ===== */
.hover-shadow {
    transition: all 0.3s ease;
}

.hover-shadow:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(-3px);
}

/* ===== Admin Section ===== */
.admin-section {
    background-color: #f8f9fa;
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

/* ===== Utility ===== */
.cursor-pointer {
    cursor: pointer;
}

.mt-6 {
    margin-top: 4rem !important;
}

.mb-6 {
    margin-bottom: 4rem !important;
}

.profile-image {
    border: 5px solid #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ===== Loading Spinner ===== */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ===== Family Select ===== */
.family-select {
    min-width: 250px;
}

select.family-select {
    width: 100%;
    max-width: none;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .navbar-brand {
        font-size: 1.1rem;
    }

    .jumbotron {
        padding: 2rem 1rem !important;
    }

    .jumbotron h1 {
        font-size: 2rem !important;
    }

    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }
}

@media (max-width: 991.98px) {
    .navbar-collapse {
        max-height: calc(100vh - 56px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .navbar-nav .dropdown-menu {
        max-height: none;
        overflow-y: visible;
    }

    .navbar-nav .dropdown-menu .dropdown-item {
        padding: 0.75rem 1.25rem;
        font-size: 1.05rem;
        line-height: 1.6;
    }

    .navbar-nav .dropdown-menu .dropdown-divider {
        margin: 0.35rem 0;
    }

    .navbar-nav .dropdown-menu .dropdown-header {
        font-size: 0.75rem;
        padding: 0.6rem 1.25rem 0.25rem;
        color: #adb5bd;
    }

    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        font-size: 1.05rem;
    }

    .navbar-nav .dropdown-toggle {
        padding: 0.75rem 1rem;
    }
}

/* ===== Print ===== */
@media print {

    .navbar,
    footer,
    .btn,
    .no-print {
        display: none !important;
    }

    .card {
        border: 2px solid #000;
        box-shadow: none;
        page-break-inside: avoid;
    }
}