/**
 * FP Distributor Media Kit — Frontend (shortcode, login, media kit)
 * Usa variabili CSS personalizzabili da Impostazioni → Aspetto
 */

/* --- Base tipografia e colore (classe fpdmk-ui sugli shortcode) --- */
.fpdmk-ui {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: #1f2937;
    line-height: 1.5;
}

.fpdmk-register-wrap,
.fpdmk-login-wrap,
.fpdmk-media-kit {
    max-width: 480px;
    margin: 0 auto 2rem;
}

.fpdmk-media-kit {
    max-width: 960px;
    padding: 1.5rem clamp(0.75rem, 2vw, 1.25rem) 2.75rem;
    box-sizing: border-box;
}

/* Pannello login / registrazione */
.fpdmk-login-wrap.fpdmk-ui,
.fpdmk-register-wrap.fpdmk-ui {
    position: relative;
    max-width: 440px;
    padding: 1.85rem 1.6rem 2.1rem;
    background: var(--fpdmk-card-bg, #fff);
    border: 1px solid var(--fpdmk-card-border, #e5e7eb);
    border-radius: var(--fpdmk-card-radius, 14px);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 12px 40px -16px rgba(15, 23, 42, 0.14);
    overflow: hidden;
}

.fpdmk-login-wrap.fpdmk-ui::before,
.fpdmk-register-wrap.fpdmk-ui::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(
        90deg,
        var(--fpdmk-btn-primary, #667eea),
        var(--fpdmk-btn-primary-end, #764ba2)
    );
}

.fpdmk-message {
    padding: 14px 18px 14px 16px;
    border-radius: var(--fpdmk-radius, 10px);
    margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.fpdmk-message-success {
    background: #d1fae5;
    border-left: 4px solid #10b981;
}
.fpdmk-message-error {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
}
.fpdmk-message-warning {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
}
.fpdmk-message-info {
    background: #e0e7ff;
    border-left: 4px solid var(--fpdmk-input-focus, #667eea);
}

.fpdmk-form .fpdmk-field {
    margin-bottom: 18px;
}

.fpdmk-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #374151;
}

.fpdmk-form .required {
    color: #ef4444;
}

.fpdmk-hint {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.45;
}

.fpdmk-input {
    width: 100%;
    padding: 12px 14px;
    min-height: 46px;
    box-sizing: border-box;
    border: 2px solid var(--fpdmk-input-border, #e5e7eb);
    border-radius: var(--fpdmk-radius, 10px);
    font-size: 16px;
    color: #111827;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.fpdmk-input:focus {
    border-color: var(--fpdmk-input-focus, #667eea);
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.fpdmk-input:focus-visible {
    outline: 2px solid var(--fpdmk-input-focus, #667eea);
    outline-offset: 2px;
}

.fpdmk-field-submit {
    margin-top: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.fpdmk-link {
    text-decoration: none;
    font-size: 14px;
}

.fpdmk-link-muted {
    color: #6b7280;
}

.fpdmk-link-muted:hover {
    color: var(--fpdmk-input-focus, #667eea);
    text-decoration: underline;
}

.fpdmk-field-checkbox {
    margin-bottom: 12px;
}

.fpdmk-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
    color: #374151;
}

.fpdmk-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--fpdmk-input-focus, #667eea);
}

.fpdmk-empty-state {
    padding: 2.5rem 1.5rem;
    text-align: center;
    background: var(--fpdmk-card-bg, #fff);
    border: 1px dashed var(--fpdmk-card-border, #cbd5e1);
    border-radius: var(--fpdmk-card-radius, 14px);
}

.fpdmk-empty-state .fpdmk-message {
    margin-bottom: 0;
    text-align: left;
    max-width: 32rem;
    margin-left: auto;
    margin-right: auto;
}

.fpdmk-btn.is-loading {
    opacity: 0.7;
    pointer-events: none;
    cursor: not-allowed;
}

.fpdmk-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    min-height: 46px;
    box-sizing: border-box;
    border-radius: var(--fpdmk-radius, 10px);
    font-weight: 600;
    font-size: 16px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.fpdmk-btn:focus-visible {
    outline: 2px solid var(--fpdmk-input-focus, #667eea);
    outline-offset: 2px;
}

.fpdmk-btn-primary {
    background: linear-gradient(
        135deg,
        var(--fpdmk-btn-primary, #667eea) 0%,
        var(--fpdmk-btn-primary-end, #764ba2) 100%
    );
    color: #fff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.35);
}

.fpdmk-btn-primary:hover,
.fpdmk-btn-primary:focus,
.fpdmk-btn-primary:focus-visible,
.fpdmk-btn-primary:active {
    opacity: 0.95;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
    color: #fff;
}

.fpdmk-ui a.fpdmk-btn.fpdmk-btn-primary,
.fpdmk-ui a.fpdmk-btn.fpdmk-btn-primary:hover,
.fpdmk-ui a.fpdmk-btn.fpdmk-btn-primary:focus,
.fpdmk-ui a.fpdmk-btn.fpdmk-btn-primary:focus-visible,
.fpdmk-ui a.fpdmk-btn.fpdmk-btn-primary:active,
.fpdmk-ui a.fpdmk-btn.fpdmk-btn-primary:visited {
    color: #fff !important;
    text-decoration: none;
}

.fpdmk-btn-secondary {
    background: var(--fpdmk-btn-secondary, #e5e7eb);
    color: #1f2937;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.fpdmk-btn-secondary:hover {
    background: var(--fpdmk-btn-secondary-hover, #d1d5db);
}

/* --- Media Kit — intestazione e filtri --- */
.fpdmk-media-kit-header {
    margin-bottom: 1.75rem;
}

.fpdmk-media-kit-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1.5rem 1.35rem 1.6rem;
    border-radius: var(--fpdmk-card-radius, 14px);
    background: linear-gradient(135deg, #f3f4ff 0%, #faf5ff 100%);
    border: 1px solid var(--fpdmk-card-border, #e5e7eb);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 8px 28px -12px rgba(99, 102, 241, 0.15);
}

.fpdmk-media-kit-hero-text {
    flex: 1 1 220px;
    min-width: 0;
}

.fpdmk-media-kit-title {
    font-size: clamp(1.35rem, 2.5vw, 1.85rem);
    font-weight: 700;
    margin: 0 0 0.4rem;
    color: #111827;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.fpdmk-media-kit-desc {
    color: #4b5563;
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.55;
    max-width: 36rem;
}

.fpdmk-media-kit-actions {
    flex: 0 0 auto;
    align-self: center;
}

.fpdmk-btn-logout {
    white-space: nowrap;
}

.fpdmk-filters-card {
    margin-bottom: 2rem;
    padding: 1.35rem 1.4rem 1.45rem;
    background: var(--fpdmk-card-bg, #fff);
    border: 1px solid var(--fpdmk-card-border, #e5e7eb);
    border-radius: var(--fpdmk-card-radius, 14px);
    box-shadow:
        0 1px 3px rgba(15, 23, 42, 0.05),
        0 10px 36px -18px rgba(15, 23, 42, 0.12);
}

.fpdmk-filters {
    margin: 0;
}

.fpdmk-filters-heading {
    margin: 0 0 1.1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

.fpdmk-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem 1.25rem;
    align-items: end;
}

.fpdmk-filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}

.fpdmk-filter-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #475569;
    letter-spacing: 0.01em;
}

.fpdmk-filters-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-top: 1.35rem;
    padding-top: 1.15rem;
    border-top: 1px solid var(--fpdmk-card-border, #e5e7eb);
}

.fpdmk-link-reset {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--fpdmk-input-focus, #667eea);
}

.fpdmk-link-reset:hover {
    text-decoration: underline;
}

.fpdmk-select {
    width: 100%;
    padding: 10px 36px 10px 14px;
    min-height: 46px;
    box-sizing: border-box;
    border: 2px solid var(--fpdmk-input-border, #e5e7eb);
    border-radius: var(--fpdmk-radius, 10px);
    font-size: 15px;
    min-width: 0;
    background-color: #fff;
    color: #111827;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.fpdmk-select:focus {
    border-color: var(--fpdmk-input-focus, #667eea);
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.fpdmk-select:focus-visible {
    outline: 2px solid var(--fpdmk-input-focus, #667eea);
    outline-offset: 2px;
}

.fpdmk-hint-reset {
    margin-top: 16px;
    font-size: 13px;
}

.fpdmk-section {
    margin-bottom: 2.5rem;
    background: var(--fpdmk-section-bg, transparent);
}

.fpdmk-section-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--fpdmk-card-border, #e5e7eb);
}

/* Elenco asset (sostituisce griglia card) */
.fpdmk-asset-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--fpdmk-card-border, #e5e7eb);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.fpdmk-asset-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.15s ease;
}

.fpdmk-asset-row:last-child {
    border-bottom: none;
}

.fpdmk-asset-row:hover {
    background: #f8fafc;
}

.fpdmk-asset-row--bulk .fpdmk-asset-row-check {
    flex: 0 0 2.25rem;
}

.fpdmk-asset-row-check {
    display: flex;
    align-items: center;
    justify-content: center;
}

.fpdmk-asset-row-main {
    flex: 1 1 220px;
    min-width: 0;
}

.fpdmk-asset-row-lang {
    flex-shrink: 0;
    margin-left: auto;
}

.fpdmk-asset-row-classif {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.45rem;
    margin-bottom: 0.35rem;
}

.fpdmk-asset-row-classif .fpdmk-card-category-chip {
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.fpdmk-asset-row-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: #111827;
    line-height: 1.35;
}

.fpdmk-asset-row-desc {
    font-size: 0.8125rem;
    color: #64748b;
    margin: 0.25rem 0 0;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fpdmk-asset-row-lang-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

.fpdmk-asset-row-action {
    flex-shrink: 0;
}

.fpdmk-btn-download--row {
    margin-top: 0;
    padding: 0.45rem 0.9rem;
    font-size: 0.8125rem;
    white-space: nowrap;
}

.fpdmk-asset-row-no-file {
    font-size: 0.8125rem;
    color: #94a3b8;
    font-style: italic;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .fpdmk-asset-row-main {
        flex: 1 1 100%;
    }

    .fpdmk-asset-row-lang {
        margin-left: 0;
    }

    .fpdmk-asset-row-action {
        flex: 1 1 100%;
        display: flex;
        justify-content: flex-end;
    }

    .fpdmk-asset-row-action .fpdmk-btn-download--row {
        width: 100%;
        max-width: 16rem;
        text-align: center;
        box-sizing: border-box;
    }
}

/* Cartelle nel Media Kit */
.fpdmk-folder-block {
    margin-bottom: 2.25rem;
    padding: 1.35rem 1.4rem 1.5rem;
    background: var(--fpdmk-card-bg, #fff);
    border: 1px solid var(--fpdmk-card-border, #e5e7eb);
    border-radius: var(--fpdmk-card-radius, 14px);
    box-shadow: 0 2px 14px rgba(15, 23, 42, 0.05);
}

.fpdmk-folder-block--uncategorized {
    border-color: #c7d2fe;
    background: linear-gradient(180deg, #eef2ff 0%, var(--fpdmk-card-bg, #fff) 48%);
}

.fpdmk-folder-head {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--fpdmk-card-border, #e5e7eb);
}

.fpdmk-folder-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.fpdmk-folder-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 0.35rem;
    color: #1f2937;
    line-height: 1.3;
    padding-left: 0.65rem;
    border-left: 3px solid var(--fpdmk-btn-primary, #667eea);
    flex: 1 1 auto;
    min-width: 0;
}

.fpdmk-folder-head-row .fpdmk-folder-title {
    margin-bottom: 0;
}

.fpdmk-accordion-trigger {
    position: relative;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    min-height: 2.5rem;
    margin: 0;
    padding: 0.35rem;
    border: 1px solid var(--fpdmk-card-border, #e5e7eb);
    border-radius: var(--fpdmk-radius, 10px);
    background: #fff;
    color: #475569;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.fpdmk-accordion-trigger:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
}

.fpdmk-accordion-trigger:focus {
    outline: 2px solid var(--fpdmk-input-focus, #667eea);
    outline-offset: 2px;
}

.fpdmk-accordion-icon {
    display: block;
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.fpdmk-accordion-trigger:not(.is-collapsed) .fpdmk-accordion-icon {
    transform: rotate(-135deg);
    margin-top: 0.2rem;
}

.fpdmk-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.fpdmk-folder-hint {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.55;
    color: #64748b;
    max-width: 52rem;
}

.fpdmk-folder-panel[hidden] {
    display: none;
}

.fpdmk-section-nested {
    margin-bottom: 1.5rem;
}

.fpdmk-section-nested:last-child {
    margin-bottom: 0;
}

.fpdmk-section-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    flex-wrap: wrap;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 0.65rem;
}

.fpdmk-section-nested .fpdmk-section-title {
    font-size: 0.9375rem;
    font-weight: 700;
    margin: 0;
    padding: 0 0 0 0.65rem;
    border-left: 3px solid #a5b4fc;
    color: #334155;
    flex: 1 1 auto;
    min-width: 0;
}

.fpdmk-section-panel {
    margin-top: 0;
}

.fpdmk-section-panel[hidden] {
    display: none;
}

/* Toolbar risultati + bulk ZIP */
.fpdmk-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 0.85rem 1rem;
    background: #f8fafc;
    border: 1px solid var(--fpdmk-card-border, #e5e7eb);
    border-radius: var(--fpdmk-card-radius, 14px);
}

.fpdmk-results-count {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #334155;
}

.fpdmk-bulk-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.85rem 1.25rem;
}

.fpdmk-bulk-select-all {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
}

.fpdmk-bulk-select-all input {
    width: 18px;
    height: 18px;
    accent-color: var(--fpdmk-input-focus, #667eea);
}

.fpdmk-bulk-unavailable {
    margin: 0;
    font-size: 0.8125rem;
    color: #64748b;
}

.fpdmk-filters-grid .fpdmk-filter-field-wide {
    grid-column: 1 / -1;
}

.fpdmk-card-category-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #4338ca;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(102, 126, 234, 0.35);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

/* Etichetta da sola cartella (nessuna fp_dmk_category): stile leggermente distinto */
.fpdmk-card-category-chip--folder {
    color: #0f766e;
    border-color: rgba(13, 148, 136, 0.4);
    background: rgba(240, 253, 250, 0.95);
}

.fpdmk-card-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--fpdmk-input-focus, #667eea);
    vertical-align: middle;
}

/* Password + footer form */
.fpdmk-password-wrap {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.fpdmk-password-wrap .fpdmk-input {
    flex: 1;
    min-width: 0;
}

.fpdmk-btn-password-toggle {
    flex: 0 0 auto;
    padding: 0 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: var(--fpdmk-radius, 10px);
    border: 2px solid var(--fpdmk-input-border, #e5e7eb);
    background: #fff;
    color: #475569;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.fpdmk-btn-password-toggle:hover {
    border-color: var(--fpdmk-input-focus, #667eea);
    background: #f8fafc;
}

.fpdmk-form-footer {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--fpdmk-card-border, #e5e7eb);
    font-size: 0.875rem;
}

.fpdmk-form-footer-sep {
    color: #cbd5e1;
}

.fpdmk-password-strength {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    min-height: 1.25em;
}

.fpdmk-password-strength--weak {
    color: #dc2626;
}

.fpdmk-password-strength--fair {
    color: #ca8a04;
}

.fpdmk-password-strength--good {
    color: #16a34a;
}
