/**
 * Secure File Manager Pro — Public/Frontend CSS
 *
 * Stile portale utenti: login, galleria file, card grid.
 * Tema professionale #1e3a5f coerente con l'admin.
 * Layout responsive mobile-first. Accessibilità WCAG 2.1 AA.
 *
 * @since   1.0.0
 * @package Secure_File_Manager_Pro
 * @author  Maryline Honkah
 *
 * Riferimenti:
 * - CSS Grid: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout
 * - CSS Custom Properties: https://developer.mozilla.org/en-US/docs/Web/CSS/--*
 */

/* ==========================================================================
   VARIABILI
   ========================================================================== */

:root {
    /* Palette colori da specifica §7 */
    --sfmp-primary: #1e3a5f;
    --sfmp-primary-light: #2271b1;
    --sfmp-primary-dark: #142a45;
    --sfmp-accent: #2271b1;
    --sfmp-success: #00a32a;
    --sfmp-warning: #dba617;
    --sfmp-danger: #d63638;
    --sfmp-white: #ffffff;
    --sfmp-gray-50: #f0f0f1;
    --sfmp-gray-100: #f0f2f5;
    --sfmp-gray-200: #e4e6ea;
    --sfmp-gray-300: #d1d5db;
    --sfmp-gray-500: #646970;
    --sfmp-gray-700: #374151;
    --sfmp-gray-900: #1d2327;
    --sfmp-radius: 8px;
    --sfmp-radius-lg: 12px;
    --sfmp-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --sfmp-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --sfmp-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --sfmp-transition: 0.2s ease;
    --sfmp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ==========================================================================
   BASE & PORTAL WRAPPER — Full-width dentro il contenitore del tema
   ========================================================================== */

/**
 * Il portale usa un approccio JS (wp_add_inline_script) per annullare i
 * vincoli max-width/padding dei container del tema. Il CSS qui sotto definisce
 * solo le dimensioni del portale stesso.
 *
 * Il JS risale da .sfmp-portal fino a <body> e rimuove max-width + padding
 * da tutti i container intermedi del tema (TagDiv, Flavor, ecc.).
 *
 * @see SFMP_Public::enqueue_assets() — inline script breakout.
 * @see https://developer.wordpress.org/themes/basics/template-hierarchy/
 */

.sfmp-portal {
    font-family: var(--sfmp-font);
    color: var(--sfmp-gray-900);
    line-height: 1.6;
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100% !important;
    padding: 20px 2% !important;
    margin: 0 auto;
}

/* La griglia file si espande a tutta la larghezza disponibile. */

/**
 * Override container TagDiv / Flavor / Flavor Theme.
 *
 * TagDiv usa una griglia 12 colonne con classi td-pb-spanN dove
 * td-pb-span8 = 66.66% + float:left. Il JS breakout forza width:100%,
 * questi CSS forniscono fallback in caso di race condition.
 *
 * @since 1.60.0
 * @see https://developer.wordpress.org/themes/basics/template-hierarchy/
 */
.td-pb-span8:has(.sfmp-portal),
.td-main-content:has(.sfmp-portal),
.td-ss-main-content:has(.sfmp-portal),
.tdc-content-wrap:has(.sfmp-portal),
.wpb_wrapper:has(.sfmp-portal),
.vc_column-inner:has(.sfmp-portal),
.wpb_column:has(.sfmp-portal),
[class*="td-pb-span"]:has(.sfmp-portal) {
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
}

/**
 * Ripristina padding per breadcrumb, titolo pagina e altri contenuti
 * del tema che sono fratelli del portale SFMP dentro il container allargato.
 *
 * Quando td-pb-span8 diventa width:100%, il titolo e il breadcrumb
 * perdono il margine sinistro della griglia originale.
 *
 * @since 1.60.0
 */
[class*="td-pb-span"]:has(.sfmp-portal) > .td-page-header,
[class*="td-pb-span"]:has(.sfmp-portal) > .entry-title,
[class*="td-pb-span"]:has(.sfmp-portal) > h1,
[class*="td-pb-span"]:has(.sfmp-portal) > .td-crumb-container,
[class*="td-pb-span"]:has(.sfmp-portal) > [class*="breadcrumb"],
[class*="td-pb-span"]:has(.sfmp-portal) > [class*="crumb"] {
    padding-left: 2% !important;
}
/* Nasconde sidebar quando il portale è attivo nella pagina. */
.td-pb-span4:has(~ .td-pb-span8 .sfmp-portal),
.td-pb-span8 ~ .td-pb-span4 {
    /* La sidebar resta — non la tocchiamo, solo il main si allarga. */
}

.sfmp-portal *, .sfmp-portal *::before, .sfmp-portal *::after {
    box-sizing: border-box;
}

.sfmp-hidden { display: none !important; }

/* ==========================================================================
   LOGIN
   ========================================================================== */

.sfmp-portal-login {
    max-width: 420px !important;
    width: auto !important;
    margin: 40px auto;
    padding: 0 !important;
}

.sfmp-login-header {
    text-align: center;
    padding: 32px 24px 24px;
    background: linear-gradient(135deg, var(--sfmp-primary) 0%, var(--sfmp-primary-light) 100%);
    border-radius: var(--sfmp-radius-lg) var(--sfmp-radius-lg) 0 0;
    color: #ffffff !important;
}

.sfmp-login-logo {
    font-size: 48px !important;
    width: 48px !important;
    height: 48px !important;
    opacity: 0.9;
    color: #ffffff !important;
}

.sfmp-login-header h2 {
    margin: 12px 0 4px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: #ffffff !important;
}

.sfmp-login-subtitle {
    margin: 0;
    font-size: 14px;
    opacity: 0.85;
    color: #ffffff !important;
}

.sfmp-login-view {
    background: var(--sfmp-white);
    padding: 28px 28px 20px;
    box-shadow: var(--sfmp-shadow-lg);
}

.sfmp-login-view h3 {
    color: var(--sfmp-primary);
    font-size: 18px;
    margin: 0 0 12px;
}

.sfmp-reset-desc {
    color: var(--sfmp-gray-500);
    font-size: 14px;
    margin: 0 0 16px;
}

.sfmp-login-footer {
    text-align: center;
    padding: 16px 24px;
    background: var(--sfmp-gray-50);
    border-radius: 0 0 var(--sfmp-radius-lg) var(--sfmp-radius-lg);
    font-size: 12px;
    color: var(--sfmp-gray-500);
    box-shadow: var(--sfmp-shadow-lg);
}

.sfmp-login-link {
    text-align: center;
    margin: 16px 0 0;
    font-size: 13px;
}

.sfmp-login-link a {
    color: var(--sfmp-primary);
    text-decoration: none;
    font-weight: 500;
}

.sfmp-login-link a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   FORM FIELDS
   ========================================================================== */

.sfmp-field {
    margin-bottom: 16px;
}

.sfmp-field label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--sfmp-gray-700);
    margin-bottom: 6px;
}

.sfmp-field label .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    color: var(--sfmp-primary-light);
}

.sfmp-field input[type="email"],
.sfmp-field input[type="password"],
.sfmp-field input[type="text"],
.sfmp-search-field,
.sfmp-select-field {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--sfmp-gray-300);
    border-radius: var(--sfmp-radius);
    font-size: 15px;
    font-family: var(--sfmp-font);
    color: var(--sfmp-gray-900);
    background: var(--sfmp-white);
    transition: border-color var(--sfmp-transition), box-shadow var(--sfmp-transition);
    outline: none;
}

.sfmp-field input:focus,
.sfmp-search-field:focus,
.sfmp-select-field:focus {
    border-color: var(--sfmp-primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}

.sfmp-password-hint {
    font-size: 12px;
    color: var(--sfmp-gray-500);
    margin: 4px 0 12px;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.sfmp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--sfmp-radius);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--sfmp-font);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--sfmp-transition);
    line-height: 1.4;
}

.sfmp-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.sfmp-btn-primary {
    background: var(--sfmp-primary);
    color: var(--sfmp-white);
}

.sfmp-btn-primary:hover {
    background: var(--sfmp-primary-light);
    transform: translateY(-1px);
    box-shadow: var(--sfmp-shadow-md);
}

.sfmp-btn-outline {
    background: transparent;
    color: var(--sfmp-primary);
    border: 1px solid var(--sfmp-primary);
}

.sfmp-btn-outline:hover {
    background: var(--sfmp-primary);
    color: var(--sfmp-white);
}

.sfmp-btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.sfmp-btn-block {
    display: flex;
    width: 100%;
}

.sfmp-btn-disabled {
    background: var(--sfmp-gray-200);
    color: var(--sfmp-gray-500);
    cursor: default;
    border: none;
}

.sfmp-btn-loading { display: inline-flex; align-items: center; }

/* ==========================================================================
   SPINNER
   ========================================================================== */

.sfmp-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--sfmp-white);
    border-radius: 50%;
    animation: sfmpSpin 0.6s linear infinite;
}

.sfmp-spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
    border-color: rgba(30, 58, 95, 0.2);
    border-top-color: var(--sfmp-primary);
}

.sfmp-spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
    vertical-align: middle;
}

@keyframes sfmpSpin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   MESSAGES
   ========================================================================== */

.sfmp-message {
    padding: 12px 16px;
    border-radius: var(--sfmp-radius);
    font-size: 14px;
    margin-bottom: 16px;
    animation: sfmpFadeIn 0.3s ease;
}

.sfmp-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.sfmp-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

@keyframes sfmpFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   GALLERY HEADER
   ========================================================================== */

.sfmp-gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--sfmp-primary) 0%, var(--sfmp-primary-light) 100%);
    border-radius: var(--sfmp-radius-lg);
    margin-bottom: 20px;
    box-shadow: var(--sfmp-shadow-md);
}

.sfmp-gallery-user {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #ffffff !important;
}

.sfmp-avatar {
    font-size: 32px !important;
    width: 32px !important;
    height: 32px !important;
    opacity: 0.8;
    color: #ffffff !important;
}

.sfmp-user-info {
    display: flex;
    flex-direction: column;
    color: #ffffff !important;
}

.sfmp-user-info strong {
    font-size: 16px;
    line-height: 1.2;
    color: #ffffff !important;
}

.sfmp-user-email {
    font-size: 12px;
    opacity: 0.75;
    color: #ffffff !important;
}

.sfmp-gallery-header .sfmp-btn-outline {
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.5);
}

.sfmp-gallery-header .sfmp-btn-outline:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #ffffff;
    color: #ffffff !important;
}

/* ==========================================================================
   TOOLBAR
   ========================================================================== */

.sfmp-gallery-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.sfmp-search-box {
    width: 100%;
    position: relative;
}

.sfmp-search-icon {
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    font-size: 18px !important;
    width: 18px !important;
    height: 18px !important;
    color: var(--sfmp-gray-500);
    pointer-events: none;
}

.sfmp-search-field {
    padding-left: 38px !important;
    width: 100%;
}

.sfmp-filter-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.sfmp-select-field {
    flex: 1 1 160px;
    min-width: 140px;
    max-width: 260px;
    padding: 10px 12px;
    appearance: auto;
}

/* ==========================================================================
   VIEW BAR — Raggruppamento, dimensione, vista griglia/lista
   ========================================================================== */

.sfmp-gallery-viewbar {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 8px 12px;
    background: var(--sfmp-gray-50, #f8f9fa);
    border: 1px solid var(--sfmp-gray-200, #e5e7eb);
    border-radius: 6px;
}

.sfmp-viewbar-section {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sfmp-viewbar-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--sfmp-gray-500);
    text-transform: uppercase;
    letter-spacing: .3px;
    white-space: nowrap;
}

.sfmp-select-sm {
    font-size: 13px;
    padding: 5px 8px;
    border: 1px solid var(--sfmp-gray-300, #d1d5db);
    border-radius: 4px;
    background: #fff;
}

/* Toggle buttons (size + view) */
.sfmp-size-toggle, .sfmp-view-toggle {
    display: flex;
    border: 1px solid var(--sfmp-gray-300, #d1d5db);
    border-radius: 4px;
    overflow: hidden;
}

.sfmp-size-btn, .sfmp-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 30px;
    border: none;
    background: #fff;
    cursor: pointer;
    color: var(--sfmp-gray-500);
    transition: background .15s, color .15s;
}

.sfmp-size-btn:not(:last-child), .sfmp-view-btn:not(:last-child) {
    border-right: 1px solid var(--sfmp-gray-300, #d1d5db);
}

.sfmp-size-btn:hover, .sfmp-view-btn:hover {
    background: var(--sfmp-gray-50, #f8f9fa);
}

.sfmp-size-active, .sfmp-view-active {
    background: var(--sfmp-primary, #c0392b) !important;
    color: #fff !important;
}

.sfmp-size-btn .dashicons, .sfmp-view-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* ==========================================================================
   GROUP HEADERS
   ========================================================================== */

.sfmp-group-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0 6px;
    margin-top: 8px;
    border-bottom: 2px solid var(--sfmp-primary, #c0392b);
}

.sfmp-group-header:first-child {
    margin-top: 0;
}

.sfmp-group-header .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    color: var(--sfmp-primary, #c0392b);
}

.sfmp-group-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--sfmp-gray-900);
}

.sfmp-group-count {
    font-size: 12px;
    color: var(--sfmp-gray-500);
    background: var(--sfmp-gray-100, #f3f4f6);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ==========================================================================
   FILE GRID — with size variants
   ========================================================================== */

.sfmp-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    min-height: 200px;
}

/* Card sizes */
.sfmp-gallery-grid.sfmp-size-small {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.sfmp-gallery-grid.sfmp-size-large {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
}

/* Small card adjustments */
.sfmp-size-small .sfmp-card-preview { height: 120px; }
.sfmp-size-small .sfmp-card-title { font-size: 12px; }
.sfmp-size-small .sfmp-card-desc { display: none; }
.sfmp-size-small .sfmp-card-meta { font-size: 11px; }
.sfmp-size-small .sfmp-card-actions .sfmp-btn { font-size: 11px; padding: 4px 8px; }

/* Large card adjustments */
.sfmp-size-large .sfmp-card-preview { height: 260px; }
.sfmp-size-large .sfmp-card-title { font-size: 16px; }
.sfmp-size-large .sfmp-card-desc { -webkit-line-clamp: 3; }

/* Full-width card: singola colonna, card orizzontale stile hero.
 * Layout flex-row con thumb a sinistra e info a destra, simile
 * alla vista lista ma con dimensioni generose e descrizione visibile.
 * @since 3.0.0 */
.sfmp-gallery-grid.sfmp-size-full {
    grid-template-columns: 1fr;
    gap: 12px;
}

.sfmp-size-full .sfmp-file-card {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    border-radius: 8px;
}

.sfmp-size-full .sfmp-card-preview {
    width: 75%;
    height: auto;
    min-height: 200px;
    flex-shrink: 0;
    border-radius: 8px 0 0 8px;
}

.sfmp-size-full .sfmp-card-preview img {
    border-radius: 8px 0 0 8px;
}

.sfmp-size-full .sfmp-card-body {
    flex: 1;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.sfmp-size-full .sfmp-card-title {
    font-size: 18px;
    margin-bottom: 6px;
    white-space: normal;
    -webkit-line-clamp: unset;
}

.sfmp-size-full .sfmp-card-desc {
    display: block;
    -webkit-line-clamp: unset;
    -webkit-box-orient: initial;
    overflow: visible;
    font-size: 13px;
    color: var(--sfmp-gray-600, #4b5563);
    line-height: 1.5;
    margin-bottom: 10px;
}

.sfmp-size-full .sfmp-card-meta {
    font-size: 13px;
    margin-bottom: 4px;
}

.sfmp-size-full .sfmp-card-actions {
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    border-top: none;
    border-left: 1px solid var(--sfmp-gray-200, #e5e7eb);
}

.sfmp-size-full .sfmp-card-actions .sfmp-btn {
    white-space: nowrap;
}

/* ==========================================================================
   LIST VIEW
   ========================================================================== */

.sfmp-gallery-grid.sfmp-view-list {
    grid-template-columns: 1fr !important;
    gap: 4px;
}

.sfmp-view-list .sfmp-file-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    border-radius: 4px;
}

.sfmp-view-list .sfmp-card-preview {
    width: 60px;
    height: 48px;
    min-height: 48px;
    flex-shrink: 0;
    border-radius: 4px 0 0 4px;
}

.sfmp-view-list .sfmp-card-body {
    flex: 1;
    padding: 8px 14px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.sfmp-view-list .sfmp-card-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

/* Descrizioni in vista lista: visibili, troncate a 1 riga.
 * @since 3.0.0 — precedentemente nascosti con display:none. */
.sfmp-view-list .sfmp-card-desc {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    -webkit-line-clamp: unset;
    -webkit-box-orient: initial;
    font-size: 12px;
    color: var(--sfmp-gray-500);
    line-height: 1.4;
    margin: 0 0 2px;
}

.sfmp-view-list .sfmp-card-meta {
    font-size: 12px;
}

.sfmp-view-list .sfmp-card-actions {
    display: flex;
    gap: 4px;
    padding: 6px 10px;
    flex-shrink: 0;
    border-top: none;
}

.sfmp-view-list .sfmp-card-actions .sfmp-btn {
    font-size: 12px;
    padding: 4px 10px;
}

.sfmp-gallery-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--sfmp-gray-500);
}

/* ==========================================================================
   FILE CARD
   ========================================================================== */

.sfmp-file-card {
    background: var(--sfmp-white);
    border: 1px solid var(--sfmp-gray-200);
    border-radius: var(--sfmp-radius-lg);
    overflow: hidden;
    box-shadow: var(--sfmp-shadow);
    transition: transform var(--sfmp-transition), box-shadow var(--sfmp-transition);
    display: flex;
    flex-direction: column;
}

.sfmp-file-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--sfmp-shadow-lg);
}

.sfmp-card-preview {
    height: 140px;
    background: var(--sfmp-gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.sfmp-card-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sfmp-card-icon-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.sfmp-card-icon {
    font-size: 40px !important;
    width: 40px !important;
    height: 40px !important;
    color: var(--sfmp-primary-light);
}

.sfmp-card-ext {
    font-size: 12px;
    font-weight: 700;
    color: var(--sfmp-gray-500);
    text-transform: uppercase;
    background: var(--sfmp-gray-200);
    padding: 2px 8px;
    border-radius: 4px;
}

.sfmp-card-body {
    padding: 12px 14px 8px;
    flex: 1;
}

.sfmp-card-title {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--sfmp-gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sfmp-card-desc {
    margin: 0 0 6px;
    font-size: 12px;
    color: var(--sfmp-gray-500);
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.sfmp-card-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.sfmp-card-size {
    font-size: 12px;
    color: var(--sfmp-gray-500);
}

.sfmp-card-category {
    font-size: 11px;
    padding: 1px 8px;
    background: var(--sfmp-gray-50);
    border-radius: 4px;
    color: var(--sfmp-gray-700);
}

.sfmp-card-actions {
    padding: 10px 14px;
    border-top: 1px solid var(--sfmp-gray-200);
    display: flex;
    justify-content: center;
}

.sfmp-card-actions .sfmp-btn {
    justify-content: center;
}

/* Bottone singolo occupa tutta la larghezza. */
.sfmp-card-actions .sfmp-btn-full {
    width: 100%;
}

/* Riga con 2 bottoni inline (Scarica + Visualizza). */
.sfmp-card-actions-row {
    display: flex;
    gap: 6px;
    width: 100%;
}
.sfmp-card-actions-row .sfmp-btn {
    flex: 1;
    text-align: center;
    justify-content: center;
    font-size: 12px;
    padding: 6px 8px;
    white-space: nowrap;
}

/* Bottone Visualizza — outline style. */
.sfmp-btn-view {
    background: transparent;
    color: var(--sfmp-primary);
    border: 1px solid var(--sfmp-primary);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.sfmp-btn-view:hover {
    background: var(--sfmp-primary);
    color: var(--sfmp-white);
}
.sfmp-btn-view .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    margin-right: 2px;
    vertical-align: middle;
}

.sfmp-btn-download:hover {
    background: var(--sfmp-success);
}

/* ==========================================================================
   PAGINATION
   ========================================================================== */

.sfmp-gallery-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin: 24px 0 16px;
    flex-wrap: wrap;
}

.sfmp-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--sfmp-gray-300);
    border-radius: var(--sfmp-radius);
    background: var(--sfmp-white);
    color: var(--sfmp-gray-700);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--sfmp-transition);
    text-decoration: none;
    font-family: var(--sfmp-font);
}

.sfmp-page-btn:hover {
    background: var(--sfmp-gray-100);
    border-color: var(--sfmp-primary-light);
}

.sfmp-page-btn.sfmp-page-active {
    background: var(--sfmp-primary);
    color: var(--sfmp-white);
    border-color: var(--sfmp-primary);
}

.sfmp-page-btn.sfmp-page-disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */

.sfmp-gallery-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--sfmp-gray-500);
}

.sfmp-empty-icon {
    font-size: 64px !important;
    width: 64px !important;
    height: 64px !important;
    color: var(--sfmp-gray-300);
    margin-bottom: 16px;
}

.sfmp-gallery-empty h3 {
    color: var(--sfmp-gray-700);
    margin: 0 0 8px;
}

.sfmp-gallery-empty p {
    margin: 0;
    font-size: 14px;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.sfmp-gallery-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    font-size: 12px;
    color: var(--sfmp-gray-500);
    border-top: 1px solid var(--sfmp-gray-200);
    margin-top: 12px;
}

.sfmp-gallery-brand {
    font-weight: 500;
}

/* ==========================================================================
   DOWNLOAD PAGE
   ========================================================================== */

.sfmp-portal-download {
    max-width: 480px;
    margin: 60px auto;
    text-align: center;
}

.sfmp-download-info {
    background: var(--sfmp-white);
    padding: 40px;
    border-radius: var(--sfmp-radius-lg);
    box-shadow: var(--sfmp-shadow-lg);
}

.sfmp-download-icon {
    font-size: 48px !important;
    width: 48px !important;
    height: 48px !important;
    color: var(--sfmp-primary);
    animation: sfmpPulse 1.5s ease-in-out infinite;
}

@keyframes sfmpPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.sfmp-download-info h2 {
    color: var(--sfmp-primary);
    margin: 16px 0 8px;
}

.sfmp-download-info p {
    color: var(--sfmp-gray-500);
    margin: 0 0 24px;
}

/* ==========================================================================
   CARD PREVIEW — Click overlay (anteprima)
   ========================================================================== */

.sfmp-card-clickable {
    cursor: pointer;
    position: relative;
}

.sfmp-card-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(30, 58, 95, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.25s ease;
}

.sfmp-card-preview-overlay .dashicons {
    color: var(--sfmp-white);
    font-size: 28px;
    width: 28px;
    height: 28px;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.sfmp-card-clickable:hover .sfmp-card-preview-overlay {
    background: rgba(30, 58, 95, 0.45);
}

.sfmp-card-clickable:hover .sfmp-card-preview-overlay .dashicons {
    opacity: 1;
    transform: scale(1);
}

/* ==========================================================================
   LIGHTBOX — Fullscreen immagini + Preview PDF inline
   @see Spec §7: "clic sulla thumbnail → visualizzazione a schermo intero
                   con watermark. Navigazione ←→. Zoom, chiusura con ESC."
   ========================================================================== */

.sfmp-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sfmp-lightbox.sfmp-hidden {
    display: none;
}

body.sfmp-lightbox-open {
    overflow: hidden;
}

.sfmp-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    cursor: pointer;
}

.sfmp-lightbox-container {
    position: relative;
    width: 90vw;
    height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

/* Chiudi */
.sfmp-lightbox-close {
    position: absolute;
    top: -10px;
    right: -10px;
    z-index: 10;
    background: var(--sfmp-danger);
    color: var(--sfmp-white);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sfmp-lightbox-close:hover {
    background: #b02a2d;
    transform: scale(1.1);
}

.sfmp-lightbox-close .dashicons {
    font-size: 22px;
    width: 22px;
    height: 22px;
}

/* Navigazione ←→ */
.sfmp-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
    color: var(--sfmp-white);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.sfmp-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sfmp-lightbox-nav.sfmp-hidden {
    display: none;
}

.sfmp-lightbox-nav .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
}

.sfmp-lightbox-prev {
    left: -60px;
}

.sfmp-lightbox-next {
    right: -60px;
}

/* Contenuto media */
.sfmp-lightbox-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow: hidden;
}

.sfmp-lightbox-media {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.sfmp-lightbox-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

.sfmp-lightbox-loading .sfmp-spinner {
    border-color: rgba(255, 255, 255, 0.2);
    border-top-color: var(--sfmp-white);
}

.sfmp-lightbox-error {
    color: var(--sfmp-danger);
    font-size: 16px;
}

/* Immagine */
.sfmp-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    cursor: zoom-in;
    transition: transform 0.3s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.sfmp-lightbox-img.sfmp-lightbox-zoomed {
    cursor: zoom-out;
    transform: scale(2);
}

/* PDF iframe */
.sfmp-lightbox-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 4px;
    background: var(--sfmp-white);
}

/* Text file iframe (TXT, CSV) */
.sfmp-lightbox-text-frame {
    background: var(--sfmp-gray-50);
    font-family: monospace;
}

/* Video player nel lightbox */
.sfmp-lightbox-video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
    background: #000;
    outline: none;
}

/* Play overlay su card video */
.sfmp-card-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, transform .2s;
    pointer-events: none;
}
.sfmp-card-play-overlay .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
    color: #ffffff;
    margin-left: 3px; /* Centratura ottica del triangolo play. */
}
.sfmp-card-clickable:hover .sfmp-card-play-overlay {
    background: rgba(0, 0, 0, 0.75);
    transform: translate(-50%, -50%) scale(1.1);
}

/* Video card sfondo scuro */
.sfmp-card-video-wrap {
    background: #1e1e28 !important;
}
.sfmp-card-video-wrap .sfmp-card-icon {
    color: #ffffff !important;
}

/* ==========================================================================
   LIGHTBOX — Pannello info documento (DOC, DOCX, XLS, XLSX)
   Per formati non renderizzabili nel browser.
   ========================================================================== */

.sfmp-lightbox-doc-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px;
    text-align: center;
}

.sfmp-lightbox-doc-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.sfmp-doc-badge {
    display: inline-block;
    padding: 14px 28px;
    border-radius: 8px;
    font-size: 28px;
    font-weight: 800;
    color: var(--sfmp-white);
    letter-spacing: 2px;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.sfmp-doc-badge-pdf  { background: #E53935; }
.sfmp-doc-badge-doc  { background: #1565C0; }
.sfmp-doc-badge-docx { background: #1565C0; }
.sfmp-doc-badge-xls  { background: #2E7D32; }
.sfmp-doc-badge-xlsx { background: #2E7D32; }
.sfmp-doc-badge-txt  { background: #546E7A; }
.sfmp-doc-badge-csv  { background: #546E7A; }

.sfmp-lightbox-doc-title {
    color: var(--sfmp-white);
    font-size: 18px;
    font-weight: 600;
    margin: 8px 0 0;
    word-break: break-word;
    max-width: 500px;
}

.sfmp-lightbox-doc-msg {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
    max-width: 400px;
}

/* Info bar */
.sfmp-lightbox-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px 0 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
}

.sfmp-lightbox-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.sfmp-lightbox-counter {
    flex-shrink: 0;
    opacity: 0.7;
}

/* Lazy loading transition */
.sfmp-card-thumb {
    transition: opacity 0.3s ease;
}

.sfmp-card-thumb[data-src] {
    opacity: 0.5;
}

.sfmp-card-thumb.sfmp-lazy-loaded {
    opacity: 1;
}

/* ==========================================================================
   CARD CHECKBOX — multi-select per download ZIP
   ========================================================================== */

.sfmp-card-checkbox-wrap {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sfmp-file-card {
    position: relative;
}

.sfmp-card-checkbox {
    display: none;
}

.sfmp-card-checkbox-mark {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255,255,255,0.8);
    border-radius: 4px;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

.sfmp-card-checkbox:checked + .sfmp-card-checkbox-mark {
    background: var(--sfmp-primary, #c0392b);
    border-color: var(--sfmp-primary, #c0392b);
}

.sfmp-card-checkbox:checked + .sfmp-card-checkbox-mark::after {
    content: '✓';
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

.sfmp-card-selected {
    outline: 3px solid var(--sfmp-primary, #c0392b);
    outline-offset: -1px;
    border-radius: 8px;
}

/* ==========================================================================
   SELECTION BAR — barra selezione multipla fissa in basso
   ========================================================================== */

.sfmp-selection-bar {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    background: var(--sfmp-gray-900, #111827);
    color: #fff;
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -4px 16px rgba(0,0,0,.25);
    margin-top: 16px;
}

.sfmp-selection-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
}

.sfmp-selection-info .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    color: var(--sfmp-primary, #c0392b);
}

.sfmp-selection-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sfmp-selection-actions .sfmp-btn {
    border-color: rgba(255,255,255,0.3);
    color: #fff;
}

.sfmp-selection-actions .sfmp-btn-primary {
    background: var(--sfmp-primary, #c0392b);
    border-color: var(--sfmp-primary, #c0392b);
}

/* ==========================================================================
   DOCUMENT PREVIEW — DOCX/XLSX inline nel lightbox
   ========================================================================== */

.sfmp-doc-preview {
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    width: 100%;
    max-width: 900px;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    color: #333;
}

.sfmp-doc-preview-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    flex-shrink: 0;
}

.sfmp-doc-preview-body {
    flex: 1;
    overflow: auto;
    padding: 24px;
    font-size: 14px;
    line-height: 1.7;
}

/* DOCX typography */
.sfmp-doc-preview-docx .sfmp-doc-preview-body h1 { font-size: 24px; margin: 16px 0 8px; }
.sfmp-doc-preview-docx .sfmp-doc-preview-body h2 { font-size: 20px; margin: 14px 0 6px; }
.sfmp-doc-preview-docx .sfmp-doc-preview-body h3 { font-size: 17px; margin: 12px 0 4px; }
.sfmp-doc-preview-docx .sfmp-doc-preview-body p { margin: 0 0 10px; }
.sfmp-doc-preview-docx .sfmp-doc-preview-body ul,
.sfmp-doc-preview-docx .sfmp-doc-preview-body ol { margin: 0 0 10px 20px; }
.sfmp-doc-preview-docx .sfmp-doc-preview-body table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.sfmp-doc-preview-docx .sfmp-doc-preview-body td,
.sfmp-doc-preview-docx .sfmp-doc-preview-body th { border: 1px solid #d1d5db; padding: 6px 10px; text-align: left; }
.sfmp-doc-preview-docx .sfmp-doc-preview-body th { background: #f3f4f6; font-weight: 600; }
.sfmp-doc-preview-docx .sfmp-doc-preview-body img { max-width: 100%; height: auto; }

/* XLSX tables */
.sfmp-doc-preview-xlsx .sfmp-doc-preview-body table { border-collapse: collapse; width: 100%; font-size: 13px; }
.sfmp-doc-preview-xlsx .sfmp-doc-preview-body td,
.sfmp-doc-preview-xlsx .sfmp-doc-preview-body th { border: 1px solid #d1d5db; padding: 4px 8px; white-space: nowrap; }
.sfmp-doc-preview-xlsx .sfmp-doc-preview-body th,
.sfmp-doc-preview-xlsx .sfmp-doc-preview-body tr:first-child td { background: #f3f4f6; font-weight: 600; }
.sfmp-doc-preview-xlsx .sfmp-doc-preview-body tr:nth-child(even) td { background: #f9fafb; }

/* Sheet tabs */
.sfmp-sheet-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e5e7eb;
    background: #f8f9fa;
    overflow-x: auto;
    flex-shrink: 0;
}

.sfmp-sheet-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}

.sfmp-sheet-tab:hover { color: #333; }

.sfmp-sheet-tab-active {
    color: var(--sfmp-primary, #c0392b);
    border-bottom-color: var(--sfmp-primary, #c0392b);
    font-weight: 600;
}

.sfmp-sheet-content {
    min-height: 100px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .sfmp-portal { padding: 12px 16px; }

    .sfmp-gallery-header { flex-direction: column; gap: 12px; text-align: center; }
    .sfmp-gallery-user { justify-content: center; }

    .sfmp-gallery-toolbar { gap: 8px; }
    .sfmp-search-box { width: 100%; }
    .sfmp-filter-group { flex-wrap: wrap; width: 100%; }
    .sfmp-select-field { min-width: 0; max-width: none; flex: 1 1 140px; }

    .sfmp-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }

    /* Full-width su tablet: card verticale */
    .sfmp-size-full .sfmp-file-card { flex-direction: column; }
    .sfmp-size-full .sfmp-card-preview { width: 100%; min-height: 180px; border-radius: 8px 8px 0 0; }
    .sfmp-size-full .sfmp-card-preview img { border-radius: 8px 8px 0 0; }
    .sfmp-size-full .sfmp-card-actions { flex-direction: row; border-left: none; border-top: 1px solid var(--sfmp-gray-200, #e5e7eb); }

    /* Lightbox responsive */
    .sfmp-lightbox-container { width: 95vw; height: 80vh; }
    .sfmp-lightbox-prev { left: 5px; }
    .sfmp-lightbox-next { right: 5px; }
    .sfmp-lightbox-nav { width: 38px; height: 38px; }
    .sfmp-lightbox-nav .dashicons { font-size: 22px; width: 22px; height: 22px; }
}

@media (max-width: 480px) {
    .sfmp-gallery-grid { grid-template-columns: 1fr; }
    .sfmp-card-preview { height: 120px; }

    /* Dual button su mobile: stack verticale se troppo stretto. */
    .sfmp-card-actions-row {
        flex-direction: row;
    }
    .sfmp-card-actions-row .sfmp-btn {
        font-size: 11px;
        padding: 5px 6px;
    }

    .sfmp-portal-login { margin: 20px auto; }
    .sfmp-login-view { padding: 20px; }

    .sfmp-lightbox-container { width: 100vw; height: 90vh; }
    .sfmp-lightbox-close { top: 5px; right: 5px; }

    /* Lightbox doc info responsive. */
    .sfmp-lightbox-doc-info { padding: 20px; }
    .sfmp-doc-badge { font-size: 22px; padding: 10px 20px; }
    .sfmp-lightbox-doc-title { font-size: 15px; }

    /* Selection bar mobile: stack. */
    .sfmp-selection-bar { flex-direction: column; gap: 8px; text-align: center; }
    .sfmp-selection-actions { justify-content: center; flex-wrap: wrap; }

    /* Doc preview mobile. */
    .sfmp-doc-preview { max-height: 70vh; }
    .sfmp-doc-preview-body { padding: 12px; font-size: 13px; }

    /* Viewbar mobile. */
    .sfmp-gallery-viewbar { gap: 8px; }
    .sfmp-viewbar-label { font-size: 11px; }
}
