:root {
    color-scheme: dark;
    --agili-primary: #10B981;
    --agili-primary-light: #34D399;
    --agili-primary-dark: #059669;
    --agili-bg: #0F172A;
    --agili-surface: #1E293B;
    --agili-surface-elevated: #334155;
    --agili-border: #334155;
    --agili-text-primary: #F8FAFC;
    --agili-text-secondary: #CCCCCC;
}

html, body {
    color-scheme: dark;
    background-color: var(--agili-bg);
    color: var(--agili-text-primary);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* MudBlazor Upgrade Safety: rules in this file target only our own agili-* classes and plain HTML elements,
 * never MudBlazor's internal mud-* class names (they are not a public API and may change in any release).
 * MudBlazor theme variables (--mud-*) are always read with a fallback value. */

/* Desktop Pointer Cursor Mandate (MudBlazor already sets the pointer on its own clickable chips and nav links) */
.agili-clickable,
button:not(:disabled),
a[href] {
    cursor: pointer !important;
}

.agili-appbar {
    border-bottom: 1px solid var(--agili-border);
}

.agili-breadcrumb-bar {
    background-color: var(--agili-surface);
    border: 1px solid var(--agili-border);
    border-radius: 12px;
    padding: 8px 16px;
    margin-bottom: 16px;
}

/* Select & Option Dark Theme Contrast Mandate */
select option,
select optgroup {
    background-color: var(--agili-surface-elevated);
    color: var(--agili-text-primary);
}

/* iOS Safari zooms the page in when a focused field's text is smaller than 16px (MudBlazor inputs use 14px)
 * and never zooms back out. On touch screens fields use 16px, so focusing one (e.g. the search box) does not zoom. */
@media (pointer: coarse) {
    input,
    textarea,
    select {
        font-size: 16px !important;
    }
}

.min-w-0 {
    min-width: 0 !important;
}

/* Filter drop-down (AgiliFilterSelect): a native <select>, highlighted while a value is chosen */
.agili-filter-select {
    padding: 8px;
    border: 1px solid var(--agili-border);
    border-radius: 4px;
    background-color: var(--agili-surface-elevated);
    color: var(--agili-text-primary);
    font-size: 0.82rem;
    cursor: pointer;
}

.agili-filter-select--active {
    border-color: var(--agili-primary);
    background-color: rgba(16, 185, 129, 0.13);
}

.agili-filter-select:focus-visible {
    outline: 2px solid var(--agili-primary-light);
    outline-offset: 2px;
}

/* Verification code field: large, spaced digits */
.agili-code-field input {
    text-align: center;
    font-size: 1.5rem !important;
    font-weight: 700;
    letter-spacing: 0.4rem;
}

/* A plain <div> that looks like a flat MudPaper */
.agili-paper {
    color: var(--agili-text-primary);
    background-color: var(--agili-surface);
    border-radius: 12px;
}

/* Hand-written <table> */
.agili-plain-table {
    width: 100%;
    border-spacing: 0;
}

/* Sticky offsets shared by everything that sticks under the app bar (sponsor strip, section tab bars).
 * Fallbacks = MudBlazor defaults, used if a release renames these theme variables.
 * The app bar is shorter on phones (7/8 of the variable in portrait, 3/4 in landscape, full from 600px):
 * --agili-appbar-offset follows the same steps, so the strip always touches the bar. */
.agili-main-content {
    --agili-appbar-offset: calc(var(--mud-appbar-height, 64px) * 0.875);
    /* Sponsor strip sizes: banner frame and pull tab */
    --agili-strip-frame-height: 90px;
    --agili-strip-toggle-height: 28px;
    /* Space the strip takes under the app bar right now, and its pull tab below that: none unless a strip is shown */
    --agili-strip-offset: 0px;
    --agili-strip-toggle-offset: 0px;
}

@media (orientation: landscape) {
    .agili-main-content {
        --agili-appbar-offset: calc(var(--mud-appbar-height, 64px) * 0.75);
    }
}

@media (min-width: 600px) {
    .agili-main-content {
        --agili-appbar-offset: var(--mud-appbar-height, 64px);
    }
}

@media (max-width: 599.98px) {
    .agili-main-content {
        --agili-strip-frame-height: 50px;
    }
}

/* Frame plus the strip's 1px bottom border; a collapsed strip keeps only the border */
.agili-main-content:has(.agili-partner-strip) {
    --agili-strip-offset: calc(var(--agili-strip-frame-height) + 1px);
    --agili-strip-toggle-offset: var(--agili-strip-toggle-height);
}

.agili-main-content:has(.agili-partner-strip.is-collapsed) {
    --agili-strip-offset: 1px;
}

/* Sponsor strip: sticky under the app bar, fixed height reserved so the page never jumps when the image loads.
 * The pull tab hangs below the strip and collapses/expands it (state kept for the visit only). */
.agili-partner-strip {
    position: sticky;
    top: var(--agili-appbar-offset, 64px);
    z-index: calc(var(--mud-zindex-appbar, 1300) - 1);
    background-color: var(--agili-surface);
    border-bottom: 1px solid var(--agili-border);
    /* Room for the 28px pull tab: with the page's 16px top padding it never covers the first row (breadcrumb bar) */
    margin-bottom: 20px;
}

.agili-partner-strip__frame {
    position: relative;
    height: var(--agili-strip-frame-height, 90px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: height 200ms ease;
}

.agili-partner-strip.is-collapsed .agili-partner-strip__frame {
    height: 0;
}

.agili-partner-strip__link {
    display: block;
    width: 100%;
    max-width: 970px;
    height: 100%;
}

.agili-partner-strip__link img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.agili-partner-strip__label {
    position: absolute;
    top: 4px;
    left: 8px;
    padding: 1px 6px;
    border-radius: 4px;
    background-color: rgba(15, 23, 42, 0.8);
    color: var(--agili-text-secondary);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    pointer-events: none;
}

.agili-partner-strip__toggle {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 104px;
    height: var(--agili-strip-toggle-height, 28px);
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background-color: var(--agili-surface);
    color: var(--agili-text-secondary);
    border: 1px solid var(--agili-border);
    border-top: none;
    border-radius: 0 0 10px 10px;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
}

.agili-partner-strip__toggle:hover {
    color: var(--agili-text-primary);
}

.agili-partner-strip__toggle:focus-visible {
    outline: 2px solid var(--agili-primary);
    outline-offset: 2px;
}

/* Section tabs (AgiliSectionTabs): a tab bar that stays visible under the app bar and the sponsor strip
 * while its section scrolls. The top padding is the room the strip's pull tab hangs into, so the pull tab
 * never covers a tab; the negative margin gives part of that room back while the bar is not stuck. */
.agili-section-tabs {
    position: sticky;
    top: calc(var(--agili-appbar-offset, 64px) + var(--agili-strip-offset, 0px));
    /* Above the page content, below the drawer, popovers, sponsor strip and app bar */
    z-index: calc(var(--mud-zindex-drawer, 1100) - 1);
    margin-top: calc(var(--agili-strip-toggle-offset, 0px) / -2);
    padding-top: var(--agili-strip-toggle-offset, 0px);
    background-color: var(--agili-bg);
    transition: top 200ms ease;
}

.agili-section-tabs__viewport {
    position: relative;
}

/* The bar scrolls sideways when the tabs do not fit: swipe, the arrows below, or the arrow keys.
 * No scrollbar: the arrows say that more tabs are hidden, and a scrollbar line would sit next to the
 * underline of the active tab. */
.agili-section-tabs__list {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    border-bottom: 1px solid var(--agili-border);
}

.agili-section-tabs__list::-webkit-scrollbar {
    display: none;
}

/* Scroll arrows: hidden until the platform script sets data-more-start / data-more-end on the bar,
 * i.e. only on a side where tabs are hidden. The fade behind the arrow shows that the row continues. */
.agili-section-tabs__arrow {
    position: absolute;
    top: 0;
    bottom: 1px;
    z-index: 1;
    display: none;
    align-items: center;
    width: 48px;
    padding: 0;
    border: none;
    color: var(--agili-text-primary);
}

.agili-section-tabs__arrow--start {
    left: 0;
    justify-content: flex-start;
    background: linear-gradient(to right, var(--agili-bg) 60%, transparent);
}

.agili-section-tabs__arrow--end {
    right: 0;
    justify-content: flex-end;
    background: linear-gradient(to left, var(--agili-bg) 60%, transparent);
}

.agili-section-tabs[data-more-start] .agili-section-tabs__arrow--start,
.agili-section-tabs[data-more-end] .agili-section-tabs__arrow--end {
    display: flex;
}

.agili-section-tabs__arrow:hover {
    color: var(--agili-primary-light);
}

.agili-section-tabs__arrow:focus-visible {
    outline: 2px solid var(--agili-primary-light);
    outline-offset: -2px;
}

.agili-section-tabs__tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 48px;
    padding: 0 14px;
    border: none;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--agili-text-secondary);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

.agili-section-tabs__tab:hover {
    color: var(--agili-text-primary);
}

.agili-section-tabs__tab.is-active {
    color: var(--agili-primary-light);
    border-bottom-color: var(--agili-primary);
}

.agili-section-tabs__tab:focus-visible {
    outline: 2px solid var(--agili-primary-light);
    outline-offset: -2px;
}

.agili-section-tabs__count {
    min-width: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background-color: var(--agili-surface-elevated);
    color: var(--agili-text-primary);
    font-size: 0.72rem;
    line-height: 20px;
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    .agili-partner-strip__frame,
    .agili-section-tabs {
        transition: none;
    }
}

/* Unread counter next to a drawer link (e.g. new advertising requests) */
.agili-nav-count {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background-color: #EF4444;
    color: #FFFFFF;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

/* Honeypot field of the advertising form: off-screen for people, still filled in by form bots */
.agili-hp {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Sidebar Drawer Layout Mandate:
 * MudBlazor's full-width dividers grow vertically inside the drawer's flex column and would push the nav menu
 * to the center. Every <MudDivider> in AgiliNavDrawer therefore carries Class="flex-grow-0" (a public MudBlazor
 * utility, guarded by ShellLayoutTests); no CSS override is needed here.
 */

/* Sidebar App Version Button */
.agili-version-btn {
    transition: all 150ms ease-in-out;
}
.agili-version-btn:hover {
    border-color: var(--agili-primary) !important;
    color: var(--agili-primary) !important;
    background-color: rgba(16, 185, 129, 0.08) !important;
}

/* Changelog HTML Styling */
.agili-changelog-card {
    background-color: var(--agili-surface);
    border: 1px solid var(--agili-border);
    border-radius: 12px;
}

.agili-changelog-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 6px;
    vertical-align: middle;
}

.agili-changelog-tag--feature {
    background-color: rgba(16, 185, 129, 0.18);
    color: #34D399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.agili-changelog-tag--improvement {
    background-color: rgba(56, 189, 248, 0.18);
    color: #38BDF8;
    border: 1px solid rgba(56, 189, 248, 0.4);
}

.agili-changelog-tag--fix {
    background-color: rgba(245, 158, 11, 0.18);
    color: #FBBF24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.agili-changelog-list {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}

.agili-changelog-list li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 8px;
    line-height: 1.6;
    color: var(--agili-text-secondary);
}

.agili-changelog-list li::before {
    content: "•";
    position: absolute;
    left: 4px;
    color: var(--agili-primary);
    font-size: 1.2rem;
    line-height: 1.3;
}