/* ================================================
   Ombra.io — Accessibility (WCAG 2.1 AA)
   ================================================
   Shared across all apps for consistent a11y support.
   Focus on: keyboard navigation, screen reader,
   high contrast under sunlight.
   ================================================ */

/* --- Focus indicators (keyboard navigation) --- */
*:focus-visible {
    outline: 3px solid #1B5E7B;
    outline-offset: 2px;
    border-radius: 4px;
}

/* MudBlazor button focus override */
.mud-button-root:focus-visible,
.mud-icon-button:focus-visible,
.mud-chip:focus-visible {
    outline: 3px solid #1B5E7B !important;
    outline-offset: 2px;
}

/* --- Skip to main content link --- */
.skip-to-main {
    position: absolute;
    top: -100px;
    left: 8px;
    z-index: 9999;
    padding: 8px 16px;
    background: #1B5E7B;
    color: white;
    border-radius: 0 0 8px 8px;
    font-weight: 600;
    text-decoration: none;
    transition: top 0.2s ease;
}

.skip-to-main:focus {
    top: 0;
}

/* --- Touch target minimum size (44x44px) --- */
.touch-target {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* --- Map grid cells — keyboard accessible --- */
.gc-ombrellone[role="button"] {
    cursor: pointer;
}

.gc-ombrellone[role="button"]:focus-visible {
    outline: 3px solid #1B5E7B;
    outline-offset: -2px;
    z-index: 10;
}

/* --- High contrast mode (prefers-contrast) --- */
@media (prefers-contrast: high) {
    .gc-libera { background: #ffffff !important; border: 2px solid #006400 !important; }
    .gc-prenotata { background: #ffffff !important; border: 2px solid #00008b !important; }
    .gc-occupata { background: #ffffff !important; border: 2px solid #8b4513 !important; }
    .gc-manutenzione { background: #ffffff !important; border: 2px solid #8b0000 !important; }
}

/* --- Reduce motion for vestibular disorders --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --- Screen reader only (visually hidden) --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Ensure minimum contrast for outdoor use --- */
.high-contrast-text {
    color: #1a1a1a;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.8);
}

/* ================================================
   Mobile Responsive Fixes
   ================================================ */

/* Riduce padding su mobile per evitare overflow orizzontale */
@media (max-width: 599px) {
    .mud-main-content {
        padding-left: 8px !important;
        padding-right: 8px !important;
        overflow-x: hidden;
    }

    .mud-breadcrumbs {
        padding-left: 4px !important;
        padding-right: 4px !important;
        font-size: 0.8rem;
    }

    /* MudGrid spacing ridotto su mobile */
    .mud-grid {
        margin: 0 !important;
    }

    .mud-grid > .mud-grid-item {
        padding: 4px !important;
    }

    /* Tabelle scrollabili su mobile */
    .mud-table {
        overflow-x: auto;
    }

    /* Fix overflow su MudPaper con padding largo */
    .mud-paper {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Dashboard header flex wrap su mobile */
    .d-flex.justify-space-between {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Flex containers con gap — riduci gap e forza wrap */
    .d-flex.gap-4 {
        gap: 8px !important;
        flex-wrap: wrap;
    }

    .d-flex.gap-3 {
        gap: 6px !important;
        flex-wrap: wrap;
    }

    .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    /* Ordini header actions — stack su mobile */
    .ordini-actions {
        width: 100%;
    }

    /* Ordini switch — compatto su mobile */
    .ordini-switch {
        margin: 0 !important;
    }
    .ordini-switch .mud-switch-label {
        display: none;
    }

    /* Mappa toolbar separatori — nascondi su mobile */
    .mappa-tb-sep {
        display: none;
    }

    /* Mappa numeric fields — compatti su mobile */
    .mappa-num-field {
        width: 75px;
        max-width: 75px;
    }

    /* Mappa toolbar — padding ridotto */
    .mappa-toolbar {
        padding: 8px !important;
    }

    /* Onboarding checklist step item */
    .mud-paper [style*="display: flex"] {
        flex-wrap: wrap;
    }
}

/* Tablet: leggera riduzione padding */
@media (min-width: 600px) and (max-width: 959px) {
    .mud-main-content {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

/* --- Mappa page: contenimento SVG su mobile --- */
@media (max-width: 959px) {
    .mappa-layout {
        flex-direction: column !important;
        height: auto !important;
        min-height: auto !important;
    }

    .mappa-panel-left,
    .mappa-panel-right {
        width: 100% !important;
        min-width: 0 !important;
        max-height: 200px;
    }

    .mappa-panel-center {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        min-height: 400px;
    }
}

/* Mappa numeric fields — dimensione default */
.mappa-num-field {
    width: 100px;
}

/* --- Analytics: heatmap e chip wrapping su mobile --- */
@media (max-width: 599px) {
    /* Forza flex-wrap su tutti i container flex della pagina analytics */
    .mud-chip-set {
        flex-wrap: wrap !important;
    }

    /* Heatmap grid container: scrollabile */
    [style*="grid-template-columns: repeat"] {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Riduce min-width delle label fisse nelle barre orarie */
    .mud-text-caption[style*="width: 70px"] {
        width: auto !important;
        min-width: 50px;
    }
}
