@import '_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css';
@import 'components.css';

/* Base application styles - Mobile First */
body {
    --body-font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-family: var(--body-font);
    font-size: var(--type-ramp-base-font-size);
    line-height: var(--type-ramp-base-line-height);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Layout improvements */
.navmenu-icon {
    display: none;
}

.main {
    /* allow page to grow vertically */
    min-height: calc(100dvh - 86px);
    color: var(--neutral-foreground-rest);
    align-items: stretch !important;
    padding: 0;
}

.body-content {
    align-self: stretch;
    /* previously forced fixed height; remove to allow scroll */
    min-height: calc(100dvh - 86px);
    display: flex;
    flex: 1 1 auto;
    overflow-y: auto; /* enable vertical scroll */
    -webkit-overflow-scrolling: touch; /* smooth iOS scroll */
}

.content {
    padding: 0.75rem;
    align-self: stretch !important;
    width: 100%;
    overflow-x: hidden;
    flex: 1 1 auto;
    padding-bottom: max(1rem, env(safe-area-inset-bottom)); /* ensure bottom content visible behind gesture bar */
}

/* Footer */
footer {
    background: var(--neutral-layer-4);
    color: var(--neutral-foreground-rest);
    align-items: center;
    padding: 0.75rem;
    text-align: center;
}

footer a {
    color: var(--neutral-foreground-rest);
    text-decoration: none;
}

footer a:focus {
    outline: 1px dashed;
    outline-offset: 3px;
}

footer a:hover {
    text-decoration: underline;
}

/* MOBILE OVERRIDES */
@media (max-width: 767px) {
    .body-content {
        min-height: auto; /* let content determine height */
    }
}

/* --- rest of existing rules unchanged below --- */

/* Alert improvements */
.alert {
    border: 1px solid var(--accent-fill-rest);
    background: var(--accent-layer-1, rgba(96, 165, 250, 0.1));
    padding: 0.75rem;
    border-radius: 6px;
    margin: 0.75rem 0;
}

/* Error UI */
#blazor-error-ui {
    background: var(--error-fill-rest, #dc2626);
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: white;
    font-size: 0.875rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
    font-size: 1.25rem;
    background: none;
    border: none;
    color: white;
    padding: 0.25rem;
}

/* Error boundary */
.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA9NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDg=) no-repeat 1rem/1.5rem 1.5rem;
    padding: 1rem 1rem 1rem 3.5rem;
    margin: 0.5rem 0;
    border-radius: 6px;
}

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

/* Loading progress */
.loading-progress {
    position: relative;
    display: block;
    width: 6rem;
    height: 6rem;
    margin: 15vh auto 1rem auto;
}

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

.loading-progress circle:last-child {
    stroke: var(--accent-fill-rest, #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: 600;
    inset: calc(15vh + 3.25rem) 0 auto 0.2rem;
    font-size: 0.875rem;
}

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

/* Code styling */
code {
    color: var(--accent-fill-rest, #c02d76);
    background: var(--neutral-layer-1, rgba(0, 0, 0, 0.05));
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-size: 0.875em;
}

/* Mobile navigation improvements */
@media (max-width: 600px) {
    .content {
        padding: 0.5rem;
    }
    .header-gutters {
        margin: 0.5rem 3rem 0.5rem 1.5rem !important;
    }
    [dir="rtl"] .header-gutters {
        margin: 0.5rem 1.5rem 0.5rem 3rem !important;
    }
    .main { flex-direction: column !important; row-gap: 0 !important; }
    nav.sitenav { width: 100%; height: 100%; }
    #main-menu { width: 100% !important; }
    #main-menu > div:first-child:is(.expander) { display: none; }
    .navmenu { width: 100%; }
    #navmenu-toggle { appearance: none; }
    #navmenu-toggle ~ nav { display: none; }
    #navmenu-toggle:checked ~ nav { display: block; }
    .navmenu-icon { cursor: pointer; z-index: 10; display: block; position: absolute; top: 15px; right: 20px; width: 20px; height: 20px; border: none; background: none; color: var(--neutral-foreground-rest); }
    [dir="rtl"] .navmenu-icon { left: 20px; right: unset; }
}

/* FluentUI component overrides for mobile */
@media (max-width: 767px) {
    .fluent-button { min-height: 44px; padding: 0.75rem 1rem; }
    .fluent-text-field,
    .fluent-number-field,
    .fluent-select { min-height: 44px; }
    .fluent-data-grid { font-size: 0.875rem; }
    .fluent-data-grid-cell { padding: 0.5rem; }
    .fluent-card { padding: 0.75rem; margin-bottom: 0.75rem; }
    .fluent-accordion-item { margin-bottom: 0.5rem; }
    .fluent-stack[gap="16"] { gap: 12px; }
    .fluent-stack[gap="20"] { gap: 16px; }
    .fluent-stack[gap="24"] { gap: 18px; }
}

/* Global fix for FluentSelect dropdown cutoff */
/* Ensure dropdown popups are not clipped by parent containers */
/* Target the fluent-select listbox positioning */
fluent-select {
    /* Ensure select has proper stacking context */
    position: relative;
}

/* Override any overflow constraints on form sections that might clip dropdowns */
/* Progressive enhancement approach: */
/* 1. Base rule (fallback): Applies overflow: visible to all .form-section elements */
/*    - Targets browsers without :has() support (IE, older Safari < 15.4) */
/*    - Potential side effect: May affect form sections that intentionally use overflow */
/*    - Risk is low as most form sections don't require constrained overflow */
.form-section {
    overflow: visible;
}
/* 2. Enhanced rule (modern browsers): Uses :has() for targeted application */
/*    - Only affects form sections that contain fluent-select elements */
/*    - Supported in Chrome 105+, Firefox 121+, Safari 15.4+, Edge 105+ */
/*    - Uses !important to override any conflicting overflow settings that may clip dropdowns */
.form-section:has(fluent-select) {
    overflow: visible !important;
}

/* Ensure listbox popup has high z-index to appear above all content */
/* Using 10000 which is higher than most other UI elements */
/* This ensures dropdowns are visible even when opening upward */
fluent-listbox,
fluent-select::part(listbox) {
    z-index: 10000 !important;
}

/* Force listbox to render in a fixed positioning context to avoid being clipped */
fluent-select::part(listbox) {
    position: fixed !important;
}
