/* =========================================================================
 * Flow-Up "Remove by area" mode
 * Restyles the top-right toggle (#remove-by-area) inside .map-toolbar,
 * shows an instructional banner, and highlights the Leaflet.Draw toolbar
 * on the left while active.
 * ========================================================================= */

/* ---------------------------------------------------------------------------
 * Remove-by-area control — icon-only segment inside the map toolbar cluster.
 * Labels stay in the DOM (JS toggles hidden) but are visually clipped; the
 * button title / aria-label carry the accessible name.
 * ------------------------------------------------------------------------- */

.map-toolbar .map-control-btn--labeled,
.map-control-btn--labeled {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0;
    width: 40px;
    min-width: 40px;
    height: 40px;
    border-radius: 0;
    font-family: 'DM Sans', inherit;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.map-control-btn--labeled[hidden] {
    display: none;
}

/* Active: red segment + soft brightness pulse (outer ring clipped by toolbar) */
.map-toolbar .map-control-btn--labeled.active,
.map-control-btn--labeled.active {
    background: var(--error-color, #DC2626);
    color: #fff;
    border-color: transparent;
    box-shadow: none;
    animation: fu-area-btn-pulse 1.6s ease-in-out infinite;
}

.map-toolbar .map-control-btn--labeled.active:hover,
.map-control-btn--labeled.active:hover {
    background: #B91C1C;
    border-color: transparent;
    transform: none;
}

@keyframes fu-area-btn-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.14); }
}

/* Legacy keyframes kept so any cached CSS referencing them stays harmless */
@keyframes fu-area-btn-ring {
    0%   { box-shadow: none; }
    100% { box-shadow: none; }
}

/* ---------------------------------------------------------------------------
 * Instructional legend - sits inside `.map-controls` right above the
 * "Rimuovi per area" toggle so the explanation is visually tied to the button.
 * ------------------------------------------------------------------------- */

.fu-area-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    width: 240px;
    max-width: calc(100vw - 2rem);
    margin-left: auto; /* align with the right-anchored .map-controls column */
    background: var(--wq-ink, #0F172A);
    color: #fff;
    border-radius: var(--wq-r-lg, 12px);
    box-shadow: var(--wq-shadow-pop, 0 6px 24px rgba(15, 23, 42, 0.2), 0 2px 6px rgba(15, 23, 42, 0.08));
    font-family: 'DM Sans', inherit;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.35;
    /* Pop into view to make the connection with the toggle obvious */
    animation: fu-area-banner-in 220ms ease-out;
}

.fu-area-banner[hidden] {
    display: none;
}

.fu-area-banner__icon {
    color: #FCD34D;
    font-size: 0.95rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.fu-area-banner__text {
    flex: 1 1 auto;
    min-width: 0;
}

.fu-area-banner__close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: background 0.15s ease, transform 0.05s ease;
    margin-top: -2px;
}

.fu-area-banner__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.fu-area-banner__close:active {
    transform: scale(0.95);
}

@keyframes fu-area-banner-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------------------------
 * Leaflet.Draw toolbar (top-left): bigger, brighter, easier to spot
 * while the remove-by-area mode is active.
 * ------------------------------------------------------------------------- */

body.fu-area-active .leaflet-draw {
    margin-top: 1rem !important;
    margin-left: 1rem !important;
}

body.fu-area-active .leaflet-draw-toolbar {
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18);
    overflow: hidden;
}

body.fu-area-active .leaflet-draw-toolbar a {
    width: 36px;
    height: 36px;
    background-position: center;
    background-color: var(--bg-primary, #fff);
    border-color: var(--error-color, #DC2626) !important;
    border-width: 1px;
    border-style: solid;
    color: var(--text-primary, #0F172A);
    transition: background-color 0.15s ease, transform 0.05s ease;
}

body.fu-area-active .leaflet-draw-toolbar a:hover {
    background-color: #FEF2F2;
}

body.fu-area-active .leaflet-draw-toolbar a.leaflet-draw-toolbar-button-enabled,
body.fu-area-active .leaflet-draw-toolbar a.enabled {
    background-color: var(--error-color, #DC2626);
    color: #fff;
    box-shadow: inset 0 0 0 2px #fff;
    filter: invert(1);
}

/* Save / Cancel action bar (the buttons that appear during edit / draw) */
body.fu-area-active .leaflet-draw-actions {
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.22);
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
}

body.fu-area-active .leaflet-draw-actions a {
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #0F172A);
    font-weight: 600;
    border-color: var(--error-color, #DC2626);
    padding: 6px 12px;
}

body.fu-area-active .leaflet-draw-actions a:hover {
    background: #FEF2F2;
}

/* Initial attention pulse on the toolbar when the mode is just entered */
.leaflet-draw.fu-area-pulse {
    animation: fu-area-toolbar-pulse 0.85s ease-out 3;
}

@keyframes fu-area-toolbar-pulse {
    0%   { transform: scale(1);    filter: drop-shadow(0 0 0 rgba(220, 38, 38, 0.0)); }
    50%  { transform: scale(1.08); filter: drop-shadow(0 0 14px rgba(220, 38, 38, 0.6)); }
    100% { transform: scale(1);    filter: drop-shadow(0 0 0 rgba(220, 38, 38, 0.0)); }
}

/* ---------------------------------------------------------------------------
 * Dark mode tweaks
 * ------------------------------------------------------------------------- */

[data-theme="dark"] .fu-area-banner {
    background: #0B1220;
    border: 1px solid var(--wq-border-strong, #334155);
}

[data-theme="dark"] body.fu-area-active .leaflet-draw-toolbar a,
[data-theme="dark"] body.fu-area-active .leaflet-draw-actions a {
    background-color: var(--wq-surface, #0F172A);
    color: var(--wq-ink, #F8FAFC);
}

[data-theme="dark"] body.fu-area-active .leaflet-draw-toolbar a:hover,
[data-theme="dark"] body.fu-area-active .leaflet-draw-actions a:hover {
    background-color: rgba(220, 38, 38, 0.15);
}

/* ---------------------------------------------------------------------------
 * Mobile tweaks
 * ------------------------------------------------------------------------- */

@media (max-width: 640px) {
    .fu-area-banner {
        top: 0.5rem;
        max-width: calc(100% - 1rem);
        padding: 8px 10px;
        font-size: 0.78rem;
    }

    .map-control-btn--labeled {
        padding: 7px 10px;
        font-size: 0.78rem;
    }

    body.fu-area-active .leaflet-draw-toolbar a {
        width: 40px;
        height: 40px;
    }
}
