/* ============================================================
   FamilyTree – Global Styles
   ============================================================ */

:root {
    --ft-primary: #6366f1;
    --ft-primary-dark: #4f46e5;
    --ft-primary-light: #e0e7ff;
    --ft-surface: #ffffff;
    --ft-surface-2: #f8fafc;
    --ft-border: #e2e8f0;
    --ft-text: #0f172a;
    --ft-text-muted: #64748b;
    --ft-danger: #ef4444;
    --ft-success: #22c55e;
    --ft-warning: #f59e0b;
    --ft-radius: 0.75rem;
    --ft-radius-sm: 0.5rem;
    --ft-shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --ft-shadow: 0 4px 16px rgba(0,0,0,.10);
    --ft-shadow-lg: 0 8px 32px rgba(0,0,0,.14);
    --ft-transition: 200ms cubic-bezier(.4,0,.2,1);
    --sidebar-bg: #111827;
    --sidebar-width: 260px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--ft-text);
    background: var(--ft-surface-2);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--ft-primary); text-decoration: none; }
a:hover { color: var(--ft-primary-dark); text-decoration: underline; }

h1:focus { outline: none; }

/* ── Layout ──────────────────────────────────────────────── */

.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid #1f2937;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 200;
}

main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-topbar {
    width: 100%;
    box-sizing: border-box;
    height: 56px;
    background: var(--ft-surface);
    border-bottom: 1px solid var(--ft-border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--ft-shadow-sm);
}

.main-topbar__tools {
    display: flex;
    align-items: center;
    gap: .9rem;
    margin-left: auto;
}

.main-topbar a {
    color: var(--ft-text-muted);
    font-size: .85rem;
    font-weight: 500;
}

.culture-selector {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}

.culture-selector__label {
    font-size: .82rem;
    color: var(--ft-text-muted);
    font-weight: 600;
    margin: 0;
}

.culture-selector__select {
    min-width: 140px;
    height: 38px;
    padding: .45rem .75rem;
    border: 1px solid var(--ft-border);
    border-radius: .6rem;
    background: var(--ft-surface);
    color: var(--ft-text);
    font-size: .85rem;
}

.culture-selector__select:focus {
    outline: none;
    border-color: var(--ft-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.18);
}

.login-display {
    display: inline-flex;
    align-items: center;
    gap: .65rem;
}

.user-name {
    font-size: .85rem;
    color: var(--ft-text-muted);
    white-space: nowrap;
}

.btn-login,
.btn-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: .45rem .85rem;
    border-radius: .6rem;
    border: 1px solid var(--ft-border);
    background: var(--ft-surface);
    color: var(--ft-text);
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--ft-transition);
}

.btn-login:hover,
.btn-logout:hover {
    background: var(--ft-surface-2);
    color: var(--ft-text);
    text-decoration: none;
}

.content {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* ── Sidebar / Nav (styles owned by NavMenu.razor.css) ───── */

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
    border-radius: var(--ft-radius-sm);
    font-weight: 500;
    font-size: .875rem;
    padding: .5rem 1.1rem;
    transition: all var(--ft-transition);
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    border: none;
    cursor: pointer;
}

.btn:focus { box-shadow: 0 0 0 3px rgba(99,102,241,.3); outline: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary   { background: var(--ft-primary);  color: #fff; }
.btn-primary:hover  { background: var(--ft-primary-dark); }

.btn-success   { background: var(--ft-success);  color: #fff; }
.btn-success:hover  { background: #16a34a; }

.btn-danger    { background: var(--ft-danger);   color: #fff; }
.btn-danger:hover   { background: #dc2626; }

.btn-secondary { background: var(--ft-surface);  color: var(--ft-text); border: 1px solid var(--ft-border); }
.btn-secondary:hover { background: var(--ft-surface-2); }

.btn-ghost     { background: transparent; color: var(--ft-text-muted); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--ft-surface-2); color: var(--ft-text); border-color: var(--ft-border); }

.btn-icon {
    padding: .45rem .55rem;
    font-size: .95rem;
    line-height: 1;
}

.btn-sm { padding: .35rem .75rem; font-size: .8rem; }

/* ── Cards ───────────────────────────────────────────────── */

.ft-card {
    background: var(--ft-surface);
    border: 1px solid var(--ft-border);
    border-radius: var(--ft-radius);
    box-shadow: var(--ft-shadow-sm);
    padding: 1.5rem;
    transition: box-shadow var(--ft-transition), transform var(--ft-transition);
}

.ft-card:hover {
    box-shadow: var(--ft-shadow);
    transform: translateY(-1px);
}

/* ── Forms ───────────────────────────────────────────────── */

.form-label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--ft-text);
    margin-bottom: .35rem;
    display: block;
}

.form-control, .form-select {
    width: 100%;
    padding: .55rem .85rem;
    border: 1px solid var(--ft-border);
    border-radius: var(--ft-radius-sm);
    font-size: .9rem;
    background: var(--ft-surface);
    color: var(--ft-text);
    transition: border-color var(--ft-transition), box-shadow var(--ft-transition);
    outline: none;
    display: block;
}

.form-control:focus, .form-select:focus {
    border-color: var(--ft-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.18);
}

textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Alerts ──────────────────────────────────────────────── */

.alert {
    border-radius: var(--ft-radius-sm);
    padding: .85rem 1.1rem;
    font-size: .875rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    border: 1px solid transparent;
}

.alert-danger   { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.alert-success  { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.alert-warning  { background: #fffbeb; color: #b45309; border-color: #fed7aa; }

/* ── Badge ───────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .01em;
}

.badge-indigo  { background: var(--ft-primary-light); color: var(--ft-primary-dark); }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef9c3; color: #a16207; }

/* ── Modal ───────────────────────────────────────────────── */

.ft-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.45);
    backdrop-filter: blur(2px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fade-in .15s ease;
}

.ft-modal {
    background: var(--ft-surface);
    border-radius: var(--ft-radius);
    box-shadow: var(--ft-shadow-lg);
    width: 100%;
    max-width: 500px;
    margin: 1rem;
    animation: slide-up .2s ease;
}

.ft-modal--lg {
    max-width: 760px;
}

.ft-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--ft-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ft-modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ft-text);
    margin: 0;
}

.ft-modal-body { padding: 1.5rem; }

.ft-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--ft-border);
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
}

/* ── Divider ─────────────────────────────────────────────── */

.ft-divider {
    border: none;
    border-top: 1px solid var(--ft-border);
    margin: 1.5rem 0;
}

/* ── Animations ──────────────────────────────────────────── */

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slide-up {
    from { transform: translateY(14px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ── Validation ──────────────────────────────────────────── */

.valid.modified:not([type=checkbox]) { border-color: var(--ft-success) !important; }
.invalid { border-color: var(--ft-danger) !important; }
.validation-message { color: var(--ft-danger); font-size: .8rem; margin-top: .25rem; }

/* ── Blazor errors ───────────────────────────────────────── */

#blazor-error-ui {
    color-scheme: light only;
    background: #fffbeb;
    border-top: 2px solid var(--ft-warning);
    bottom: 0;
    box-shadow: 0 -2px 12px rgba(0,0,0,.08);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: .7rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 9999;
    font-size: .875rem;
    color: #92400e;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: .75rem;
    top: .6rem;
    font-size: 1rem;
}

.blazor-error-boundary {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--ft-radius-sm);
    padding: 1rem 1rem 1rem 3rem;
    color: #b91c1c;
}

.blazor-error-boundary::after { content: "An error has occurred." }

/* ── Loading ─────────────────────────────────────────────── */

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: .6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--ft-primary);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * .8), 500%;
    transition: stroke-dasharray .05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto .2rem;
}

.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    main { margin-left: 0; min-width: 0; width: 100%; }
    .content { padding: 1rem; }
    .sidebar-toggler { display: block; }
    .nav-scrollable { display: none; }
    .nav-scrollable.collapse-open { display: block; }
    .main-topbar {
        height: auto;
        min-height: 56px;
        padding-top: .75rem;
        padding-bottom: .75rem;
    }
    .main-topbar__tools {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    .culture-selector {
        width: 100%;
        justify-content: space-between;
    }
    .culture-selector__select {
        flex: 1;
        min-width: 0;
    }
}

.nav-scrollable{
    background: var(--sidebar-bg);
}


.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5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    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}