/**
 * Notification Center — modal, preferences, mini toasts
 */

/* Topbar bell (desktop + mobile; mobile tweaks in mobile-pwa.css) */
.topbar-notifications-bell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    margin-right: 0.25rem;
    background: none;
    border: none;
    border-radius: var(--radius-round);
    color: var(--color-gray-700);
    font-size: var(--font-size-xl);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s ease, color 0.2s ease;
}

.topbar-notifications-bell:hover {
    background: rgba(var(--brand-green-rgb), 0.08);
    color: var(--brand-green);
}

.topbar-notifications-bell:active {
    background: rgba(var(--rgb-black), 0.06);
    transform: scale(0.96);
}

.topbar-notifications-bell-badge {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-round);
    background: var(--color-danger);
    border: 1.5px solid var(--neutral-0);
    animation: pulse 2s infinite;
}

.topbar-user-email {
    cursor: default;
}

.topbar-user-menu-btn {
    cursor: pointer;
}

.topbar-user-caret {
    font-size: var(--font-size-3xs);
    margin-left: var(--space-1);
}

.topbar-security-btn.is-secure {
    color: var(--brand-green);
}

.topbar-security-btn.needs-action {
    color: var(--color-warning);
}

.topbar-security-menu {
    min-width: 19rem;
    padding: var(--space-2) 0;
}

.topbar-security-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
}

.topbar-security-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.topbar-security-text small {
    color: var(--color-text-muted);
}

.topbar-security-hint {
    padding: var(--space-2) var(--space-3) var(--space-1);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.push-denied-banner {
    font-size: var(--font-size-sm);
    border-radius: var(--radius-sm);
}

/* ============================================
   NOTIFICATIONS MODAL
   ============================================ */

/*
 * Self-contained full-viewport dimming (Bootstrap backdrop disabled on #notificationsModal).
 * Covers the full viewport, not just the main column.
 */
#notificationsModal.notifications-modal.show {
    display: block !important;
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 1065 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    background: rgba(var(--rgb-black), 0.4) !important;
}

body.modal-open:has(#notificationsModal.show) > .modal-backdrop {
    display: none !important;
}

.notifications-modal-dialog {
    max-width: min(720px, calc(100vw - 1.5rem));
    margin: 1rem auto;
}

.notifications-modal-content {
    border: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-modal);
}

.notifications-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: none;
    background: linear-gradient(
        135deg,
        rgba(var(--brand-green-rgb), 0.12) 0%,
        rgba(var(--brand-green-rgb), 0.03) 100%
    );
}

.notifications-modal-header .modal-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--brand-green);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.notifications-modal-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-sm);
    background: rgba(var(--brand-green-rgb), 0.15);
    color: var(--brand-green);
}

.notifications-modal-subtitle {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.notifications-guide-btn {
    border-radius: var(--radius-pill);
    font-size: var(--font-size-caption);
    font-weight: 500;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.notifications-guide-btn:hover {
    color: var(--brand-green);
    background: var(--neutral-0);
}

.notifications-modal-tabs {
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-2);
    gap: 0.25rem;
    flex-wrap: nowrap;
}

.notifications-modal-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    font-weight: 500;
    padding: 0.75rem 1rem;
    margin-bottom: -1px;
    white-space: nowrap;
}

.notifications-modal-tabs .nav-link:hover {
    color: var(--neutral-900);
    background: transparent;
}

.notifications-modal-tabs .nav-link.active {
    color: var(--brand-green);
    background: transparent;
    border-bottom-color: var(--brand-green);
}

.notifications-modal-body {
    padding: 1.25rem 1.5rem 1.5rem;
    max-height: min(65vh, 520px);
    overflow-y: auto;
}

.notifications-modal-body .notification-item {
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
}

.notifications-modal-body .notification-actions .btn-sm {
    font-weight: 600;
}

.notifications-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    background: var(--neutral-50);
}

/* Feed tab */
.notifications-modal-body .empty-notifications {
    padding: 2.5rem 1rem;
    text-align: center;
}

.notifications-modal-body .empty-notifications i {
    font-size: var(--font-size-5xl);
    color: var(--brand-green);
    opacity: 0.85;
}

.smm-notifications-list:empty {
    display: none;
}

/* SMM weekly brief feed items */
.notification-item-smm {
    position: relative;
    background: var(--neutral-0);
    border: 1px solid var(--color-border-alt);
    border-left: 3px solid var(--brand-green);
    border-radius: var(--radius-sm);
    padding: 0.85rem 2.5rem 0.85rem 0.85rem;
    margin-bottom: 0.65rem;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.notification-item-smm:hover {
    border-color: var(--brand-green);
    box-shadow: var(--shadow-brand);
}

.notification-item-bug-reply {
    position: relative;
}

.notification-item-bug-reply .notification-content {
    padding-right: 1.5rem;
}

.notification-item-smm .notification-dismiss,
.notification-item-bug-reply .notification-dismiss {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--color-text-faint);
    border-radius: var(--radius-round);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: var(--font-size-base);
    font-weight: 300;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

.notification-item-smm .notification-dismiss:hover,
.notification-item-bug-reply .notification-dismiss:hover {
    color: var(--neutral-700);
    background: var(--neutral-100);
}

.notif-smm-row {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
}

.notif-smm-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, rgba(var(--brand-green-rgb), 0.14), rgba(var(--brand-green-rgb), 0.06));
    color: var(--brand-green-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-base);
}

.notif-smm-body {
    flex: 1;
    min-width: 0;
}

.notif-smm-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.notif-smm-title {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.notif-smm-when {
    font-size: var(--font-size-xs);
    color: var(--color-text-faint);
    margin-top: 0.1rem;
}

.notif-smm-expand {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    padding: 0.15rem;
    cursor: pointer;
    border-radius: var(--radius-xs);
    line-height: 1;
}

.notif-smm-expand:hover {
    color: var(--brand-green-hover);
    background: var(--neutral-100);
}

.notif-smm-compact {
    font-size: var(--font-size-caption);
    color: var(--color-text-muted);
    margin-top: 0.35rem;
    line-height: 1.45;
}

.notif-smm-expanded {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--neutral-100);
}

.notif-smm-details {
    margin: 0 0 0.5rem;
    font-size: var(--font-size-xs);
}

.notif-smm-details div {
    margin-bottom: 0.35rem;
}

.notif-smm-details dt {
    font-weight: 600;
    color: var(--color-text-secondary);
    display: inline;
    margin-right: 0.25rem;
}

.notif-smm-details dd {
    display: inline;
    margin: 0;
    color: var(--color-text-muted);
}

.notif-smm-hints-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-faint);
    margin: 0 0 0.35rem;
}

.notif-smm-hints {
    margin: 0 0 0.5rem;
    padding-left: 1.1rem;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.notif-smm-action {
    display: inline-block;
    margin-top: 0.35rem;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--brand-green-hover);
    text-decoration: none;
}

.notif-smm-action:hover {
    color: var(--brand-green-strong);
    text-decoration: underline;
}

/* Preferences tab */
.notifications-prefs-intro {
    font-size: var(--font-size-md);
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.notifications-section-label {
    font-size: var(--font-size-2xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-faint);
    margin: 0 0 0.75rem;
}

.notifications-pref-cards {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.notifications-pref-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.125rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--neutral-0);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    margin: 0;
}

.notifications-pref-card:hover {
    border-color: rgba(var(--brand-green-rgb), 0.4);
    box-shadow: var(--shadow-card);
}

.notifications-pref-card-text {
    flex: 1;
    min-width: 0;
}

.notifications-pref-card-text strong {
    display: block;
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--neutral-900);
}

.notifications-pref-card-text small {
    display: block;
    font-size: var(--font-size-caption);
    color: var(--color-text-muted);
    margin-top: 0.15rem;
    line-height: 1.35;
}

/* Brand switch: drawn here (track + knob), so it stays a switch in emerald even
   when Bootstrap's form-switch CSS (CDN) is missing, e.g. offline in the PWA. */
.notifications-pref-card .form-switch {
    padding-left: 0;
    min-height: 0;
}

.notifications-pref-card .form-switch .form-check-input {
    -webkit-appearance: none;
    appearance: none;
    float: none;
    display: block;
    width: 2.75rem;
    height: 1.5rem;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-pill);
    background-color: var(--neutral-200);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3.2' fill='%23fff'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left center;
    background-size: contain;
    box-shadow: var(--shadow-xs);
    transition: background-color 0.18s ease, border-color 0.18s ease, background-position 0.18s ease,
        box-shadow 0.18s ease;
}

.notifications-pref-card .form-switch .form-check-input:checked {
    background-color: var(--brand-green);
    border-color: var(--brand-green);
    background-position: right center;
    box-shadow: none;
}

.notifications-pref-card:hover .form-switch .form-check-input:not(:checked) {
    border-color: var(--neutral-400);
}

.notifications-pref-card:hover .form-switch .form-check-input:checked {
    background-color: var(--brand-green-hover);
    border-color: var(--brand-green-hover);
}

/* No black ring on tap (customer-layout-optimization.css leaves role="switch" out of its modal
   focus outline); keyboard focus gets the emerald ring below instead. */
.notifications-pref-card .form-switch .form-check-input:focus {
    outline: none;
    box-shadow: none;
}

.notifications-pref-card .form-switch .form-check-input:focus-visible {
    box-shadow: var(--focus-ring);
    border-color: var(--brand-green);
}

.notifications-pref-card:has(.form-check-input:checked) {
    border-color: rgba(var(--brand-green-rgb), 0.35);
}

@media (prefers-reduced-motion: reduce) {
    .notifications-pref-card .form-switch .form-check-input {
        transition: none;
    }
}

/* ============================================
   GUIDE TAB
   ============================================ */

.notifications-guide-lead {
    font-size: var(--font-size-md);
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin-bottom: 1rem;
}

/* Section wrappers (Telefono / Computer) */
.notifications-guide-section {
    margin-bottom: 1.25rem;
}

.notifications-guide-section-title {
    font-size: var(--font-size-2xs);
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--color-text-faint);
    margin: 0 0 0.625rem;
}

/* Generic 2-col grid */
.notifications-guide-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* Phone grid: always 2 columns (Android | iPhone side by side) */
.notifications-guide-grid--phones {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Base card */
.notifications-guide-card {
    background: var(--neutral-0);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    height: 100%;
}

/* Compact sizing inside the phones grid */
.notifications-guide-grid--phones .notifications-guide-card {
    padding: 0.75rem 0.875rem;
}

/* Card head */
.notifications-guide-card-head {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.65rem;
}

/* Generic icon */
.notifications-guide-card-icon {
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-sm);
    background: rgba(var(--brand-green-rgb), 0.1);
    color: var(--brand-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-base);
    flex-shrink: 0;
}

/* Android icon tint */
.notifications-guide-card-icon--android {
    background: rgba(61, 220, 132, 0.12);
    color: var(--color-green-500);
}

/* iPhone / Apple icon tint */
.notifications-guide-card-icon--iphone {
    background: rgba(var(--rgb-neutral-500), 0.1);
    color: var(--color-text-secondary);
}

.notifications-guide-card-head h6 {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--neutral-900);
}

/* Subsection heading ("1. Installa l'app" / "2. Attiva le notifiche") */
.notifications-guide-subheading {
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--neutral-700);
    margin: 0.75rem 0 0.3rem;
}

.notifications-guide-subheading:first-of-type {
    margin-top: 0;
}

/* Requisito line (iPhone card) */
.notifications-guide-requisito {
    font-size: var(--font-size-2xs);
    color: var(--color-text-muted);
    line-height: 1.45;
    margin: 0 0 0.6rem;
    border-left: 2px solid var(--color-border);
    padding-left: 0.5rem;
}

/* Numbered steps */
.notifications-guide-steps {
    margin: 0;
    padding-left: 1.1rem;
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.notifications-guide-steps li {
    margin-bottom: 0.35rem;
}

.notifications-guide-steps li:last-child {
    margin-bottom: 0;
}

/* Inline note ("causa più comune…") */
.notifications-guide-note {
    font-size: var(--font-size-2xs);
    color: var(--color-text-faint);
}

/* iOS denied-permission callout */
.notifications-guide-callout {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.625rem 0.75rem;
    background: var(--color-warning-surface);
    border: 1px solid var(--color-warning-soft-alt);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-2xs);
    color: var(--color-warning-ink-deep);
    line-height: 1.45;
}

.notifications-guide-callout-icon {
    flex-shrink: 0;
    color: var(--color-warning);
    font-size: var(--font-size-sm);
    margin-top: 0.05rem;
}

/* Desktop card: full width in its own single-card grid */
.notifications-guide-card--desktop {
    grid-column: 1 / -1;
}

/* Screenshot figure */
.notifications-guide-figure {
    margin: 1rem auto 0;
    padding: 0;
    max-width: 340px;
    text-align: center;
}

.notifications-guide-figure img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 420px;
    object-fit: contain;
    margin-inline: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-card);
}

.notifications-guide-figure figcaption {
    margin-top: 0.5rem;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    line-height: 1.45;
}

/* ============================================
   MINI TOAST NOTIFICATIONS
   ============================================ */

.mini-toast-container {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 10080;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.mini-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--neutral-0);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    box-shadow: var(--shadow-card);
    min-width: 260px;
    max-width: 320px;
    font-size: var(--font-size-caption);
    line-height: 1.4;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s ease;
    border-left: 3px solid var(--color-border-dim);
}

.mini-toast.show {
    opacity: 1;
    transform: translateX(0);
}

.mini-toast.hide {
    opacity: 0;
    transform: translateX(20px);
}

.mini-toast.success {
    border-left-color: var(--brand-green);
}

.mini-toast.error {
    border-left-color: var(--color-danger-bootstrap);
}

.mini-toast.info {
    border-left-color: var(--color-primary-bootstrap);
}

.mini-toast-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-toast-icon svg {
    width: 100%;
    height: 100%;
}

.mini-toast.success .mini-toast-icon {
    color: var(--brand-green);
}

.mini-toast.error .mini-toast-icon {
    color: var(--color-danger-bootstrap);
}

.mini-toast.info .mini-toast-icon {
    color: var(--color-primary-bootstrap);
}

.mini-toast-content {
    flex: 1;
    min-width: 0;
}

.mini-toast-content strong {
    display: block;
    font-weight: 600;
    color: var(--color-ink-bootstrap);
    margin-bottom: 2px;
    font-size: var(--font-size-caption);
}

.mini-toast-content span {
    color: var(--color-text-bootstrap);
    font-size: var(--font-size-xs);
}

.mini-toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0;
    margin: -2px -4px -2px 0;
    font-size: var(--font-size-lg);
    line-height: 1;
    color: var(--color-text-form-muted);
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    transition: all 0.15s ease;
}

.mini-toast-close:hover {
    color: var(--color-text-bootstrap);
    background: var(--color-surface-form);
}

@media (max-width: 576px) {
    .notifications-modal-dialog {
        max-width: calc(100vw - 0.5rem);
        margin: 0.25rem auto;
    }

    .notifications-modal-header {
        padding: 1rem 1.125rem;
    }

    .notifications-modal-tabs {
        padding: 0 0.75rem;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .notifications-modal-tabs .nav-link {
        padding: 0.65rem 0.75rem;
        font-size: var(--font-size-caption);
    }

    .notifications-modal-body {
        padding: 1rem 1.125rem 1.25rem;
        max-height: min(70vh, 560px);
    }

    /* Desktop/generic grid stacks; phone grid stays 2-col */
    .notifications-guide-grid:not(.notifications-guide-grid--phones) {
        grid-template-columns: 1fr;
    }

    /* Phone cards: tighter font on very small screens */
    .notifications-guide-grid--phones .notifications-guide-card {
        padding: 0.625rem 0.625rem;
    }

    .notifications-guide-grid--phones .notifications-guide-steps {
        font-size: var(--font-size-2xs);
    }

    .notifications-guide-grid--phones .notifications-guide-subheading {
        font-size: var(--font-size-2xs);
    }

    .mini-toast-container {
        left: 16px;
        right: 16px;
        top: 60px;
    }

    .mini-toast {
        max-width: 100%;
        min-width: auto;
    }
}
