/* ═══════════════════════════════════════════════════════════════════════════
   FamilyVault — app.css
   Modern, clean design system. No 3rd-party UI framework dependencies.
   Supports light mode (default) and dark mode via prefers-color-scheme.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
    /* Brand palette */
    --fv-brand:          #4f46e5;   /* indigo-600 */
    --fv-brand-dark:     #3730a3;   /* indigo-800 */
    --fv-brand-light:    #e0e7ff;   /* indigo-100 */
    --fv-accent:         #06b6d4;   /* cyan-500  */

    /* Surfaces */
    --fv-bg:             #f8fafc;   /* slate-50  */
    --fv-surface:        #ffffff;
    --fv-surface-raised: #ffffff;
    --fv-border:         #e2e8f0;   /* slate-200 */
    --fv-border-focus:   #4f46e5;

    /* Text */
    --fv-text:           #0f172a;   /* slate-900 */
    --fv-text-muted:     #64748b;   /* slate-500 */
    --fv-text-inverse:   #ffffff;

    /* Navbar */
    --fv-nav-bg:         #1e1b4b;   /* indigo-950 */
    --fv-nav-text:       #c7d2fe;   /* indigo-200 */
    --fv-nav-active:     #ffffff;
    --fv-nav-hover-bg:   rgba(255,255,255,0.08);
    --fv-nav-height:     60px;

    /* Shadows */
    --fv-shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --fv-shadow-md:      0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
    --fv-shadow-lg:      0 10px 30px rgba(0,0,0,.12);

    /* Radii */
    --fv-radius-sm:      6px;
    --fv-radius:         10px;
    --fv-radius-lg:      16px;
    --fv-radius-pill:    999px;

    /* Transitions */
    --fv-transition:     150ms ease;
}

/* Dark mode overrides */
@media (prefers-color-scheme: dark) {
    :root {
        --fv-bg:             #0f172a;
        --fv-surface:        #1e293b;
        --fv-surface-raised: #273549;
        --fv-border:         #334155;
        --fv-text:           #f1f5f9;
        --fv-text-muted:     #94a3b8;
        --fv-brand-light:    #312e81;
        --fv-nav-bg:         #0f172a;
    }
}

/* ── Reset & base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--fv-text);
    background: var(--fv-bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.25;
    color: var(--fv-text);
    margin-top: 0;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

a { color: var(--fv-brand); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .fv-secret {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    letter-spacing: 0.04em;
}

/* ── App shell ──────────────────────────────────────────────────────────── */
.fv-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.fv-main {
    flex: 1;
    padding-top: var(--fv-nav-height);   /* clear the fixed navbar */
}

.fv-content {
    max-width: 1280px;
    margin: 0 auto;
}

/* ── Navbar ─────────────────────────────────────────────────────────────── */
.fv-navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--fv-nav-height);
    background: var(--fv-nav-bg);
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    z-index: 1000;
}

.fv-navbar-inner {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 1.25rem;
    gap: 0.5rem;
}

/* Brand */
.fv-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    margin-right: 1.5rem;
    flex-shrink: 0;
}

.fv-brand-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.fv-brand-name {
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.02em;
}

/* Nav links */
.fv-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.fv-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--fv-radius-sm);
    color: var(--fv-nav-text);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: background var(--fv-transition), color var(--fv-transition);
    white-space: nowrap;
}

.fv-nav-link:hover,
.fv-nav-link.active {
    background: var(--fv-nav-hover-bg);
    color: var(--fv-nav-active);
    text-decoration: none;
}

.fv-nav-link.active {
    background: rgba(255,255,255,0.12);
    font-weight: 600;
}

.fv-nav-link-muted { opacity: 0.7; font-size: 1.1rem; padding: 0.45rem 0.6rem; }
.fv-nav-link-muted:hover { opacity: 1; }

.fv-nav-icon { font-size: 1rem; }

/* Dropdown */
.fv-dropdown { position: relative; }

.fv-dropdown-toggle { user-select: none; }

.fv-chevron {
    font-size: 0.75rem;
    display: inline-block;
    transition: transform var(--fv-transition);
    margin-left: 0.15rem;
}
.fv-chevron.open { transform: rotate(180deg); }

.fv-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    background: var(--fv-surface);
    border: 1px solid var(--fv-border);
    border-radius: var(--fv-radius);
    box-shadow: var(--fv-shadow-md);
    padding: 0.4rem 0;
    z-index: 1100;
}

.fv-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    color: var(--fv-text);
    font-size: 0.9rem;
    text-decoration: none;
    transition: background var(--fv-transition);
}

.fv-dropdown-item:hover,
.fv-dropdown-item.active {
    background: var(--fv-brand-light);
    color: var(--fv-brand-dark);
    text-decoration: none;
}

/* Right side */
.fv-navbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.fv-user-chip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem 0.3rem 0.3rem;
    background: rgba(255,255,255,0.1);
    border-radius: var(--fv-radius-pill);
}

.fv-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--fv-brand);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fv-user-name {
    color: var(--fv-nav-active);
    font-size: 0.875rem;
    font-weight: 500;
}

.fv-role-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: var(--fv-radius-pill);
    background: rgba(255,255,255,0.15);
    color: var(--fv-nav-text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.fv-signout-btn {
    padding: 0.35rem 0.85rem;
    border-radius: var(--fv-radius-sm);
    border: 1px solid rgba(255,255,255,0.25);
    background: transparent;
    color: var(--fv-nav-text);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--fv-transition), color var(--fv-transition);
}

.fv-signout-btn:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* Hamburger (mobile) */
.fv-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    padding: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    margin-left: auto;
}

.fv-hamburger span {
    display: block;
    height: 2px;
    background: var(--fv-nav-text);
    border-radius: 2px;
    transition: background var(--fv-transition);
}

.fv-hamburger:hover span { background: #fff; }

/* Mobile drawer */
.fv-mobile-menu {
    position: fixed;
    top: var(--fv-nav-height);
    left: 0; right: 0;
    background: var(--fv-nav-bg);
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 0.5rem 0 1rem;
    z-index: 999;
    box-shadow: var(--fv-shadow-lg);
}

.fv-mobile-link {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--fv-nav-text);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background var(--fv-transition);
}

.fv-mobile-link:hover,
.fv-mobile-link.active {
    background: var(--fv-nav-hover-bg);
    color: #fff;
    text-decoration: none;
}

.fv-mobile-signout {
    margin-top: 0.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 1rem;
    color: #fca5a5;
}

@media (max-width: 768px) {
    .fv-nav, .fv-navbar-right { display: none; }
    .fv-hamburger { display: flex; }
}

/* ── Login page ─────────────────────────────────────────────────────────── */
.fv-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--fv-bg);
    padding: 1rem;
}

.fv-login-card {
    width: 100%;
    max-width: 420px;
    background: #DBEAFE;
    border: 2px solid #1A3A5C;
    border-radius: var(--fv-radius-lg);
    padding: 2.5rem 2rem;
    box-shadow: var(--fv-shadow-lg);
}

.fv-login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.fv-app-icon {
    width: 96px;
    height: 96px;
    object-fit: contain;
    display: block;
    margin: 0 auto 0.75rem;
}

.fv-login-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--fv-brand);
    margin: 0 0 0.75rem;
    letter-spacing: -0.03em;
}

.fv-tagline-img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* ── Form controls ──────────────────────────────────────────────────────── */
.fv-input {
    border-radius: var(--fv-radius-sm);
    border: 1.5px solid var(--fv-border);
    background: var(--fv-bg);
    color: var(--fv-text);
    transition: border-color var(--fv-transition), box-shadow var(--fv-transition);
}

.fv-input:focus {
    border-color: var(--fv-border-focus);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
    outline: none;
    background: var(--fv-surface);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.fv-btn-primary {
    background: var(--fv-brand);
    color: #fff;
    border: none;
    border-radius: var(--fv-radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.65rem 1.25rem;
    transition: background var(--fv-transition), transform 80ms ease, box-shadow var(--fv-transition);
    box-shadow: 0 2px 6px rgba(79,70,229,0.35);
}

.fv-btn-primary:hover:not(:disabled) {
    background: var(--fv-brand-dark);
    box-shadow: 0 4px 12px rgba(79,70,229,0.4);
}

.fv-btn-primary:active:not(:disabled) { transform: translateY(1px); }
.fv-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* Override Bootstrap btn-primary to match our brand */
.btn-primary {
    background-color: var(--fv-brand);
    border-color: var(--fv-brand);
}
.btn-primary:hover { background-color: var(--fv-brand-dark); border-color: var(--fv-brand-dark); }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--fv-surface);
    border: 1px solid var(--fv-border);
    border-radius: var(--fv-radius);
    box-shadow: var(--fv-shadow-sm);
}

.card-header {
    background: var(--fv-surface);
    border-bottom: 1px solid var(--fv-border);
    border-radius: var(--fv-radius) var(--fv-radius) 0 0 !important;
}

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table {
    color: var(--fv-text);
    border-color: var(--fv-border);
}

.table-light th {
    background: var(--fv-surface-raised);
    color: var(--fv-text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--fv-border);
}

.table-hover tbody tr:hover {
    background: var(--fv-brand-light);
}

/* ── Resizable columns ───────────────────────────────────────────────────── */
/* Clip cell content when a column is dragged narrow */
#credentials-table td,
#credentials-table th.col-resizable {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Subtle visible indicator on the resize handle */
.col-resize-handle:hover,
.col-resize-handle:active {
    background: var(--fv-brand);
    opacity: 0.35;
    border-radius: 2px;
}

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
    font-weight: 600;
    letter-spacing: 0.03em;
    border-radius: var(--fv-radius-pill);
}

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
    border-radius: var(--fv-radius-sm);
    border: none;
    font-size: 0.9rem;
}

/* ── Validation ─────────────────────────────────────────────────────────── */
.valid.modified:not([type=checkbox]) {
    outline: 2px solid #22c55e;
    outline-offset: 1px;
}

.invalid {
    outline: 2px solid #ef4444;
    outline-offset: 1px;
}

.validation-message {
    color: #ef4444;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* ── Focus ring ─────────────────────────────────────────────────────────── */
.btn:focus-visible,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(79,70,229,0.25);
    outline: none;
}

/* ── Blazor error UI ────────────────────────────────────────────────────── */
#blazor-error-ui {
    color-scheme: light only;
    background: #fef3c7;
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,.15);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.75rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 9999;
    font-size: 0.9rem;
    color: #92400e;
}

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

.blazor-error-boundary {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--fv-radius);
    padding: 1rem 1rem 1rem 3.5rem;
    color: #991b1b;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ef4444'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 1rem center;
    background-size: 1.75rem;
}

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

/* ── Loading progress ───────────────────────────────────────────────────── */
.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

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

.loading-progress circle:last-child {
    stroke: var(--fv-brand);
    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: 700;
    color: var(--fv-text-muted);
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

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

/* ── Gear button ────────────────────────────────────────────────────────── */
.fv-gear-btn {
    font-size: 1.15rem;
    padding: 0.4rem 0.6rem;
    gap: 0.2rem;
}

/* Dropdown right-aligned (for gear menu near right edge) */
.fv-dropdown-right {
    left: auto;
    right: 0;
}

.fv-dropdown-divider {
    height: 1px;
    background: var(--fv-border);
    margin: 0.35rem 0;
}

.fv-dropdown-label {
    display: block;
    padding: 0.3rem 1rem 0.15rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--fv-text-muted);
}

/* Avatar image in navbar chip */
.fv-user-avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

/* Mobile divider */
.fv-mobile-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 0.4rem 0;
}

/* ── Profile / Settings page ─────────────────────────────────────────────── */
.fv-settings-card {
    background: var(--fv-surface);
    border: 1px solid var(--fv-border);
    border-radius: var(--fv-radius);
    padding: 1.75rem 2rem;
    box-shadow: var(--fv-shadow-sm);
    max-width: 720px;
}

.fv-settings-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--fv-text);
    margin-bottom: 1.25rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--fv-border);
}

/* Avatar row */
.fv-avatar-row {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}

.fv-avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--fv-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    border: 3px solid var(--fv-border);
}

.fv-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fv-avatar-initials {
    color: #fff;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.fv-avatar-controls {
    flex: 1;
}

/* Avatar upload row */
.fv-avatar-upload-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

/* Styled label acts as the file-picker button */
.fv-avatar-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.9rem;
    border-radius: var(--fv-radius-sm);
    border: 1.5px solid var(--fv-brand);
    background: var(--fv-brand-light);
    color: var(--fv-brand-dark);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--fv-transition), border-color var(--fv-transition);
    user-select: none;
}

.fv-avatar-upload-btn:hover {
    background: var(--fv-brand);
    color: #fff;
    border-color: var(--fv-brand);
}

/* Hide the native file input visually but keep it accessible */
.fv-avatar-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
}

/* Theme picker */
.fv-theme-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.fv-theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 1.5rem;
    border: 2px solid var(--fv-border);
    border-radius: var(--fv-radius);
    background: var(--fv-surface);
    cursor: pointer;
    transition: border-color var(--fv-transition), background var(--fv-transition);
    min-width: 110px;
    position: relative;
}

.fv-theme-option:hover {
    border-color: var(--fv-brand);
    background: var(--fv-brand-light);
}

.fv-theme-option.selected {
    border-color: var(--fv-brand);
    background: var(--fv-brand-light);
}

.fv-theme-icon { font-size: 1.75rem; }

.fv-theme-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--fv-text);
}

.fv-theme-check {
    position: absolute;
    top: 0.4rem;
    right: 0.5rem;
    font-size: 0.85rem;
    color: var(--fv-brand);
    font-weight: 700;
}

/* Admin link cards */
.fv-admin-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 480px;
}

.fv-admin-link-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--fv-border);
    border-radius: var(--fv-radius);
    background: var(--fv-surface);
    text-decoration: none;
    color: var(--fv-text);
    transition: border-color var(--fv-transition), background var(--fv-transition), box-shadow var(--fv-transition);
}

.fv-admin-link-card:hover {
    border-color: var(--fv-brand);
    background: var(--fv-brand-light);
    box-shadow: var(--fv-shadow-sm);
    text-decoration: none;
    color: var(--fv-text);
}

.fv-admin-link-icon { font-size: 1.75rem; flex-shrink: 0; }

/* ── Utility helpers ────────────────────────────────────────────────────── */
.fv-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--fv-text);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--fv-border);
}

.fv-secret {
    background: var(--fv-surface-raised);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--fv-border);
    user-select: all;
}

.fv-copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-size: 1rem;
    opacity: 0.6;
    transition: opacity var(--fv-transition), background var(--fv-transition);
}

.fv-copy-btn:hover { opacity: 1; background: var(--fv-brand-light); }

/* ── Password show/hide toggle ──────────────────────────────────────────── */
.fv-password-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.fv-password-wrap .form-control {
    padding-right: 2.75rem;   /* make room for the eye button */
}

.fv-eye-btn {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0.2rem 0.25rem;
    cursor: pointer;
    color: var(--fv-text-muted);
    line-height: 1;
    border-radius: var(--fv-radius-sm);
    transition: color var(--fv-transition), background var(--fv-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.fv-eye-btn:hover {
    color: var(--fv-brand);
    background: var(--fv-brand-light);
}

.fv-eye-btn:focus-visible {
    outline: 2px solid var(--fv-brand);
    outline-offset: 1px;
}
