/* Lexend NON arriva piu' da fonts.googleapis.com: e' auto-ospitato in
   css/fonts.css, collegato dai template insieme al preload. Vedi
   docs/UI_PATTERNS.md. Non rimettere qui un @import verso un dominio terzo:
   comunicherebbe l'IP di ogni medico a quel fornitore. */

/* ============================================================================
   DESIGN TOKENS — RicettaSmart
   Fonte unica dei colori del design system. Vedi DESIGN.md per la guida d'uso.
   Esposti come utility Tailwind (bg-brand-600, text-ink, ...) via il
   tailwind.config inline in base.html.
   NOTA: questa prima passata è SOLO additiva (zero cambi visivi). I valori
   brand-* coincidono con la scala `indigo` di Tailwind oggi usata nei template,
   così la futura migrazione `indigo-*` → `brand-*` non altererà l'aspetto.
   ========================================================================== */
:root {
    /* Brand — scala indaco RicettaSmart ancorata a #3f51b9 (600).
       I due blu legacy entrano nella scala: #5d6cc6 = 500, #3f51b9 = 600. */
    --brand-50: #eef0fa;
    --brand-100: #e0e3f4;
    --brand-200: #c5cbeb;
    --brand-300: #a3acde;
    --brand-400: #7f8bd0;
    --brand-500: #5d6cc6;  /* ex .bg-blu / .text-blu */
    --brand-600: #3f51b9;  /* indaco primario RS */
    --brand-700: #36459c;
    --brand-800: #2f3b80;
    --brand-900: #2a3566;
    --brand-950: #1b2140;
    /* Alias storico: ora coincide col primario della scala */
    --brand-strong: var(--brand-600);

    /* Neutri / superfici (scala gray di Tailwind) */
    --page-bg: #f3f4f6;        /* gray-100 — sfondo body attuale */
    --surface: #ffffff;
    --surface-sunken: #f9fafb; /* gray-50 */
    --ink: #111827;            /* gray-900 — testo primario */
    --ink-soft: #374151;       /* gray-700 */
    --muted: #4b5563;          /* gray-600 — testo secondario, AA su bianco */
    --muted-soft: #6b7280;     /* gray-500 */
    --muted-faint: #9ca3af;    /* gray-400 — icone/placeholder tenui */
    --border: #e5e7eb;         /* gray-200 */
    --border-strong: #d1d5db;  /* gray-300 */

    /* Feedback (valori dalle scale Tailwind già in uso) */
    --success: #059669;        /* emerald-600 */
    --success-strong: #047857; /* emerald-700 */
    --success-bg: #ecfdf5;     /* emerald-50 */
    --success-line: #a7f3d0;   /* emerald-200 · hairline per superfici success tinte */
    --danger: #dc2626;         /* red-600 */
    --danger-strong: #b91c1c;  /* red-700 */
    --danger-bg: #fef2f2;      /* red-50 */
    --warning: #d97706;        /* amber-600 */
    --warning-strong: #b45309; /* amber-700 */
    --warning-bg: #fffbeb;     /* amber-50 */
    --info: var(--brand-600);

    /* Stati prescrizione — abbinare SEMPRE a icona/label (mai solo colore).
       Mappatura presa da ultime-prescrizioni-list.html (stato corrente). */
    --state-emessa: var(--success);   /* stato=1 · fa-circle-check */
    --state-annullata: var(--danger); /* stato=0 · fa-circle-xmark */
    --state-bozza: #9ca3af;           /* stato=2 · gray-400 · fa-circle-pause */
    /* --state-bianca (stato=3): da confermare prima di tokenizzare */
}

/* GENERAL STYLE */

.section-scrollable {  /* Le sezioni scrollabili usano overflow-y: auto */
    overflow-y: auto;
}

/* SEZIONE IMPOSTAZIONI */

.active-imp {
    color: var(--brand-strong);
    border-color: var(--brand-strong) !important;
}

ul#lista-impostazioni li a:hover {
    color: var(--brand-strong);
}

/* Nasconde la scrollbar mantenendo lo scroll (menu orizzontale su mobile) */
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

ul#abilita-operatori li {
    cursor: pointer;
    background-color: transparent;
    transition: all 0.2s ease-in-out;
}

ul#abilita-operatori li:hover {
    cursor: pointer;
    background-color: #cccccc5a;
    transition: all 0.2s ease-in-out;
}

/* SFONDO PILLS */

.pill {
    opacity: 0.3; /* in modo da non distrarre troppo il contenuto principale */
    width: 80px; /* dimensione esemplificativa */
    height: auto;
    transition: opacity 0.3s; /* transizione per un effetto più fluido */
    z-index: -1;
  }

  .pill:hover {
    opacity: 1; /* opacità al massimo quando il mouse è sopra */
    transition: opacity 0.3s;
  }

/* HELPER CLASSES */

.hidden {
    display: none;
}

.p-8 {
    padding: clamp(10px, 2.96vh, 2rem) !important;
}

/* COMPONENTS */

/* Popover informativo per hint di campo (field-info.html) */
.info-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 4px;
    color: var(--brand-500);
    background: transparent;
    border: none;
    border-radius: 9999px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: background 0.15s ease-in-out, color 0.15s ease-in-out;
    vertical-align: middle;
}

.info-trigger:hover,
.info-trigger[aria-expanded="true"] {
    background-color: var(--brand-50);
    color: var(--brand-600);
}

.info-popover {
    position: absolute;
    z-index: 50;
    top: calc(100% + 6px);
    left: 0;
    min-width: 240px;
    max-width: 320px;
    background: #ffffff;
    border: 1px solid var(--brand-200);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--ink);
    font-weight: 400;
    white-space: normal;
    text-transform: none;
}

.info-popover strong {
    color: var(--ink);
    font-weight: 600;
}

/* Rimuove i marker default di <details> per uno stile uniforme con chevron custom */
details > summary {
    list-style: none;
}

details > summary::-webkit-details-marker {
    display: none;
}

/* Link helper "Outbound" — apre in nuova tab una risorsa esterna utile per ottenere il valore di un campo.
   Visivamente discreto: sembra un link, non un bottone di submit. */
.btn-helper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: #ffffff;
    color: var(--muted);
    border: 1px solid var(--border-strong);
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.375rem 0.875rem;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    white-space: nowrap;
}

.btn-helper:hover {
    background-color: var(--brand-50);
    color: var(--brand-600);
    border-color: var(--brand-200);
}

.btn-helper i.fa-arrow-up-right-from-square {
    font-size: 0.7rem;
    opacity: 0.7;
}

.btn-helper:hover i.fa-arrow-up-right-from-square {
    opacity: 1;
}

/* Bottone X di chiusura su #sessione-feedback: visibile solo quando c'è contenuto */
#sessione-feedback [data-rs-dismiss-feedback] {
    display: none;
}
#sessione-feedback:has(#sessione-feedback-loader:not(.hidden)) [data-rs-dismiss-feedback],
#sessione-feedback:has(#sessione-feedback-body > *) [data-rs-dismiss-feedback] {
    display: inline-flex;
}

/* Loading state per bottoni durante una richiesta HTMX: htmx aggiunge da solo
   la classe .htmx-request all'elemento che emette la richiesta.
   ATTENZIONE: `pointer-events:none` blocca il secondo click del MOUSE, ma NON
   l'attivazione da tastiera (due Invio di fila partono lo stesso), e non vale
   quando l'hx-post sta su un <form> invece che sul bottone, perche' in quel caso
   la classe finisce sul form e questo selettore non lo prende. La protezione vera
   contro il doppio invio e' `hx-sync="this:drop"` sull'elemento che emette la
   richiesta (`hx-disabled-elt` NON esiste in htmx 1.9.2). Vedi HTMX_PATTERNS.md §21. */
button.htmx-request {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

/* L'icona fa-check viene sostituita da uno spinner durante la richiesta */
button.htmx-request i.fa-check {
    animation: rs-btn-spin 0.8s linear infinite;
}

button.htmx-request i.fa-check::before {
    content: "\f110"; /* fa-spinner Font Awesome 6 */
}

@keyframes rs-btn-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Tendina del periodo nelle Statistiche: mentre la pagina si ricarica l'icona
   del calendario diventa uno spinner (hx-indicator="closest label" sul select).
   Prima non c'era nessun segnale fra il cambio e l'arrivo dei numeri nuovi. */
label.htmx-request {
    opacity: 0.7;
}
label.htmx-request i.fa-calendar-day {
    animation: rs-btn-spin 0.8s linear infinite;
}
label.htmx-request i.fa-calendar-day::before {
    content: "\f110"; /* fa-spinner Font Awesome 6 */
}

/* Toast notification — usato da partials/components/alert-delete.html */
@keyframes rs-toast-in {
    from { opacity: 0; transform: translateX(110%); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes rs-toast-in-mobile {
    from { opacity: 0; transform: translateY(-110%); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes rs-toast-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(110%); }
}

.rs-toast {
    animation: rs-toast-in 0.3s ease-out;
}

@media (max-width: 640px) {
    .rs-toast { animation: rs-toast-in-mobile 0.3s ease-out; }
}

.rs-toast-out {
    animation: rs-toast-out 0.25s ease-in forwards;
}

@media (prefers-reduced-motion: reduce) {
    .rs-toast,
    .rs-toast-out {
        animation: none;
    }
}

/* Bottom sheet — su mobile il modal Note/Anamnesi di Nuova Prescrizione sale
   dal bordo inferiore stile app; da sm in su resta il dialog centrato. */
@keyframes rs-sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

@media (max-width: 639px) {
    .rs-bottom-sheet { animation: rs-sheet-up 0.28s cubic-bezier(0.32, 0.72, 0.33, 1); }
}

@media (prefers-reduced-motion: reduce) {
    .rs-bottom-sheet { animation: none; }
}

/* Zone di presa dello swipe-to-dismiss (maniglia + header dei sheet):
   disattivano i gesti nativi del browser (pull-to-refresh, pan) per i tocchi
   che iniziano qui, altrimenti il refresh ruba il drag dopo pochi px. I tap
   sugli elementi interni (es. la X) continuano a funzionare. */
[data-rs-sheet-grab] { touch-action: none; }

/* Badge "Raccomandato" per opzioni che è meglio lasciare attive (es. checkbox sessione) */
.badge-recommended {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 9999px;
    background: #d1fae5;
    color: #047857;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

/* Badge "Auto" per campi auto-compilati (codaslao, dataPwdTs) */
.badge-auto {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    padding: 1px 5px;
    border-radius: 9999px;
    background: var(--page-bg);
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

/* Stato disabilitato visuale per gruppi di campi (es. Credenziali Google quando i checkbox di sessione sono off) */
.fields-disabled {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.fields-disabled input,
.fields-disabled label,
.fields-disabled a {
    cursor: not-allowed;
}

.btn-success {
    background-color: #10b981;
    transition: all 0.2s ease-in-out;
    border-radius: 9999px;
    color: #fff;    
}

.btn-success:hover {
    background-color: #009160;
    transition: all 0.2s ease-in-out;
    border-radius: 9999px;
    color: #fff;
}

.btn-primary {
    background-color: var(--brand-500);
    transition: all 0.2s ease-in-out;
    border-radius: 9999px;
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--brand-600);
    transition: all 0.2s ease-in-out;
    border-radius: 9999px;
    color: #fff;
}

.btn-delete {
    background-color: #ef4444;
    transition: all 0.2s ease-in-out;
    border-radius: 9999px;
    color: #fff;
}

.btn-warning {
    background-color: #f59e0b;
    transition: all 0.2s ease-in-out;
    border-radius: 9999px;
    color: #fff;
}

.btn-warning:hover {
    background-color: #d97706;
    transition: all 0.2s ease-in-out;
    border-radius: 9999px;
    color: #fff;
}

.btn-delete:hover {
    background-color: #c12a2a;
    transition: all 0.2s ease-in-out;
    border-radius: 9999px;
    color: #fff;
}

.btn-cancel {
    background-color: var(--border-strong);
    transition: all 0.2s ease-in-out;
    border-radius: 9999px;
    color: #232323;
}

.btn-disabled {
    background-color: var(--border-strong);
    transition: all 0.2s ease-in-out;
    border-radius: 9999px;
    color: #232323;
}

.btn-cancel:hover {
    background-color: #b7b7b7;
    transition: all 0.2s ease-in-out;
    border-radius: 9999px;
    color: #232323;
}

.dataset-segment .dataset-segment-option {
    background-color: var(--border);
    color: var(--muted);
    transition: all 0.2s ease-in-out;
}

.dataset-segment label:hover .dataset-segment-option {
    background-color: var(--border-strong);
}

.dataset-segment input:checked + .dataset-segment-option {
    background-color: var(--brand-500);
    color: #ffffff;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.08);
}

.dataset-segment input:focus-visible + .dataset-segment-option {
    outline: 2px solid #93c5fd;
    outline-offset: 1px;
}

.btn-azioni:hover {
    transition: all 0.2s ease-in-out;
}

.btn-login {
    background-color: var(--brand-500);
    color: #fff;
    transition: all 0.2s ease-in-out;
    font-weight: 700;
}

.btn-login:hover {
    background-color: var(--brand-600);
    color: #fff;
    transition: all 0.2s ease-in-out;
    font-weight: 700;

}

/* DROPDOWN MENU */
.dropdown:focus-within .dropdown-content {
    display: block;
  }  

/* SPINNER */

#spinner {
    width: 50px;
    height: auto;
}

.htmx-indicator {
    opacity:0;
    transition: opacity 500ms ease-in;
    position: absolute;
    top: 20%;
    right: 50%;
}
.htmx-request .htmx-indicator{
    opacity:1;
}
.htmx-request.htmx-indicator{
    opacity:1;
}
   

/* TYPOGRAPHY */

.greeting p {
    font-size: clamp(14px, 1.85vh, 16px);
}

.month {
    white-space: nowrap;
}

#sessione {
    font-size: 12px;
    white-space: nowrap;
}

.session-alert {
    white-space: nowrap;

}

/* === Session pill (modern badge) === */
.rs-session-pill {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    padding: 0.3rem 0.55rem;
    border-radius: 0.625rem;
    font-size: 11px;
    line-height: 1;
    color: #fff;
    backdrop-filter: blur(4px);
    transition: background-color .25s ease, box-shadow .25s ease;
    overflow: hidden;
}
.rs-session-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    white-space: nowrap;
}
.rs-session-pill[data-rs-state="active"] {
    background: rgba(16, 185, 129, 0.18);
    box-shadow: inset 0 0 0 1px rgba(110, 231, 183, 0.35);
}
.rs-session-pill[data-rs-state="warning"] {
    background: rgba(245, 158, 11, 0.22);
    box-shadow: inset 0 0 0 1px rgba(252, 211, 77, 0.45);
}
.rs-session-pill[data-rs-state="expired"] {
    background: rgba(239, 68, 68, 0.22);
    box-shadow: inset 0 0 0 1px rgba(252, 165, 165, 0.45);
}

.rs-session-dot {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 0.55rem;
    width: 0.55rem;
    flex-shrink: 0;
}
.rs-session-dot-core {
    position: relative;
    display: inline-block;
    height: 0.45rem;
    width: 0.45rem;
    border-radius: 9999px;
    box-shadow: 0 0 6px currentColor;
}
.rs-session-dot-ping {
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    opacity: 0;
}
.rs-session-pill[data-rs-state="active"] .rs-session-dot-core { background: #34d399; color: #34d399; }
.rs-session-pill[data-rs-state="warning"] .rs-session-dot-core { background: #fbbf24; color: #fbbf24; }
.rs-session-pill[data-rs-state="expired"] .rs-session-dot-core { background: #f87171; color: #f87171; }

.rs-session-pill[data-rs-state="warning"] .rs-session-dot-ping {
    background: #fbbf24;
    animation: rsSessionPulse 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}
.rs-session-pill[data-rs-state="expired"] .rs-session-dot-ping {
    background: #f87171;
    animation: rsSessionPulse 1.6s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes rsSessionPulse {
    0%   { transform: scale(1);   opacity: 0.75; }
    80%  { transform: scale(2.4); opacity: 0; }
    100% { transform: scale(2.4); opacity: 0; }
}

/* Variante "quiet" della pill: promemoria password Sistema TS.
   La sessione TS ha un countdown reale (ambra/rosso + ping pulsante); la
   scadenza password e` invece una STIMA, quindi niente colori di stato e
   niente pulsazione — solo una tinta neutra sul fondo brand della sidebar. */
.rs-session-pill--quiet {
    background: rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}
.rs-session-pill--quiet .rs-session-icon {
    flex-shrink: 0;
    font-size: 10px;
    opacity: 0.85;
}
/* Top bar mobile: spazio conteso con logo, badge sessione e avatar. 16ch fa
   entrare per intero il caso a un prescrittore ("GDP da rinnovare"); con piu`
   prescrittori tronca, e il testo completo resta nel `title` e nel promemoria
   in dashboard. */
.rs-session-pill--quiet .rs-session-time {
    max-width: 16ch;
}
@media (min-width: 640px) {
    .rs-session-pill--quiet .rs-session-time {
        max-width: none;
    }
}

.rs-session-title {
    display: block;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    opacity: 0.65;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
.rs-session-sigla {
    font-weight: 700;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}
.rs-session-prefix {
    opacity: 0.7;
    flex-shrink: 0;
}
.rs-session-time {
    opacity: 0.85;
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.rs-session-pill[data-rs-state="warning"] .rs-session-time {
    opacity: 1;
    font-weight: 600;
}
@media (max-width: 639px) {
    /* Top bar mobile: i badge di stato (sessione + reminder password) sono pill
       compatte a stadio pieno. Il titolo "Stato Sessione" e` gia` nascosto su
       mobile, quindi fissiamo un'altezza uniforme (28px) e centriamo la row.
       Desktop (sidebar verticale, col titolo) invariato. */
    .rs-session-pill {
        height: 1.75rem;
        justify-content: center;
        border-radius: 9999px;
    }
    /* Ordine top bar mobile: logo (estrema sinistra) · badge di stato (centro) ·
       avatar operatore (estrema destra). Le auto-margin distribuiscono lo spazio
       libero; l'avatar (#sigla_op_attivo) va per ultimo. Solo mobile: su desktop
       la sidebar e` verticale e questo blocco non si applica. */
    #sidebar > .rs-session-pill,   /* reminder password TS (pill figlia diretta) */
    #mobile-badge-session {        /* wrapper badge sessione */
        order: 1;
        margin-left: auto;
    }
    #sigla_op_attivo {
        order: 2;
        margin-left: auto;
    }
    /* Touch target ~44px per il badge riepilogo senza cambiarne l'altezza
       visiva: estende l'area cliccabile solo in verticale (nessun overlap coi
       vicini orizzontali). overflow: visible perche' il pseudo esce dalla pill. */
    #mobile-session-summary {
        overflow: visible;
    }
    #mobile-session-summary::before {
        content: "";
        position: absolute;
        inset: -8px 0;
    }
}
/* Loading bar indeterminata: recupero automatico ID-Sessione in corso
   (card verde del modal Rinnova). Segnala "in corso" senza dedline finta e
   scoraggia click ulteriori. Sotto prefers-reduced-motion diventa statica. */
.rs-progress-track {
    position: relative;
    overflow: hidden;
}
.rs-progress-indeterminate {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 40%;
    border-radius: 9999px;
    animation: rsProgressSlide 1.4s ease-in-out infinite;
}
@keyframes rsProgressSlide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}
@media (prefers-reduced-motion: reduce) {
    .rs-progress-indeterminate {
        animation: none;
        width: 100%;
        transform: none;
        opacity: 0.6;
    }
}

/* .rs-pwdts-action e' il link del promemoria password TS: stesso aspetto, classe
   diversa. Non unificarle: .rs-session-action e' il bersaglio di una guida del tour
   (welcome_tour.py) e deve corrispondere a UN solo elemento in pagina. */
.rs-session-action,
.rs-pwdts-action {
    margin-left: auto;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.45rem;
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.18);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    color: #fff;
    transition: background-color .15s ease;
}
.rs-session-action:hover,
.rs-pwdts-action:hover { background: rgba(255, 255, 255, 0.32); }
/* Badge PRO: una sola forma in tutta l'app (14/10/2026), tonda con la sola stellina.
   Il nome per gli screen reader sta in <span class="sr-only">PRO</span> dentro il badge.
   Colori dai token d'avviso; il bordo tenue lo stacca anche dalle superfici bianche. */
.rs-pro-badge {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 9999px;
    background: var(--warning-bg);
    color: var(--warning-strong);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warning-strong) 22%, transparent);
    font-size: 0.625rem;
    line-height: 1;
    vertical-align: middle;
}
/* Nelle righe minuscole (pillola dello stato sessione). */
.rs-pro-badge-sm {
    width: 1rem;
    height: 1rem;
    font-size: 0.5rem;
}

/* === Sidebar footer action buttons === */
.rs-side-act {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.35rem 0.25rem 0.3rem;
    border-radius: 0.5rem;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease, transform .15s ease;
    flex: 1 1 0;
    min-width: 0;
}
.rs-side-act:hover {
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
    transform: translateY(-1px);
}
.rs-side-act i { font-size: 13px; line-height: 1; }
.rs-side-act-label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
    opacity: 0.85;
}
.rs-side-act-logout { color: rgba(252, 165, 165, 0.85); }
.rs-side-act-logout:hover { color: #fecaca; background: rgba(239, 68, 68, 0.15); }
.rs-side-act-form { flex: 1 1 0; display: flex; min-width: 0; }
.rs-side-act-form button { width: 100%; }

/* === Helper tabs (storico paziente in nuova-prescrizione) === */
.rs-tab {
    color: var(--muted-soft);
    background: transparent;
    transition: background-color .15s ease, color .15s ease;
    cursor: pointer;
}
.rs-tab:hover {
    color: var(--ink-soft);
}
.rs-tab-active {
    background-color: var(--brand-500);
    color: #ffffff;
}
.rs-tab-active:hover {
    color: #ffffff;
}

/* === Input group filtri (filtro-combobox-group.html) === */
/* Stato attivo: il gruppo segnala che la lista è filtrata. */
.rs-filter-group-active {
    border-color: var(--brand-500);
}
.rs-filter-group-active .rs-filter-group-label {
    background-color: var(--brand-50);
    color: var(--brand-600);
    border-color: var(--brand-500);
}
/* La tendina del combobox interno NON ha regole CSS dedicate: la geometria
   (position:fixed, top/left/width/max-height) la imposta inline il JS in
   main.js — fixed per uscire dall'overflow-hidden dei card modal, larghezza
   ≥ campo per leggere le forme lunghe, altezza clampata allo spazio visibile
   (tastiera mobile inclusa via visualViewport). */

/* === Sidebar nav items === */
.rs-nav-item {
    color: rgba(255, 255, 255, 0.85);
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.rs-nav-item:hover {
    background-color: var(--brand-600);
    color: #fff;
}
/* CTA Prescrivi: outline + bold per emphasis sottile */
.rs-nav-cta {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.40);
}
.rs-nav-cta i { font-size: 15px; }
.rs-nav-cta:hover {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.60);
    background-color: var(--brand-600);
}
/* Active state: pagina corrente */
.rs-nav-item.is-active {
    background-color: var(--brand-600);
    color: #fff;
}
.rs-nav-item.is-active .sidebar-text { font-weight: 700; }
.rs-nav-cta.is-active {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.60);
}


#current-date {
    white-space: nowrap;
}

.paziente-col {
    padding: 5px;
    font-size: 14px;
}





/* NUOVA PRESCRIZIONE */

.quantita {
    width: 50px !important;
}

.inputAIC {
    width: 100px !important;
    text-align: center;
}


/* FORM ANAGRAFICA PAZIENTE */

#anagrafica-paziente input, #anagrafica-paziente select {
    border: 1px solid #cccccc;
    border-radius: 10px;
}

#anagrafica-paziente td {
    cursor: pointer;
}

/* FORM IMPOSTAZIONI GENERALI */
#form-imp-generali input, #form-imp-generali select {
    border: 1px solid #cccccc;
    border-radius: 10px;
}

/* FORM IMPOSTAZIONI SICUREZZA */
#form-imp-sicurezza input, #form-imp-sicurezza select {
    border: 1px solid #cccccc;
    border-radius: 10px;
}

/* FORM IMPOSTAZIONI OPERATORI
   Regola legacy rimossa: tutti gli input/select del form usano `outline-1 outline-gray-300`
   (utility Tailwind) come bordo. Mantenere `border: 1px + border-radius: 10px` qui
   sovrascriveva classi Tailwind tipo `rounded-l-md` su input-group con suffix (es. userpop_local @gmail.com). */

label {
    white-space: nowrap;
}

/* Default border + radius per input/select/textarea senza styling Tailwind esplicito.
   Nota: `border-radius` qui copre tutti e 4 gli angoli — per input-group con suffix
   (es. userpop_local + @gmail.com) usare `rounded-l-md` + `rounded-r-none` espliciti
   per resettare gli angoli destri (le classi Tailwind hanno specificità class > tag). */
input, select, textarea {
    border: 1px solid #cccccc;
    border-radius: 0.375rem; /* = rounded-md Tailwind */
}

#operatore-row {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#operatore-row:hover {
    cursor: pointer;
    background-color: #cccccc5a;
    transition: all 0.2s ease-in-out;
}

#posologia-row {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#posologia-row:hover {
    cursor: pointer;
    background-color: #cccccc5a;
    transition: all 0.2s ease-in-out;
}

#nuovo-operatore-row {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#nuovo-operatore-row:hover {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#nuova-posologia-row {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#nuova-posologia-row:hover {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#nuovo-farmaco-row {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#nuovo-farmaco-row:hover {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#farmaco-row {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#farmaco-row:hover {
    cursor: pointer;
    background-color: #cccccc5a;
    transition: all 0.2s ease-in-out;
}

.input-like-txt {
    background-color: transparent;
    border: none !important;
    width: auto;
}

.input-like-txt:focus, .input-like-txt:active {
    background-color: transparent;
    border: none !important;
    width: auto;
    outline: none !important;
    box-shadow: none !important;
}

/* WELCOME MODAL */


@media (min-width: 640px) {
    .welcome-modal-card {
        max-height: calc(100vh - 2rem);
    }
}

/* ANIMATIONS AND TRANSITIONS */

.htmx-fade {
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
}

.htmx-fade.htmx-added {
    opacity: 0;
}

/* TABLES */
      
.resizer {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 4px;
    cursor: col-resize;
    user-select: none;
}

table {
    table-layout: fixed; /* Imposto table-layout fixed per avere un controllo migliore sulle colonne */
}

/* SIDEBAR */

/*.sidebar-container {
    background-color: var(--brand-500);
} */

.sidebar {
    position: sticky;      /* o `fixed` se vuoi staccarla completamente dal flusso */
    top: 0;                /* punto di “aggancio” in alto */
    height: 100vh;         /* sempre alta quanto la finestra */
    overflow-y: auto;      /* scroll interno, se ti servono menù lunghi */
    transition: all 0.5s ease-in-out;
}

span.sidebar-text {
    font-size: 15px;
}

li.sidebar-item a i {
    text-align: center;
}

/*.icon-imp {
    font-size: clamp(14px, 1.6vh, 18px);
}*/

li.sidebar-item {
    white-space: nowrap;
}

li.sidebar-item span {
    white-space: nowrap;
}

li.sidebar-item a:hover {
    background-color: var(--brand-600);
    border-radius: 9999px;
}

.sidebar-text {
    font-size: clamp(14px, 1.48vh, 16px);
}

.sidebar.collapsed {
  width: 4rem !important;
}
.sidebar.collapsed .sidebar-text, .sidebar.collapsed .hide-element {
    opacity: 0;
    pointer-events: none; /* Evita interazioni indesiderate */
}

.sidebar.collapsed .hide-logo {
    display: none;
}

/* Quando la sidebar è espansa, il testo è visibile */
.sidebar:not(.collapsed) .sidebar-text,
.sidebar:not(.collapsed) .hide-logo,
.sidebar:not(.collapsed) .hide-element {
    opacity: 1;
}

.sidebar-text, .hide-logo, .hide-element {
    transition: opacity 0.3s ease-in-out; /* Rende più fluido il cambio di opacità */
}

.sidebar-middle.collapsed .hide-element {
    display: none;
}

.sidebar {
  transition: all 0.5s;
}

@media (min-width: 640px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: visible;
  }
  /* Le pillole (licenza, sessione, promemoria password) hanno overflow:hidden, che
     in colonna flex toglie l'altezza minima: senza questo, a corto di spazio, si
     schiacciavano e il testo veniva tagliato. */
  #sidebar .rs-session-pill {
    flex-shrink: 0;
  }
}

/* Sidebar su schermo largo e basso (portatili 1280x720 / 1366x768 col browser aperto,
   viewport ~631-650px): stessi elementi, spazi piu' stretti, cosi' non scorre in
   verticale e «Medici Prescrittori» diventa «Prescrittori» su una riga. */
@media (min-width: 640px) and (max-height: 760px) {
  #sidebar .rs-side-spazio { display: none; }
  /* Fra le voci c'erano space-y-1 e gap-1 sommati (8px). */
  #navDesktop > ul { row-gap: 3px; }
  #navDesktop > ul > li { margin-top: 0; height: 1.75rem; }
  #navDesktop > ul > li > *,
  #sidebar .rs-side-gestione > * {
    height: 1.75rem;
    padding-top: 0;
    padding-bottom: 0;
  }
  #sidebar .rs-side-gestione { margin-top: 2px; }
  #sidebar .rs-side-medici { display: none; }
  /* Mini-pannello operatore */
  #mini-panel > :first-child { padding-top: 0.375rem; padding-bottom: 0.25rem; }
  #mini-panel > :nth-child(2) { padding-top: 0.375rem; padding-bottom: 0.375rem; }
  #sidebar-operatore-avatar-shell { height: 1.75rem; width: 1.75rem; margin-bottom: 0.25rem; }
  #current-time { font-size: 1.125rem; }
  #mini-panel .rs-side-act { padding: 0.25rem 0.25rem 0.2rem; }
  /* Licenza e pillole sessione */
  #sidebar > a.rs-session-pill { margin-bottom: 0.25rem; }
  #mobile-badge-session { margin-top: 0.25rem; }
  #mobile-badge-session > :first-child { gap: 0.25rem; }
}

/* Stato espanso: spazio a sinistra del testo */
.sidebar a .sidebar-text {
    /*margin-left: 0.75rem;  spazio che altrimenti forniva il gap */
    transition: margin-left 0.5s ease-in-out, opacity 0.3s ease-in-out;
  }

 /*@media (max-width: 1024px) {
   .sidebar {
      width: 4rem !important;
    }
    .sidebar .sidebar-text,
    .sidebar .hide-element {
      opacity: 0 !important;
      pointer-events: none;
      transition: opacity 0.3s ease-in-out;
    }
    .sidebar .hide-logo {
      display: none !important;
    }
  }*/

/* ALPHABET NAV */

#alpha-list {
    gap: clamp(0.5px, 0.2vh, 6px);
}

@media (min-width: 1280px) {
    #alpha-list {
        justify-content: space-evenly;
        height: 100%;
    }
}

/* Controlli circolari condivisi: pulsante "mostra tutti" (eraser) + lettere.
   width+height espliciti uguali (non aspect-ratio) garantiscono il cerchio
   perfetto: così il glifo non può allungare il box in un'ellisse. Dimensione
   fluida via clamp(), legata all'altezza viewport come prima. */
#alpha-list > li > a,
#alpha-list > li > button {
    display: grid;
    place-items: center;
    width: clamp(18px, 2.4vh, 26px);
    height: clamp(18px, 2.4vh, 26px);
    margin-inline: auto;
    font-size: clamp(10px, 1.2vh, 14px);
    line-height: 1;
    border-radius: 50%;
    transition: background-color .15s ease, color .15s ease,
                transform .15s cubic-bezier(0.22, 1, 0.36, 1), box-shadow .15s ease;
}

/* Hover: ingrandimento tattile + tinta. Lo zoom vale per tutti i cerchi, il
   colore è specifico (lettere = brand, eraser = danger). */
#alpha-list > li > a:hover,
#alpha-list > li > button:hover {
    transform: scale(1.2);
}
#alpha-list li.alpha-list-item a:not(.alpha-active):hover {
    background-color: var(--brand-100);
    color: var(--brand-700);
}
#alpha-list > li:first-child > button:hover {
    background-color: var(--danger-bg);
    color: var(--danger-strong);
}

/* Lettera selezionata: pieno indaco; l'id alza la specificità così resta
   evidenziata anche col cursore sopra (prende comunque il pop dimensionale). */
#alpha-list .alpha-active {
    background-color: var(--brand-600);
    color: #fff;
}

/* prefers-reduced-motion: niente zoom, solo cambio colore. */
@media (prefers-reduced-motion: reduce) {
    #alpha-list > li > a,
    #alpha-list > li > button {
        transition: background-color .15s ease, color .15s ease;
    }
    #alpha-list > li > a:hover,
    #alpha-list > li > button:hover {
        transform: none;
    }
}

/* PRESCRIZIONI NAV */

li.ricette-list-item {
    padding: 3px 8px;
    border-radius: 10px;
    transition: background 0.2s ease-in-out;
    cursor: pointer;
}

li.ricette-list-item:hover {
    background-color: #cccccc9d;
    border-radius: 10px;
    padding: 3px 8px;
    transition: background 0.2s ease-in-out;
    cursor: pointer;
}

.ricette-list-item.active {
    background-color: #cccccc9d !important;
  }

/* STATISTICHE */

#container-statistiche {
    height: 100%;
    overflow-y: auto;
    padding: 1rem;
    box-sizing: border-box;
}

/* ALERT */

#alert-modal {
    transition: opacity 0.3s ease;
}

.opacity-0 {
    opacity: 0;
}

/* ACCORDION sezioni in form-prescrittore e form-operatore.
   La <summary> ha gia` -mx-4 -mt-4 (Tailwind) per estendere header+hover ai
   bordi top+laterali del wrapper card (bg-slate-50, p-4). Pero` quando il
   <details> e` CHIUSO, il padding-bottom del wrapper resta visibile sotto
   come banda slate-50 NON cliccabile. Qui aggiungiamo state-aware:
   - chiuso: summary copre anche il bottom (margin-bottom: -1rem) e diventa
     completamente arrotondato per matchare il wrapper card.
   - aperto: regola non si applica, summary resta come header con rounded-t
     e il contenuto interno occupa lo spazio sotto.
   Match sia `tour-section-*` (prescrittore) sia `accordion-*` (operatore). */
details[id^="tour-section-"]:not([open]) > summary,
details[id^="accordion-"]:not([open]) > summary {
    margin-bottom: -1rem;
    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
}

/* === Lista Prescrizioni: KPI strip + chip filters di stato ===
   Card non cliccabili (informative). I colori richiamano i badge stato
   già usati in prescrizione-list-row.html per continuità visiva. */

/* Chip filters: outline neutro, attivo = sfondo pieno colorato */
.rs-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: 9999px;
    background: #fff;
    border: 1px solid var(--border-strong);
    color: var(--ink-soft);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
    white-space: nowrap;
}
.rs-chip:hover {
    background: var(--page-bg);
    border-color: var(--muted-faint);
}
.rs-chip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    padding: 0 0.35rem;
    height: 1.1rem;
    border-radius: 9999px;
    background: var(--border);
    color: var(--ink-soft);
    font-size: 0.7rem;
    font-weight: 600;
}
/* Stato attivo: per ogni stato un colore coerente con la KPI / badge riga */
.rs-chip-active {
    color: #fff;
    border-color: transparent;
}
.rs-chip-active .rs-chip-count {
    background: rgba(255, 255, 255, 0.28);
    color: #fff;
}
.rs-chip-tutte.rs-chip-active     { background: var(--brand-600); }
.rs-chip-emesse.rs-chip-active    { background: #059669; }
.rs-chip-bozze.rs-chip-active     { background: var(--muted-soft); }
.rs-chip-bianche.rs-chip-active   { background: #2563eb; }
.rs-chip-annullate.rs-chip-active { background: #dc2626; }

/* === Selettore periodo (lista prescrizioni) === */
.rs-presc-period-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    width: 9.5rem;
    max-width: 9.5rem;
}
@media (min-width: 640px) {
    .rs-presc-period-wrap {
        width: auto;
        max-width: none;
        min-width: 13rem;
    }
}
.rs-presc-period-icon {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--brand-500);
    font-size: 0.85rem;
    pointer-events: none;
}
.rs-presc-period-caret {
    position: absolute;
    right: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-soft);
    font-size: 0.7rem;
    pointer-events: none;
    transition: transform .12s ease, color .12s ease;
}
.rs-presc-period-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 2.1rem;
    border: 1px solid var(--border-strong);
    border-radius: 0.5rem;
    background: #fff;
    font-size: 0.85rem;
    color: var(--ink);
    line-height: 1.2;
    cursor: pointer;
    transition: border-color .12s ease, box-shadow .12s ease, background-color .12s ease;
    /* Forza il testo a non andare sotto la freccia anche su iOS */
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}
.rs-presc-period-select:hover {
    border-color: var(--muted-faint);
    background: var(--surface-sunken);
}
.rs-presc-period-select:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}
.rs-presc-period-wrap:focus-within .rs-presc-period-caret {
    transform: translateY(-50%) rotate(180deg);
    color: var(--brand-600);
}

/* Allinea altezza select periodo e input ricerca. Setto un height esplicito
   con box-sizing: border-box: il padding y interno smette di contare per
   l'altezza esterna, cosi` i due controlli restano sempre identici. */
.rs-presc-period-select,
#cerca-prescrizioni {
    box-sizing: border-box;
    height: 2.25rem;
}
@media (max-width: 639px) {
    .rs-presc-period-select,
    #cerca-prescrizioni {
        height: 2rem;
    }
}

/* Mobile: compatta select periodo, chips e ricerca per dare piu` spazio
   alla lista delle prescrizioni. */
@media (max-width: 639px) {
    .rs-presc-period-select {
        padding: 0.4rem 1.6rem 0.4rem 1.85rem;
        font-size: 0.75rem;
        border-radius: 0.4rem;
    }
    .rs-presc-period-icon {
        left: 0.55rem;
        font-size: 0.75rem;
    }
    .rs-presc-period-caret {
        right: 0.55rem;
        font-size: 0.6rem;
    }
    /* Chips su una sola riga con scroll orizzontale invisibile */
    #chips-stato {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.3rem;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    #chips-stato::-webkit-scrollbar { display: none; }
    .rs-chip {
        padding: 0.25rem 0.55rem;
        font-size: 0.72rem;
        gap: 0.3rem;
        flex-shrink: 0;
    }
    .rs-chip-count {
        font-size: 0.62rem;
        min-width: 1.15rem;
        height: 0.95rem;
        padding: 0 0.3rem;
    }
    /* Input search compatto */
    #cerca-prescrizioni {
        padding-top: 0.4rem;
        padding-bottom: 0.4rem;
        padding-left: 2.1rem;
        padding-right: 0.6rem;
        font-size: 0.78rem;
        border-radius: 0.4rem;
    }
    #cerca-prescrizioni + i,
    .relative > .fa-search {
        font-size: 0.78rem;
    }
}

/* === Lista Prescrizioni moderna: card-row in container flex-col === */
.rs-presc-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* "Oscura dati": sfoca i campi sensibili (CF, telefono, email, cognome) quando
   il contenitore #pazienti-list ha la classe .data-protected. Reveal-on-hover sul
   singolo campo per consultarlo al volo. La classe è gestita in lista-pazienti.html. */
#pazienti-list.data-protected [data-sensitive="true"] {
    filter: blur(4px);
    transition: filter .15s ease;
    user-select: none;
    cursor: default;
}
#pazienti-list.data-protected [data-sensitive="true"]:hover,
#pazienti-list.data-protected [data-sensitive="true"]:focus-within {
    filter: blur(0);
    user-select: auto;
}
.rs-presc-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease, transform .12s ease;
    min-width: 0;
}
.rs-presc-item:hover,
.rs-presc-item:focus-visible {
    background: var(--surface-sunken);
    border-color: var(--border-strong);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    outline: none;
}
.rs-presc-item:active { transform: scale(0.997); }

.rs-presc-item-disabled {
    background: var(--surface-sunken);
    cursor: default;
    color: var(--muted-faint);
}
.rs-presc-item-disabled:hover {
    background: var(--surface-sunken);
    border-color: var(--border);
    box-shadow: none;
}

/* Data — colonna stretta tipografica */
.rs-presc-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 2.6rem;
    padding: 0.15rem 0.4rem;
    border-radius: 0.4rem;
    background: var(--page-bg);
    line-height: 1.05;
}
.rs-presc-date-day {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
}
.rs-presc-date-mon {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.rs-presc-date-year {
    font-size: 0.6rem;
    color: var(--muted-faint);
    margin-top: 0.05rem;
}

/* Body paziente */
.rs-presc-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.rs-presc-name {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    min-width: 0;
}
.rs-presc-cognome {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rs-presc-nome {
    font-size: 0.92rem;
    color: var(--ink-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rs-presc-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.72rem;
    color: var(--muted-soft);
    line-height: 1.1;
}
.rs-presc-meta i { margin-right: 0.2rem; opacity: 0.7; }
.rs-presc-op,
.rs-presc-nrbe {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Stato — badge moderno */
.rs-presc-stato {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}
.rs-presc-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    border: 1px solid transparent;
    white-space: nowrap;
}
.rs-presc-badge i { font-size: 0.7rem; }
.rs-presc-badge-emessa    { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.rs-presc-badge-annullata { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.rs-presc-badge-bianca    { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.rs-presc-badge-bozza     { background: var(--page-bg); color: var(--muted); border-color: var(--border-strong); }

/* Loader infinite-scroll */
.rs-presc-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    color: var(--muted-soft);
    font-size: 0.8rem;
}

/* Empty state */
.rs-presc-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 2.5rem 1rem;
    color: var(--muted-soft);
    text-align: center;
}
.rs-presc-empty i {
    font-size: 2rem;
    color: var(--border-strong);
    margin-bottom: 0.3rem;
}
.rs-presc-empty p {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin: 0;
}
.rs-presc-empty-hint {
    font-size: 0.78rem;
    color: var(--muted-faint);
}

/* Icona paziente accanto al cognome */
.rs-presc-pz-icon {
    flex-shrink: 0;
    width: 1.35rem;
    height: 1.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: var(--brand-100);
    color: var(--brand-700);
    font-size: 0.7rem;
    margin-right: 0.15rem;
}

/* Chevron orientato verso il basso (down quando chiuso, up quando aperto) */
.rs-presc-chevron {
    color: var(--muted-faint);
    font-size: 0.75rem;
    transition: transform .18s ease, color .12s ease;
}
.rs-presc-item:hover .rs-presc-chevron { color: var(--muted); }
.rs-presc-item[aria-expanded="true"] .rs-presc-chevron {
    transform: rotate(180deg);
    color: var(--brand-700);
}

/* Container row che ingloba item header + accordion */
.rs-presc-row {
    display: flex;
    flex-direction: column;
}
.rs-presc-row + .rs-presc-row { margin-top: 0.25rem; }

/* Quando l'accordion è aperto, l'header perde il radius inferiore per
   "fondersi" visivamente con il pannello sottostante */
.rs-presc-item[aria-expanded="true"] {
    background: var(--surface-sunken);
    border-color: var(--border-strong);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
}

/* Accordion: pannello sotto l'item che ospita la preview */
.rs-presc-accordion {
    background: #fff;
    border: 1px solid var(--border-strong);
    border-top: none;
    border-bottom-left-radius: 0.6rem;
    border-bottom-right-radius: 0.6rem;
    padding: 0.75rem 0.9rem 0.9rem;
    animation: rsPrescAccordionIn .18s ease-out;
}
@keyframes rsPrescAccordionIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Preview header: NRBE + bottone "Apri prescrizione" */
.rs-presc-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--border);
}
.rs-presc-preview-nrbe {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--muted);
}
.rs-presc-preview-nrbe i { color: var(--muted-faint); }
.rs-presc-preview-label { font-weight: 500; }
.rs-presc-preview-value {
    font-weight: 700;
    color: var(--ink);
    font-family: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, monospace;
    font-size: 0.78rem;
}
.rs-presc-preview-open {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32rem 0.7rem;
    border-radius: 0.4rem;
    background: var(--brand-600);
    color: #fff !important;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: background-color .12s ease, transform .08s ease;
    flex-shrink: 0;
    /* Sempre a destra, anche quando manca il blocco NRBE a sinistra
       (in flex con space-between un unico figlio resterebbe a sinistra). */
    margin-left: auto;
}
.rs-presc-preview-open:hover { background: var(--brand-700); }
.rs-presc-preview-open:active { transform: scale(0.97); }
.rs-presc-preview-open i { font-size: 0.7rem; }

/* Titolo sezione "Farmaci prescritti" */
.rs-presc-preview-section-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.4rem;
}
.rs-presc-preview-section-title i { color: var(--brand-500); }
.rs-presc-preview-count {
    margin-left: auto;
    background: var(--brand-50);
    color: var(--brand-700);
    padding: 0.1rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
}

/* Lista farmaci */
.rs-presc-farmaci {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.rs-presc-farmaco {
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-left: 3px solid var(--brand-500);
    border-radius: 0.4rem;
    padding: 0.45rem 0.6rem;
}
.rs-presc-farmaco-main {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.rs-presc-farmaco-nome {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink);
    flex: 1;
    min-width: 0;
    word-break: break-word;
}
.rs-presc-farmaco-q {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--brand-700);
    background: var(--brand-50);
    padding: 0.05rem 0.4rem;
    border-radius: 0.25rem;
    flex-shrink: 0;
}
.rs-presc-farmaco-meta {
    margin-top: 0.2rem;
    font-size: 0.74rem;
    color: var(--muted-soft);
    line-height: 1.3;
}
.rs-presc-farmaco-diag {
    margin-top: 0.2rem;
    font-size: 0.72rem;
    color: var(--muted-faint);
}
.rs-presc-farmaco-diag i { margin-right: 0.2rem; opacity: 0.7; }

/* Preview certificato: accent verde-acqua per distinguere dai farmaci */
.rs-presc-farmaco-cert {
    border-left-color: #14b8a6;
}

/* Avatar paziente (sostituisce il riquadro data nelle card paziente) */
.rs-paz-avatar {
    flex-shrink: 0;
    width: 2.4rem;
    height: 2.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: linear-gradient(135deg, var(--brand-100) 0%, var(--brand-200) 100%);
    color: var(--brand-700);
    font-size: 1rem;
}
/* Box laterale con data ultima operazione */
.rs-paz-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
}
.rs-paz-lastop {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    color: var(--muted-faint);
    white-space: nowrap;
}
.rs-paz-lastop i { font-size: 0.7rem; }
@media (max-width: 640px) {
    .rs-paz-avatar { width: 2rem; height: 2rem; font-size: 0.85rem; }
    .rs-paz-lastop { display: none; }
}

/* Azioni rapide nel preview paziente: griglia di bottoni */
.rs-paz-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.8rem;
}
@media (min-width: 640px) {
    .rs-paz-actions {
        grid-template-columns: repeat(9, minmax(0, 1fr));
    }
}
.rs-paz-action {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.55rem 0.4rem;
    border-radius: 0.5rem;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    color: var(--ink-soft);
    text-decoration: none !important;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease, transform .08s ease, color .12s ease;
}
.rs-paz-action i { font-size: 1rem; color: var(--brand-700); }
.rs-paz-action:hover {
    background: var(--brand-50);
    border-color: var(--brand-200);
}
.rs-paz-action:active { transform: scale(0.97); }
.rs-paz-action-prescrivi { background: var(--brand-50); border-color: var(--brand-200); }
.rs-paz-action-prescrivi:hover { background: var(--brand-100); border-color: var(--brand-300); }
.rs-paz-action-chat i { color: #16a34a; }
.rs-paz-action-chat:hover { background: #dcfce7; border-color: #86efac; }
.rs-paz-action-elimina i { color: #dc2626; }
.rs-paz-action-elimina:hover { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.rs-paz-action-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: auto;
}
.rs-paz-action-disabled:hover { background: var(--surface-sunken); border-color: var(--border); }

/* Pallino indicatore "note presenti" sul bottone Note dell'accordion paziente. */
.rs-paz-action-dot {
    position: absolute;
    top: 0.3rem;
    right: 0.35rem;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 9999px;
    background: #ef4444;
    box-shadow: 0 0 0 2px var(--surface-sunken);
    pointer-events: none;
}
.rs-paz-action-note:hover .rs-paz-action-dot {
    box-shadow: 0 0 0 2px var(--brand-50);
}

/* Lista ultime prescrizioni nel preview paziente */
.rs-paz-ultime {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.rs-paz-ultime-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.6rem;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease;
}
.rs-paz-ultime-item:hover,
.rs-paz-ultime-item:focus-visible {
    background: var(--brand-50);
    border-color: var(--brand-200);
    outline: none;
}
.rs-paz-ultime-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 2.6rem;
    line-height: 1.05;
}
.rs-paz-ultime-day {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
}
.rs-paz-ultime-mon {
    font-size: 0.65rem;
    color: var(--muted-soft);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.rs-paz-ultime-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}
.rs-paz-ultime-kind {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--brand-700);
    background: var(--brand-50);
    padding: 0.05rem 0.45rem;
    border-radius: 0.25rem;
    width: fit-content;
}
.rs-paz-ultime-kind-cert {
    color: #0f766e;
    background: #ccfbf1;
}
.rs-paz-ultime-nrbe {
    font-size: 0.7rem;
    color: var(--muted-soft);
    font-family: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, monospace;
}
.rs-paz-ultime-stato {
    flex-shrink: 0;
}

/* Box suggerimento "importa pazienti" (banner blu) */
.rs-paz-suggerimento {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    border-radius: 0.5rem;
    padding: 0.7rem 0.9rem;
    margin-bottom: 0.5rem;
    text-align: left;
    display: block;
}
.rs-paz-suggerimento i {
    color: #2563eb;
    font-size: 1rem;
    margin-bottom: 0;
}
.rs-paz-suggerimento p {
    font-size: 0.85rem;
    color: #1e3a8a;
    display: inline;
    margin: 0 0 0 0.3rem;
}
.rs-paz-suggerimento .rs-presc-empty-hint {
    display: block;
    margin-top: 0.2rem;
    color: #1e40af;
}

/* Pillole meta nel preview head (certificati: operatore, CF) */
.rs-presc-preview-meta-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-width: 0;
}
.rs-presc-preview-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    background: var(--page-bg);
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.1;
    white-space: nowrap;
}
.rs-presc-preview-chip b {
    font-weight: 600;
    color: var(--ink);
}
.rs-presc-preview-chip i {
    color: var(--brand-500);
    font-size: 0.7rem;
}

/* Preview vuoto / errore */
.rs-presc-preview-noitems,
.rs-presc-preview-empty {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem;
    color: var(--muted-faint);
    font-size: 0.8rem;
    background: var(--surface-sunken);
    border: 1px dashed var(--border);
    border-radius: 0.4rem;
}

/* Stato "loading" del pannello accordion mentre HTMX carica */
.rs-presc-accordion.is-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--muted-faint);
    font-size: 0.8rem;
    padding: 1rem;
}

/* Mobile: nascondi la label testuale del badge stato (resta solo icona),
   nascondi l'anno nel riquadro data, accordion padding ridotto. */
@media (max-width: 640px) {
    .rs-presc-item {
        gap: 0.55rem;
        padding: 0.5rem 0.6rem;
        grid-template-columns: auto 1fr auto auto;
    }
    .rs-presc-badge-label { display: none; }
    .rs-presc-badge {
        padding: 0.3rem 0.4rem;
        border-radius: 0.5rem;
    }
    .rs-presc-badge i { font-size: 0.85rem; }
    .rs-presc-date-year { display: none; }
    .rs-presc-accordion { padding: 0.55rem 0.65rem 0.7rem; }
    .rs-presc-preview-open { padding: 0.4rem 0.6rem; }
}

/* =========================================================================
   Welcome Tour v2 — animazioni intro modal.
   Le animazioni partono al primo render del nodo nel DOM (modal iniettato
   via HTMX su #welcome-intro-modal-host con hx-trigger="load"). Quando aggiungeremo
   altre animazioni al wizard tienile in questa sezione.
   ========================================================================= */

/* Transizione fluida tra step del wizard — confinata al SOLO body interno
   (#rs-welcome-wizard-body). Chrome del modal (overlay scuro, header, stepper,
   footer) resta fermo.

   Implementazione via View Transitions API (HTMX `transition:true` sui form):
   il browser fa snapshot del vecchio body PRIMA dello swap, snapshot del nuovo
   DOPO, e cross-fada i due snapshot SOVRAPPOSTI. Niente "vuoto opacity 0"
   intermedio tra exit e enter — la causa del "flash" del pattern fade-out
   seguito da fade-in. Vecchio e nuovo sono visibili insieme durante la
   transizione.

   Fallback browser senza View Transitions API (Firefox <126, Safari <18):
   solo fade-in del nuovo body (no exit animation, no vuoto, no flash). */
@keyframes rs-wiz-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
#rs-welcome-wizard-body {
    animation: rs-wiz-fade-in 380ms cubic-bezier(0.4, 0, 0.2, 1) both;
}
@supports (view-transition-name: none) {
    /* View Transitions attive: lascio gestire al browser i pseudo-elementi
       ::view-transition-old/new sotto. Disabilito l'animation di mount,
       altrimenti si sovrappone alla transition nativa creando doppio fade. */
    #rs-welcome-wizard-body {
        animation: none;
        view-transition-name: rs-wiz-body;
    }
    ::view-transition-old(rs-wiz-body),
    ::view-transition-new(rs-wiz-body) {
        animation-duration: 480ms;
        animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    }
}
@media (prefers-reduced-motion: reduce) {
    #rs-welcome-wizard-body { animation: none; }
    ::view-transition-old(rs-wiz-body),
    ::view-transition-new(rs-wiz-body) { animation: none !important; }
}

/* Wizard step 4 idle — glow ring sull'icona "plug-circle-bolt" del container
   circolare. Suggerisce all'utente che c'e' un'azione da attivare (cliccare
   "Crea Sessione TS") senza essere insistente. Stesso linguaggio "respiro"
   del CTA del modal intro: 3s cycle, box-shadow ring soft, easing ease-in-out.
   Delay iniziale 600ms cosi' il glow parte DOPO il fade-in dello step (380ms)
   evitando sovrapposizione visiva al mount. */
@keyframes rs-wiz-step4-icon-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
    50%      { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0.18); }
}
.rs-wiz-step4-idle-icon {
    animation: rs-wiz-step4-icon-glow 3s cubic-bezier(0.4, 0, 0.6, 1) 600ms infinite;
}
@media (prefers-reduced-motion: reduce) {
    .rs-wiz-step4-idle-icon { animation: none; }
}

/* Wizard step 4 done — bounce "happy" sull'icona check verde dopo che la
   sessione e' stata creata con successo. One-shot al mount (NO loop): celebrazione
   momentanea + assestamento. Due animation in parallelo:
   1) Pop con rotazione + overshoot (palla che rimbalza e si ferma): scale 0 →
      1.25 → 0.88 → 1.06 → 1, rotazione -30deg → +10deg → settle 0deg.
   2) Burst ring verde che esplode una volta e svanisce (effetto celebratorio
      "scintilla" di successo). */
@keyframes rs-wiz-step4-done-bounce {
    0%   { transform: scale(0)    rotate(-30deg); opacity: 0; }
    50%  { transform: scale(1.25) rotate(10deg);  opacity: 1; }
    70%  { transform: scale(0.88) rotate(-5deg); }
    85%  { transform: scale(1.06) rotate(2deg); }
    100% { transform: scale(1)    rotate(0);      opacity: 1; }
}
@keyframes rs-wiz-step4-done-burst {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    100% { box-shadow: 0 0 0 20px rgba(34, 197, 94, 0); }
}
.rs-wiz-step4-done-icon {
    animation:
        rs-wiz-step4-done-bounce 900ms cubic-bezier(0.34, 1.56, 0.64, 1) both,
        rs-wiz-step4-done-burst  700ms ease-out 150ms both;
}
@media (prefers-reduced-motion: reduce) {
    .rs-wiz-step4-done-icon { animation: none; }
}

/* "Respiro" a onda dei numeri step: un singolo passaggio scale + glow soft.
   Niente rimbalzi multipli — l'animazione e' un singolo crescendo + decrescendo
   simmetrico, come un battito calmo. Il delay sequenziale e' passato inline via
   custom property --rs-welcome-step-delay.
   `both` preserva lo stato pre-delay e post-animation (ritorno al colore originale).
   Easing standard Material (cubic-bezier 0.4, 0, 0.2, 1) per smoothness pura. */
@keyframes rs-welcome-step-pop {
    0% {
        transform: scale(1);
        background-color: rgb(219 234 254);
        color: rgb(29 78 216);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
    50% {
        transform: scale(1.12);
        background-color: rgb(96 165 250);
        color: rgb(255 255 255);
        box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.18);
    }
    100% {
        transform: scale(1);
        background-color: rgb(219 234 254);
        color: rgb(29 78 216);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}
.rs-welcome-intro-step-num {
    animation: rs-welcome-step-pop 1600ms cubic-bezier(0.4, 0, 0.2, 1) both;
    animation-delay: var(--rs-welcome-step-delay, 0ms);
}

/* Pulse ring + bg breath del CTA "Inizia configurazione".
   Due animazioni sincronizzate (stesso cycle 3s, stesso delay 3.5s, stesso easing):
   1) rs-welcome-cta-pulse → box-shadow ring blu che si espande e svanisce
   2) rs-welcome-cta-bg-breath → background-color che si schiarisce leggermente
      al peak (blue-600 → blue-500 → blue-600), come un "respiro" del bottone.
   Entrambe partono DOPO che i 4 numeri hanno finito (ultimo step parte a
   3 * 600ms = 1800ms, dura 1600ms → finisce a 3400ms). */
@keyframes rs-welcome-cta-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.40); }
    70%  { box-shadow: 0 0 0 12px rgba(37, 99, 235, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}
@keyframes rs-welcome-cta-bg-breath {
    0%, 100% { background-color: rgb(37, 99, 235); }   /* blue-600 a riposo */
    50%      { background-color: rgb(59, 130, 246); }  /* blue-500 al peak (piu' chiaro) */
}
.rs-welcome-intro-cta {
    animation:
        rs-welcome-cta-pulse 3s cubic-bezier(0.4, 0, 0.6, 1) 3.5s infinite,
        rs-welcome-cta-bg-breath 3s cubic-bezier(0.4, 0, 0.6, 1) 3.5s infinite;
}
/* Su hover pausiamo la respirazione (l'utente sta gia' interagendo, l'animation
   smette di servire) e forziamo blue-700 per coerenza col hover Tailwind del
   template. `!important` necessario per battere il valore corrente dell'animation. */
.rs-welcome-intro-cta:hover {
    animation-play-state: paused;
    background-color: rgb(29, 78, 216) !important;
}

/* CTA "Prova un workflow" della schermata finale celebrativa.
   Riusa gli STESSI keyframe del CTA intro (pulse + bg-breath sincronizzati)
   ma con delay piu' breve: la finale non ha 4 numeri da aspettare, parte ~1.2s
   dopo il mount (subito dopo il bounce dell'icona check che dura 900ms). */
.rs-welcome-cta-finale {
    animation:
        rs-welcome-cta-pulse 3s cubic-bezier(0.4, 0, 0.6, 1) 1.2s infinite,
        rs-welcome-cta-bg-breath 3s cubic-bezier(0.4, 0, 0.6, 1) 1.2s infinite;
}
.rs-welcome-cta-finale:hover {
    animation-play-state: paused;
    background-color: rgb(29, 78, 216) !important;
}

/* Rispetto preferenza utente: niente animazioni se l'utente ha disabilitato
   le animazioni a livello OS / browser (es. macOS "Reduce motion"). */
@media (prefers-reduced-motion: reduce) {
    .rs-welcome-intro-step-num,
    .rs-welcome-intro-cta,
    .rs-welcome-cta-finale {
        animation: none;
    }
}

/* ============================================================================
   Tutorial guidato dei workflow (Welcome v2, fase 2)
   - .rs-tutorial-highlight: anello brand pulsante sull'elemento del passo corrente.
   - .rs-tut-anim: animazione d'entrata del pannello.
   ========================================================================== */
/* Optional Google invitation never competes with a guide (even collapsed),
   a wizard, its completion modal or an element highlighted by the guide. */
#rs-google-invite[hidden],
html.rs-tutorial-active #rs-google-invite,
body:has(.rs-tutorial-highlight) #rs-google-invite,
body:has(#rs-welcome-wizard) #rs-google-invite,
body:has(#rs-welcome-intro-modal) #rs-google-invite,
body:has(#rs-tut-done-modal:not(.hidden)) #rs-google-invite {
    display: none !important;
}

/* Anello in AMBRA (token warning), non brand: deve risaltare sulla UI indaco e
   farsi notare come "guarda qui". */
.rs-tutorial-highlight {
    /* niente border-radius forzato: il box-shadow segue il raggio nativo dell'elemento
       (es. bottone full-rounded), cosi' la forma non cambia all'hover. */
    box-shadow: 0 0 0 3px var(--warning), 0 0 0 6px rgba(245, 158, 11, 0.30);
    animation: rs-tut-pulse 1.6s ease-out infinite;
    scroll-margin: 120px;
}
@keyframes rs-tut-pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--warning), 0 0 0 6px rgba(245, 158, 11, 0.35); }
    50%      { box-shadow: 0 0 0 3px var(--warning), 0 0 0 12px rgba(245, 158, 11, 0.0); }
}
/* Anti-crop dell'anello in uno scroller: `overflow-*-auto` ritaglia il box-shadow di un
   elemento evidenziato (es. tab Impostazioni, chip "Aggiungi operatore"), sia sopra/sotto
   sia ai lati quando l'elemento e' il primo/ultimo (bordo del contenitore). Solo MENTRE lo
   scroller contiene un highlight diamo respiro su TUTTI i lati (`:has`) cosi' l'anello si
   vede intero; fuori dalla guida nulla cambia. `!important` per battere le utility di
   padding di Tailwind gia' presenti sul contenitore (es. `px-1`, `pb-2`). */
.overflow-x-auto:has(.rs-tutorial-highlight),
.overflow-y-auto:has(.rs-tutorial-highlight),
.overflow-auto:has(.rs-tutorial-highlight) {
    padding: 0.5rem !important;
}
/* Anti-crop per `overflow-hidden` NON-scroller (es. la <ul> arrotondata della lista
   "Abilita Operatori": overflow-hidden serve solo a ritagliare gli angoli delle righe).
   Non e' uno scroller, quindi la regola padding sopra non basta: qui l'anello del primo/ultimo
   <li> verrebbe comunque ritagliato. Solo MENTRE contiene un highlight riportiamo overflow a
   `visible` (`:has`) cosi' il box-shadow si vede intero; fuori dalla guida nulla cambia. */
.overflow-hidden:has(.rs-tutorial-highlight) {
    overflow: visible !important;
}
.rs-tut-anim {
    animation: rs-tut-slidein 0.2s ease-out;
}
@keyframes rs-tut-slidein {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
/* Posizione mobile del pannello guida (auto-smart): di default IN BASSO (sopra la tab-bar,
   titolo visibile); sale IN ALTO (.rs-tut-attop) quando l'utente scrive in un campo, cosi'
   la tastiera non lo copre. Desktop usa le utility sm: di Tailwind (non entra qui). */
@media (max-width: 639px) {
    #rs-tut-panel {
        top: auto;
        bottom: calc(56px + env(safe-area-inset-bottom) + 8px);
    }
    #rs-tut-panel.rs-tut-attop {
        top: calc(56px + env(safe-area-inset-top) + 8px);
        bottom: auto;
    }
}
/* Passi che agiscono DENTRO un modal dell'app: il pannello va portato SOPRA quel modal
   per restare leggibile. 9100 sta sopra TUTTI i modal dell'app — sia quelli a z-50
   (modal farmaci) sia il modal rinnovo sessione a z-[9000] — ma SOTTO i modal della
   guida stessa (#rs-tut-exit-modal / #rs-tut-done-modal, z-[9500]). Id-specificity per
   battere l'utility Tailwind `z-40` del pannello. */
#rs-tut-panel.rs-tut-over-modal {
    z-index: 9100;
}
@media (prefers-reduced-motion: reduce) {
    .rs-tutorial-highlight { animation: none; }
    .rs-tut-anim { animation: none; }
}

