/* Leftover MudSelect / MudMenu overlays stay in the DOM after the popover closes
   (especially when a live page re-renders mid-close) and steal the next click —
   dialogs then need two clicks to open or to press OK. While no popover is open,
   those overlays must not capture pointer events. Real dialog/drawer overlays
   use different classes and are left alone. */
body:not(:has(.mud-popover-open)) .mud-overlay-popover {
    pointer-events: none !important;
}

.gap-table {
    background-color: transparent !important;
}

/* 2. Target the table cells to create the 'Card' effect */
.gap-table .mud-table-body .mud-table-row > td {
    background-color: var(--mud-palette-surface); /* Card Color */
    border-top: 12px solid var(--mud-palette-background); /* The Gap */
    border-bottom: none !important;
}

/* 3. Optional: Round the corners of the row to look more like a card */
.gap-table .mud-table-body .mud-table-row > td:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}
.gap-table .mud-table-body .mud-table-row > td:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* 4. Fix for the Header: Give it a background so it stands out */
.gap-table .mud-table-head > .mud-table-row > th {
    background-color: var(--mud-palette-surface);
    border-bottom: 12px solid var(--mud-palette-background) !important; /* Gap below header */
}

/* MudChart sizing.
   `.mud-chart` is a flex container with `min-width: fit-content` and the SVG
   inside has no flex-grow, so the chart never expands past the SVG's intrinsic
   viewBox width even when the wrapper is much wider. We override that:
     - drop the `fit-content` floor so the chart can shrink to the wrapper width,
     - force the chart to fill its `.mud-chart-fill` wrapper,
     - let the SVG flex-grow to fill the remaining row space. */
.mud-chart-fill {
    display: block;
    overflow: hidden;
}
.mud-chart-fill .mud-chart {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
}
.mud-chart-fill .mud-chart > svg {
    flex: 1 1 auto !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    display: block;
}

/* Coloured legend dot for the per-operation latency summary cards.
   The colour is supplied per-instance via inline `background-color`. */
.latency-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* --- Nursers page: create-form is collapsible on mobile --------------------
   Desktop (>= md / 960px): always show the create form. The toggle button
   is wrapped in <MudHidden Breakpoint="MdAndUp"> in the page, so it's only
   visible on mobile.
   Mobile (< 960px): hide the create form by default; reveal it when the
   wrapper has the `--open` modifier class (driven by `_showCreate`). */
.nurser-create-wrapper,
.nurser-filter-wrapper {
    display: block;
}

@media (max-width: 959.98px) {
    .nurser-create-wrapper,
    .nurser-filter-wrapper {
        display: none !important;
    }

    .nurser-create-wrapper.nurser-create-wrapper--open,
    .nurser-filter-wrapper.nurser-filter-wrapper--open {
        display: block !important;
    }
}

/* --- Total PnL milestone celebration --------------------------------------
   Applied (and removed) by JS (window.pnlCelebration) when total PnL crosses a
   new €100k milestone. Lives in the global stylesheet (not the scoped
   Dashboard.razor.css) so it reliably matches the JS-toggled class on the
   MudPaper element and the dynamically created fireworks canvas. */
.pnl-celebrate {
    position: relative;
    z-index: 1;
    animation: pnl-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 1,
               pnl-glow 1s ease-in-out infinite;
}

/* Rotating multi-colour border ("the swirly thing"). Applied only while the fireworks run
   (class added/removed by JS), so it stops together with them; the bulbs + glow persist. */
.pnl-celebrate-swirl::before {
    content: "";
    position: absolute;
    inset: -5px;
    border-radius: 16px;
    padding: 4px;
    background: conic-gradient(from 0deg,
        #ff0040, #ff8c00, #ffd700, #00e676, #00b0ff, #d500f9, #ff0040);
    /* Show only the border ring by masking out the interior. */
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask-composite: exclude;
    animation: pnl-spin 1.6s linear infinite;
    pointer-events: none;
    z-index: -1;
}

/* Blinking "bulbs" running along the marquee ring. */
.pnl-celebrate::after {
    content: "";
    position: absolute;
    inset: -5px;
    border-radius: 16px;
    background:
        repeating-linear-gradient(90deg,
            rgba(255, 255, 255, 0.95) 0 6px, transparent 6px 22px);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask-composite: exclude;
    padding: 4px;
    mix-blend-mode: screen;
    animation: pnl-bulbs 0.5s steps(2, jump-none) infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes pnl-spin {
    to { transform: rotate(1turn); }
}

@keyframes pnl-bulbs {
    0%   { opacity: 0.9; background-position: 0 0; }
    100% { opacity: 0.3; background-position: 22px 0; }
}

@keyframes pnl-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}

@keyframes pnl-glow {
    0%, 100% { box-shadow: 0 0 14px 2px rgba(255, 215, 0, 0.55),
                           0 0 30px 6px rgba(213, 0, 249, 0.35); }
    50%      { box-shadow: 0 0 22px 6px rgba(0, 176, 255, 0.65),
                           0 0 42px 12px rgba(0, 230, 118, 0.45); }
}

.pnl-fireworks-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20000;
}

/* Marching-ants border, Las-Vegas style: big round glowing bulbs chasing smoothly around the card
   — including around the rounded corners. Rendered as an SVG rounded-rect stroke (added to the card
   when daily PnL is above a threshold); round dash caps make the bulbs, a gradient stroke colours
   each bulb differently, and the whole thing hue-cycles, flashes and glows. */
.pnl-marching-ants {
    position: relative;
}

.pnl-ants-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible; /* let the bulbs straddle the edge + glow spill out */
    pointer-events: none;
    z-index: 2;
}

.pnl-ants-rect {
    fill: none;
    stroke-width: 9px;
    stroke-linecap: round;          /* round dash caps = round bulbs */
    stroke-dasharray: 1 27;         /* tiny dash + gap; round caps grow it into a ~9px bulb */
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.85)) drop-shadow(0 0 9px rgba(255, 0, 128, 0.7));
    animation:
        pnl-ants 0.7s linear infinite,
        pnl-ants-hue 3.5s linear infinite,
        pnl-ants-flash 0.9s ease-in-out infinite;
}

/* March the bulbs one full dash period (dash 1 + gap 27) for a seamless loop. */
@keyframes pnl-ants {
    to { stroke-dashoffset: -28; }
}

@keyframes pnl-ants-hue {
    0%   { filter: hue-rotate(0deg)   drop-shadow(0 0 5px rgba(255, 255, 255, 0.85)) drop-shadow(0 0 10px rgba(255, 0, 128, 0.7)); }
    100% { filter: hue-rotate(360deg) drop-shadow(0 0 5px rgba(255, 255, 255, 0.85)) drop-shadow(0 0 10px rgba(255, 0, 128, 0.7)); }
}

@keyframes pnl-ants-flash {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.6; }
}

@media (prefers-reduced-motion: reduce) {
    .pnl-celebrate,
    .pnl-celebrate-swirl::before,
    .pnl-celebrate::after,
    .pnl-ants-rect {
        animation: none;
    }
}

/* --- Nursers page: compact the per-area table on mobile -------------------- */
@media (max-width: 959.98px) {
    .nurser-country-section {
        padding: 0.5rem !important;
    }

    .nurser-country-section .mud-table-container {
        overflow-x: auto;
    }

    .nurser-table .mud-table-cell,
    .nurser-table .mud-table-head .mud-table-cell {
        font-size: 0.7rem !important;
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
        padding-top: 0.15rem !important;
        padding-bottom: 0.15rem !important;
        white-space: nowrap;
    }

    .nurser-table .mud-icon-button {
        padding: 2px !important;
    }

    .nurser-table .mud-icon-button .mud-icon-root,
    .nurser-table .mud-icon-button svg {
        font-size: 1rem !important;
        width: 1rem !important;
        height: 1rem !important;
    }

    .nurser-table .mud-checkbox .mud-icon-button {
        padding: 0 !important;
    }

    /* Hide the State (6th) and OMT (12th) columns on mobile.
       Column order: 1 checkbox, 2 Actions, 3 Strat., 4 Dir., 5 Prod.,
       6 State, 7 QTY, 8 Tr., 9 Limit, 10 Px, 11 Ordr Px, 12 OMT, 13 Ordr state. */
    .nurser-table .mud-table-row > th:nth-child(6),
    .nurser-table .mud-table-row > td:nth-child(6),
    .nurser-table .mud-table-row > th:nth-child(12),
    .nurser-table .mud-table-row > td:nth-child(12) {
        display: none !important;
    }
}

/* Delivery-area cards on the frontpage. These live here, not in Dashboard.razor.css:
   index.html does not load the Blazor scoped bundle, so rules in *.razor.css never reach the browser. */
.area-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-surface);
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
}

.area-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.area-card-name {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.area-card-code {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
}

.area-periods {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.area-period {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 10px 10px 8px;
    border-radius: 10px;
}

.area-period-today {
    background: rgba(119, 107, 231, 0.16);
    background: color-mix(in srgb, var(--mud-palette-primary) 18%, var(--mud-palette-surface));
    box-shadow: inset 0 3px 0 var(--mud-palette-primary);
}

.area-period-month {
    background: rgba(77, 171, 245, 0.14);
    background: color-mix(in srgb, var(--mud-palette-info) 16%, var(--mud-palette-surface));
    box-shadow: inset 0 3px 0 var(--mud-palette-info);
}

.area-period-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.area-period-today .area-period-label {
    color: var(--mud-palette-primary);
}

.area-period-month .area-period-label {
    color: var(--mud-palette-info);
}

.area-period-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    margin: 0;
}

.area-period-meta {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    font-variant-numeric: tabular-nums;
}

.area-strategies {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--mud-palette-lines-default);
}

.area-strategy {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.area-strategy-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    font-size: 0.78rem;
}

.area-strategy-pnl {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    margin: 0;
}

.area-card-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--mud-palette-text-secondary);
}

.area-card-total-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin: 0;
}

@media (max-width: 720px) {
    .area-periods {
        grid-template-columns: 1fr;
    }

    .area-card {
        padding: 12px;
    }
}

