/*!
 * Mass Mailing Pro — Frontend CSS
 * Fase 1: Contatti + Liste + Query Builder
 *
 * Scope: tutti i selettori prefissati `mmp-` per non collidere con il tema.
 * Box-sizing reset locale.
 */

.mmp-page,
.mmp-page * {
    box-sizing: border-box;
}

.mmp-page {
    max-width: 1280px;
    margin: 30px auto;
    padding: 0 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1d2327;
}

/* ===== Header ===== */
.mmp-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}
.mmp-page-header h1 {
    margin: 0 0 5px;
    font-size: 28px;
    line-height: 1.2;
}
.mmp-subtitle {
    margin: 0;
    color: #50575e;
    font-size: 14px;
}
.mmp-header-stats {
    display: flex;
    gap: 15px;
}
.mmp-stat {
    background: #f6f7f7;
    padding: 12px 18px;
    border-radius: 8px;
    text-align: center;
    min-width: 110px;
}
.mmp-stat-success { background: #ecf7e8; color: #1e5b1e; }
.mmp-stat-value { display: block; font-size: 22px; font-weight: 700; }
.mmp-stat-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: #50575e; margin-top: 3px; }
.mmp-stat-success .mmp-stat-label { color: #1e5b1e; }

/* ===== Card ===== */
.mmp-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.mmp-card-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    flex-wrap: wrap;
}
.mmp-toolbar-filters {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    flex-wrap: wrap;
}
.mmp-toolbar-info {
    color: #50575e;
    font-size: 13px;
}

/* ===== Form controls ===== */
.mmp-input,
.mmp-page input[type="text"],
.mmp-page input[type="email"],
.mmp-page input[type="number"],
.mmp-page input[type="date"],
.mmp-page select,
.mmp-page textarea {
    padding: 8px 12px;
    border: 1px solid #c8ccd0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: #1d2327;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.mmp-input:focus,
.mmp-page input:focus,
.mmp-page select:focus,
.mmp-page textarea:focus {
    border-color: #6B2C91;
    outline: none;
    box-shadow: 0 0 0 2px rgba(107, 44, 145, 0.15);
}
.mmp-search-input {
    flex: 1;
    min-width: 220px;
    max-width: 360px;
}
.mmp-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #1d2327;
    cursor: pointer;
}
.mmp-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1d2327;
    margin-bottom: 6px;
}
.mmp-field { margin-bottom: 16px; }
.mmp-field-row { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: end; margin-bottom: 16px; }
.mmp-helper { color: #646970; font-size: 13px; line-height: 1.5; margin: 5px 0 0; }

.mmp-radio-group { display: flex; gap: 8px; }
.mmp-radio-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border: 1px solid #c8ccd0;
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
    background: #fff;
    transition: all 0.15s;
}
.mmp-radio-pill input { margin-right: 6px; }
.mmp-radio-pill:has(input:checked) {
    background: #6B2C91;
    color: #fff;
    border-color: #6B2C91;
}
.mmp-radio-pill input:disabled + span { opacity: 0.5; }

/* ===== Buttons ===== */
.mmp-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.mmp-button-primary {
    background: #6B2C91;
    color: #fff;
    border-color: #6B2C91;
}
.mmp-button-primary:hover { background: #5a2479; }
.mmp-button-secondary {
    background: #fff;
    color: #1d2327;
    border-color: #c8ccd0;
}
.mmp-button-secondary:hover { background: #f6f7f7; }
.mmp-button-small {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    font-size: 12px;
    background: #fff;
    color: #1d2327;
    border: 1px solid #c8ccd0;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
}
.mmp-button-small:hover { background: #f6f7f7; }
.mmp-button-danger {
    color: #b32d2e;
    border-color: #c8ccd0;
}
.mmp-button-danger:hover { background: #fcebec; border-color: #b32d2e; }

/* ===== Table ===== */
.mmp-table-wrapper { overflow-x: auto; }
.mmp-table {
    width: 100%;
    border-collapse: collapse;
}
.mmp-table th,
.mmp-table td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    vertical-align: middle;
}
.mmp-table thead th {
    background: #fafafa;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #646970;
}
.mmp-table tbody tr:hover { background: #fafbfc; }
.mmp-col-actions { white-space: nowrap; text-align: right; }
.mmp-row-sub { color: #646970; font-size: 12px; margin-top: 2px; }
.mmp-loading-row,
.mmp-empty-row {
    text-align: center !important;
    padding: 50px 20px !important;
    color: #8c8f94 !important;
    font-style: italic;
}

/* ===== Badges ===== */
.mmp-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
}
.mmp-badge-ok { background: #ecf7e8; color: #1e5b1e; }
.mmp-badge-warn { background: #fff5cd; color: #835900; }
.mmp-badge-muted { background: #f0f0f1; color: #646970; }
.mmp-badge-dyn { background: #ede5f3; color: #5a2479; }
.mmp-badge-static { background: #e0f0ff; color: #135e96; }

/* ===== Pagination ===== */
.mmp-pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    padding: 15px 20px;
    border-top: 1px solid #f0f0f0;
    flex-wrap: wrap;
}
.mmp-pag-btn {
    min-width: 36px;
    padding: 6px 12px;
    border: 1px solid #c8ccd0;
    background: #fff;
    color: #1d2327;
    border-radius: 5px;
    font-size: 13px;
    cursor: pointer;
}
.mmp-pag-btn:hover { background: #f6f7f7; }
.mmp-pag-btn-active {
    background: #6B2C91;
    color: #fff;
    border-color: #6B2C91;
    cursor: default;
}
.mmp-pag-btn-disabled {
    color: #c8ccd0;
    cursor: not-allowed;
}
.mmp-pag-ellipsis {
    padding: 0 4px;
    color: #8c8f94;
}

/* ===== Notices ===== */
.mmp-notice {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}
.mmp-notice-warning {
    background: #fff8e1;
    border-left: 4px solid #f0c36d;
    color: #735a00;
}

/* ===== Modal ===== */
.mmp-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 17, 21, 0.55);
    z-index: 99998;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}
.mmp-modal-overlay[hidden] { display: none !important; }
body.mmp-modal-open { overflow: hidden; }

.mmp-modal {
    background: #fff;
    border-radius: 10px;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 80px);
}
.mmp-modal-large { max-width: 920px; }

.mmp-modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mmp-modal-header h2 { margin: 0; font-size: 18px; }
.mmp-modal-close {
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: #8c8f94;
    cursor: pointer;
    padding: 0 6px;
}
.mmp-modal-close:hover { color: #1d2327; }
.mmp-modal-body {
    padding: 22px 24px;
    overflow-y: auto;
}
.mmp-modal-footer {
    padding: 14px 24px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== Query Builder ===== */
.mmp-dynamic-section {
    margin-top: 20px;
    padding: 16px;
    background: #fafafa;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
}
.mmp-section-header h3 { margin: 0 0 4px; font-size: 16px; }
.mmp-section-header .mmp-helper { margin-bottom: 14px; }

.mmp-qb-group {
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    padding: 12px;
    background: #fff;
    margin-top: 12px;
}
.mmp-qb-depth-0 { border: 1px solid #c4a8d9; background: #fdfbff; }
.mmp-qb-depth-1 { background: #f7f7fa; }
.mmp-qb-depth-2 { background: #ffffff; }
.mmp-qb-depth-3 { background: #f9f9f9; }

.mmp-qb-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-bottom: 10px;
    border-bottom: 1px dashed #e5e5e5;
    margin-bottom: 10px;
}
.mmp-qb-label { font-size: 13px; color: #646970; }
.mmp-qb-logic {
    padding: 4px 10px;
    border: 1px solid #6B2C91;
    background: #fff;
    color: #6B2C91;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
}
.mmp-qb-group-actions {
    margin-left: auto;
    display: flex;
    gap: 5px;
}
.mmp-qb-rules { display: flex; flex-direction: column; gap: 8px; }
.mmp-qb-rule {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(140px, auto) minmax(180px, 2fr) auto;
    gap: 8px;
    align-items: center;
    padding: 8px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
}
.mmp-qb-field,
.mmp-qb-op {
    padding: 7px 10px;
    border: 1px solid #c8ccd0;
    border-radius: 5px;
    font-size: 13px;
    background: #fff;
}
.mmp-qb-value {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.mmp-qb-value-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #c8ccd0;
    border-radius: 5px;
    font-size: 13px;
}
.mmp-qb-value select[multiple] { min-height: 80px; }
.mmp-qb-sep { color: #8c8f94; font-size: 13px; padding: 0 4px; }
.mmp-qb-remove { padding: 5px 8px !important; }

@media (max-width: 720px) {
    .mmp-qb-rule {
        grid-template-columns: 1fr;
    }
}

/* ===== Preview ===== */
.mmp-preview-box {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e5e5e5;
}
.mmp-preview-result {
    margin-top: 12px;
    padding: 14px;
    background: #f0f7ff;
    border: 1px solid #c7daf2;
    border-radius: 8px;
    font-size: 14px;
}
.mmp-preview-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}
.mmp-preview-stats strong { font-size: 18px; }
.mmp-text-success { color: #1e5b1e; }
.mmp-preview-sample { margin-top: 12px; }
.mmp-preview-sample summary { cursor: pointer; color: #6B2C91; font-weight: 500; }
.mmp-preview-sample ul { margin: 8px 0 0 0; padding-left: 20px; font-size: 13px; }
.mmp-preview-sample li { padding: 2px 0; }

/* ===== Members modal ===== */
.mmp-members-toolbar { margin-bottom: 14px; }
.mmp-members-toolbar input { width: 100%; }
.mmp-members-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.mmp-members-column h4 {
    margin: 0 0 8px;
    font-size: 13px;
    color: #646970;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.mmp-members-list {
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    background: #fff;
    max-height: 360px;
    overflow-y: auto;
}
.mmp-members-list .mmp-empty,
.mmp-members-list .mmp-helper {
    padding: 16px;
    text-align: center;
    color: #8c8f94;
    font-style: italic;
}
.mmp-member-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}
.mmp-member-row:last-child { border-bottom: none; }

@media (max-width: 720px) {
    .mmp-members-grid { grid-template-columns: 1fr; }
}

/* ===== Toast ===== */
.mmp-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 18px;
    border-radius: 8px;
    background: #1d2327;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 99999;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    max-width: 400px;
}
.mmp-toast-visible { opacity: 1; transform: translateY(0); }
.mmp-toast-ok { background: #2e7d32; }
.mmp-toast-error { background: #b32d2e; }
.mmp-toast-info { background: #1d2327; }

/* ===== Templates grid ===== */
.mmp-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}
.mmp-template-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.15s, transform 0.15s;
}
.mmp-template-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.mmp-template-thumb {
    background: #f6f7f7;
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c8ccd0;
    overflow: hidden;
}
.mmp-template-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}
.mmp-template-thumb-empty {
    font-size: 48px;
}
.mmp-template-body {
    padding: 14px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.mmp-template-name {
    font-weight: 600;
    color: #1d2327;
    margin-bottom: 4px;
    font-size: 15px;
}
.mmp-template-meta {
    color: #646970;
    font-size: 12px;
    margin-bottom: 12px;
}
.mmp-template-actions {
    display: flex;
    gap: 6px;
    margin-top: auto;
    flex-wrap: wrap;
}
.mmp-template-category {
    display: inline-block;
    padding: 2px 8px;
    background: #ede5f3;
    color: #5a2479;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    margin-right: 6px;
}

/* ===== Placeholder pages (Fase 0) ===== */
.mmp-placeholder { box-sizing: border-box; }
.mmp-placeholder *,
.mmp-placeholder *::before,
.mmp-placeholder *::after { box-sizing: inherit; }

/* ============================================================
   WIZARD CAMPAGNE (Fase 3) — pagina intera, 5 step
   Accenti coerenti con il resto del plugin (viola #6B2C91).
   ============================================================ */
.mmp-wizard {
    max-width: 1100px;
    margin: 24px auto;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.mmp-wizard-top {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    background: #1d2327;
    color: #fff;
}
.mmp-wizard-back { color: #cdd2da; text-decoration: none; font-size: 13px; }
.mmp-wizard-back:hover { color: #fff; }
.mmp-wizard-title { font-weight: 600; font-size: 15px; }
.mmp-wizard-save-status { margin-left: auto; font-size: 12px; color: #9ad29a; }

/* Barra step */
.mmp-wizard-steps {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    background: #faf7fc;
    border-bottom: 1px solid #ece6f1;
}
.mmp-wz-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 8px;
    font-size: 13px;
    color: #8a7d96;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    user-select: none;
    white-space: nowrap;
}
.mmp-wz-tab .mmp-wz-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #e3dae9;
    color: #6b2c91;
    font-size: 12px;
    font-weight: 700;
}
.mmp-wz-tab.is-active { color: #6B2C91; font-weight: 600; border-bottom-color: #6B2C91; }
.mmp-wz-tab.is-active .mmp-wz-num { background: #6B2C91; color: #fff; }

/* Corpo step */
.mmp-wizard-body { padding: 28px 28px 8px; min-height: 320px; }
.mmp-wz-step { display: none; }
.mmp-wz-step.is-active { display: block; }
.mmp-wz-step h2 { margin: 0 0 18px; font-size: 18px; color: #1d2327; }
.mmp-wz-step h3 { margin: 0 0 10px; font-size: 14px; color: #1d2327; }

.mmp-wizard .mmp-field { display: block; margin-bottom: 16px; max-width: 560px; }
.mmp-wizard .mmp-field > span { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 600; color: #3c434a; }
.mmp-wizard .mmp-input { width: 100%; box-sizing: border-box; padding: 9px 11px; border: 1px solid #c3c4c7; border-radius: 5px; font-size: 14px; }
.mmp-wizard .mmp-input:focus { border-color: #6B2C91; outline: none; box-shadow: 0 0 0 2px rgba(107,44,145,.15); }
.mmp-wz-hint { display: block; margin-top: 5px; font-size: 12px; color: #8c8f94; font-style: normal; }

/* Step 1 destinatari */
.mmp-wz-radio { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid #e0e0e0; border-radius: 8px; margin-bottom: 10px; max-width: 560px; cursor: pointer; }
.mmp-wz-radio input { margin-top: 3px; }
.mmp-wz-radio span { font-size: 14px; color: #1d2327; }
.mmp-wz-list-select { margin: 4px 0 0 30px; max-width: 530px; }
.mmp-wz-count { margin-top: 14px; font-size: 14px; color: #3c434a; }

/* Step 4 design */
.mmp-wz-design { display: grid; grid-template-columns: 300px 1fr; gap: 18px; }
.mmp-wz-template-list { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow: auto; }
.mmp-wz-tpl { display: flex; align-items: center; gap: 10px; padding: 8px; border: 2px solid #e0e0e0; border-radius: 8px; background: #fff; cursor: pointer; text-align: left; }
.mmp-wz-tpl:hover { border-color: #b98fd0; }
.mmp-wz-tpl.is-selected { border-color: #6B2C91; background: #f7f1fb; }
.mmp-wz-tpl img { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.mmp-wz-tpl-icon { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: #f0f0f0; border-radius: 4px; font-size: 20px; flex-shrink: 0; }
.mmp-wz-tpl-name { font-size: 13px; color: #1d2327; }
.mmp-wz-preview { position: relative; border: 1px solid #e0e0e0; border-radius: 8px; overflow: auto; min-height: 460px; max-height: 580px; background: #f6f7f7; }
.mmp-wz-preview-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #8c8f94; font-size: 14px; padding: 20px; text-align: center; }
.mmp-wz-preview-scaler { transform-origin: top left; background: #fff; }
/* width/height/transform dell'iframe e dello scaler sono impostati inline da fitPreview() */
.mmp-wz-preview-frame { display: block; border: 0; background: #fff; }

/* Step 5 revisione */
.mmp-wz-review-dl { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; max-width: 640px; margin: 0 0 22px; }
.mmp-wz-review-dl dt { font-weight: 600; color: #50575e; font-size: 13px; }
.mmp-wz-review-dl dd { margin: 0; color: #1d2327; font-size: 14px; word-break: break-word; }
.mmp-wz-test { border-top: 1px solid #eee; padding-top: 18px; max-width: 560px; }
.mmp-wz-test-row { display: flex; gap: 8px; }
.mmp-wz-test-row .mmp-input { flex: 1; }

/* Navigazione footer */
.mmp-wizard-nav { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; border-top: 1px solid #eee; background: #fafafa; }
.mmp-wizard-nav-right { display: flex; gap: 10px; margin-left: auto; }

/* Badge stato campagna mancante (gli altri esistono già) */
.mmp-badge-danger { background: #fce4e4; color: #b32d2e; }

@media (max-width: 820px) {
    .mmp-wz-design { grid-template-columns: 1fr; }
    .mmp-wz-tab { font-size: 0; gap: 0; }     /* su mobile mostra solo il numero */
    .mmp-wz-tab .mmp-wz-num { font-size: 12px; }
}
