/* ========================================================
   NotificheRicevute - restyling card-based.

   Usato dal WebControl ~/WebControls/NotificheRicevute.ascx
   (incluso da Utenti/Notifiche.aspx, MilleGiorni/Notifiche.aspx,
   PRP/NotificheInEntrata.aspx, Organizzazione/NotificheInEntrata.aspx,
   Stress/NotificheInEntrata.aspx, Comunicazione/NotificheInEntrata.aspx).

   Tutte le regole sono scoped sotto .notifiche-control: caricato
   automaticamente dal tema TaleteTouch su ogni pagina ma non
   sortisce effetto se .notifiche-control non c'e' nel DOM.

   Filter bar in card, bulk action "Marca tutti come letti" in
   alto a destra, RadGrid skinnato (zebra, sticky header, riga
   non letta in evidenza, "Apri" come pulsante outline). Sotto
   768px: filter bar a 2 colonne, segmented control a tutta riga,
   pulsanti azione stretch.
   ======================================================== */

.notifiche-control {
    --nf-brand: #024987;
    --nf-brand-light: #0367a6;
    --nf-text: #2c3e50;
    --nf-muted: #6c757d;
    --nf-border: #e1e7ef;
    --nf-card-bg: #ffffff;
    --nf-unread-bg: #eef6ff;
    --nf-shadow: 0 2px 8px rgba(2, 73, 135, 0.06);
    margin-top: 0.25rem;
}

/* ===== Titolo pagina maggiorato sulle pagine con NotificheRicevute =====
   .app-title e' renderizzato dal master fuori da .notifiche-control: usiamo
   :has() (CSS L4, Chrome 105+/Safari 15.4+/Firefox 121+, stesso pattern di
   anteprima-notifica.css) per scoparlo a pagine che ospitano il control,
   evitando l'inline <style>+!important precedente in Utenti/Notifiche.aspx.
   La specificita' di body:has(...) .app-title batte .app-title del master
   senza bisogno di !important. */
body:has(.notifiche-control) .app-title {
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.1;
    margin: 0.4rem 0 1.25rem;
}

@media (max-width: 768px) {
    body:has(.notifiche-control) .app-title {
        font-size: 1.9rem;
    }
}

/* ===== Bulk action bar (in alto a destra) ===== */
.notifiche-control .notifiche-actions {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 1rem;
}

.notifiche-control .notifiche-actions .RadButton {
    background: #fff !important;
    border: 1px solid var(--nf-border) !important;
    color: var(--nf-brand) !important;
    border-radius: 8px !important;
    padding: 0.5rem 1rem !important;
    font-weight: 500 !important;
    font-size: 0.92rem !important;
    height: auto !important;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.notifiche-control .notifiche-actions .RadButton:hover {
    border-color: var(--nf-brand) !important;
    background: rgba(2, 73, 135, 0.04) !important;
}

/* ===== Filter card ===== */
.notifiche-control .notifiche-filters {
    background: var(--nf-card-bg);
    border: 1px solid var(--nf-border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    box-shadow: var(--nf-shadow);
    /* override .barranavigazione legacy (sfondo grigio fisso) */
    background-color: var(--nf-card-bg) !important;
}

.notifiche-control .notifiche-filters .filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.85rem;
    align-items: end;
}

/* I controlli legacy ChiaveEsterna/DateTimePicker rendono wrapper
   <div class="input"><div class="inputlabel">...</div><...combo/picker.../></div>:
   qui li trasformiamo in celle della griglia. */
.notifiche-control .notifiche-filters .filters-grid > .input,
.notifiche-control .notifiche-filters .filters-grid > [id$="_inputDiv"] {
    margin: 0;
    padding: 0;
    float: none;
    width: auto;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.notifiche-control .notifiche-filters .inputlabel {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--nf-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin: 0;
    padding: 0;
    height: auto;
}

.notifiche-control .notifiche-filters .RadComboBox,
.notifiche-control .notifiche-filters .RadComboBox_Default,
.notifiche-control .notifiche-filters .RadInput,
.notifiche-control .notifiche-filters .RadPicker {
    width: 100% !important;
}

/* ===== Segmented control (RadioButtonList Stato) ===== */
.notifiche-control .notifiche-filters .field-segmented {
    grid-column: span 2;
}

.notifiche-control .notifiche-filters .segmented {
    display: inline-flex;
    background: #f3f5f8;
    border: 1px solid var(--nf-border);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
    width: max-content;
}

/* L'<asp:RadioButtonList RepeatLayout="Flow"> rende un <span> contenitore
   intorno ai radio + label: lo rendiamo "trasparente" al flex parent. */
.notifiche-control .notifiche-filters .segmented > span {
    display: contents;
}

/* notifiche-segmented.js bonifica il DOM al load: rimuove gli span Telerik
   .rfd* (decorazione di RadFormDecorator) e marca con data-checked="true" la
   <label> associata al radio attivo. Il CSS quindi puo' essere lineare:
   solo regole sulle <label> e sullo stato data-checked. */

.notifiche-control .notifiche-filters .segmented input[type="radio"] {
    /* Fallback se per qualche motivo il JS non parte: input invisibile ma
       funzionale. Il JS ribadira' lo stesso a inline style. */
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
    margin: 0;
}

.notifiche-control .notifiche-filters .segmented label {
    cursor: pointer;
    padding: 0.42rem 0.95rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--nf-muted);
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    margin: 0;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    background: transparent;
    border: 0;
    box-shadow: none;
    font-family: inherit;
    white-space: nowrap;
}

/* Stato attivo: pillola bianca + testo brand. data-checked="true" e' messo
   da notifiche-segmented.js sulla label dell'input :checked al load
   e ad ogni cambio di selezione. */
.notifiche-control .notifiche-filters .segmented label[data-checked="true"] {
    background: #fff;
    color: var(--nf-brand);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    font-weight: 600;
}

/* ===== Pulsanti azione (Azzera / Visualizza) ===== */
.notifiche-control .notifiche-filters-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px dashed var(--nf-border);
    justify-content: flex-end;
    flex-wrap: wrap;
}

.notifiche-control .notifiche-filters-actions .inputbutton {
    display: inline-block;
}

.notifiche-control .notifiche-filters-actions .inputbutton .inputlabel {
    display: none;
}

.notifiche-control .notifiche-filters-actions .RadButton {
    border-radius: 8px !important;
    padding: 0.55rem 1.1rem !important;
    font-size: 0.92rem !important;
    font-weight: 500 !important;
    height: auto !important;
    transition: all 0.15s ease;
}

/* Primario (Visualizza) - blu pieno */
.notifiche-control .notifiche-filters-actions .btn-primary .RadButton {
    background: linear-gradient(135deg, var(--nf-brand) 0%, var(--nf-brand-light) 100%) !important;
    color: #fff !important;
    border: 0 !important;
    box-shadow: 0 2px 6px rgba(2, 73, 135, 0.22) !important;
}

.notifiche-control .notifiche-filters-actions .btn-primary .RadButton:hover {
    box-shadow: 0 4px 12px rgba(2, 73, 135, 0.32) !important;
    transform: translateY(-1px);
}

/* Ghost (Azzera) - solo testo */
.notifiche-control .notifiche-filters-actions .btn-ghost .RadButton {
    background: transparent !important;
    color: var(--nf-muted) !important;
    border: 0 !important;
    box-shadow: none !important;
}

.notifiche-control .notifiche-filters-actions .btn-ghost .RadButton:hover {
    background: rgba(2, 73, 135, 0.04) !important;
    color: var(--nf-brand) !important;
}

/* ===== Tabella ===== */
.notifiche-control .notifiche-table-card {
    background: var(--nf-card-bg);
    border: 1px solid var(--nf-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--nf-shadow);
}

.notifiche-control .notif-grid,
.notifiche-control .notif-grid .rgMasterTable {
    border: 0 !important;
    font-size: 0.92rem;
}

.notifiche-control .notif-grid table.rgMasterTable {
    background: transparent;
}

.notifiche-control .notif-grid th.rgHeader,
.notifiche-control .notif-grid .rgHeader {
    background: #fafbfd !important;
    color: var(--nf-muted) !important;
    font-size: 0.74rem !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 0 !important;
    border-bottom: 1px solid var(--nf-border) !important;
    padding: 0.85rem 1rem !important;
    white-space: nowrap;
}

.notifiche-control .notif-grid .rgFilterRow > td {
    background: #fafbfd !important;
    border: 0 !important;
    border-bottom: 1px solid var(--nf-border) !important;
    padding: 0.4rem 1rem !important;
}

.notifiche-control .notif-grid .rgRow > td,
.notifiche-control .notif-grid .rgAltRow > td {
    background: transparent !important;
    padding: 0.85rem 1rem !important;
    border: 0 !important;
    border-bottom: 1px solid #f0f2f5 !important;
    vertical-align: middle !important;
    color: var(--nf-text);
}

.notifiche-control .notif-grid .rgRow:hover > td,
.notifiche-control .notif-grid .rgAltRow:hover > td {
    background: rgba(2, 73, 135, 0.035) !important;
}

/* Riga non letta: sfondo azzurro + bordo accentato a sinistra + grassetto.
   La classe .nf-unread viene applicata via codebehind in ItemDataBound
   quando NotificaRicevuta != '1'.
   N.B. nome volutamente prefissato "nf-" per non collidere con la classe
   .unread globale in Talete.css (usata come badge rosso sul logo header
   con position:absolute, che romperebbe la riga della tabella). */
.notifiche-control .notif-grid .rgRow.nf-unread > td,
.notifiche-control .notif-grid .rgAltRow.nf-unread > td {
    background: var(--nf-unread-bg) !important;
    font-weight: 500;
}

.notifiche-control .notif-grid .rgRow.nf-unread:hover > td,
.notifiche-control .notif-grid .rgAltRow.nf-unread:hover > td {
    background: #e3effa !important;
}

.notifiche-control .notif-grid .rgRow.nf-unread > td:first-child,
.notifiche-control .notif-grid .rgAltRow.nf-unread > td:first-child {
    box-shadow: inset 3px 0 0 var(--nf-brand);
}

/* "Apri" button: GridButtonColumn (LinkButton default) renderizza un <a>
   semplice senza class affidabile, oppure un <input type="button"> se cambiata
   la ButtonType. Targetto la tipologia generica nella cella ultima. */
.notifiche-control .notif-grid tbody tr > td:last-child a,
.notifiche-control .notif-grid tbody tr > td:last-child input[type="button"] {
    display: inline-block;
    border: 1px solid var(--nf-border);
    color: var(--nf-brand);
    background: #fff;
    border-radius: 6px;
    padding: 0.32rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
    line-height: 1.4;
}

.notifiche-control .notif-grid tbody tr > td:last-child a:hover,
.notifiche-control .notif-grid tbody tr > td:last-child input[type="button"]:hover {
    background: var(--nf-brand);
    color: #fff;
    border-color: var(--nf-brand);
}

/* ===== Icona busta come badge circolare ===== */
/* La prima cella delle righe dati ospita un <asp:Image src=mail_closed/opened.gif>:
   nascondiamo l'immagine e disegniamo un badge circolare via pseudo-element.
   Per le righe non lette (.nf-unread) il badge e' pieno e blu. */
.notifiche-control .notif-grid tbody tr > td:first-child {
    width: 56px !important;
    text-align: center;
}

.notifiche-control .notif-grid tbody tr > td:first-child img {
    display: none !important;
}

.notifiche-control .notif-grid tbody tr > td:first-child::before {
    content: "\2709"; /* ✉ */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f0f2f5;
    color: var(--nf-muted);
    font-size: 1rem;
    line-height: 1;
    vertical-align: middle;
}

.notifiche-control .notif-grid tbody tr.nf-unread > td:first-child::before {
    background: linear-gradient(135deg, var(--nf-brand) 0%, var(--nf-brand-light) 100%);
    color: #fff;
    box-shadow: 0 2px 6px rgba(2, 73, 135, 0.25);
}

/* Pager */
.notifiche-control .notif-grid .rgPager > td,
.notifiche-control .notif-grid .rgPager {
    background: #fafbfd !important;
    border: 0 !important;
    border-top: 1px solid var(--nf-border) !important;
    padding: 0.4rem 0.5rem !important;
    color: var(--nf-muted);
    font-size: 0.86rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .notifiche-control .notifiche-filters .filters-grid {
        grid-template-columns: 1fr 1fr;
    }

    .notifiche-control .notifiche-filters .field-segmented {
        grid-column: 1 / -1;
    }

    .notifiche-control .notifiche-filters-actions {
        justify-content: stretch;
    }

    .notifiche-control .notifiche-filters-actions .inputbutton,
    .notifiche-control .notifiche-filters-actions .inputbutton .RadButton {
        flex: 1;
        width: 100%;
        justify-content: center;
    }

    .notifiche-control .notif-grid .rgMasterTable {
        font-size: 0.86rem;
    }
}
