/**
 * Mass Mailing Suite - Frontend CSS - ISOLATO
 * File: frontend/assets/css/frontend.css
 * 
 * STRATEGIA ISOLAMENTO:
 * - Tutti gli stili wrappati in .mms-shortcode-wrapper
 * - Rimosso selettore universale *
 * - Rimosso body.mms-page (non utilizzato)
 * - Prefissi specifici per evitare conflitti
 */

/* ============================================
   WRAPPER PRINCIPALE - ISOLAMENTO
   ============================================ */

.mms-shortcode-wrapper,
.mms-shortcode-wrapper *,
.mms-shortcode-wrapper *::before,
.mms-shortcode-wrapper *::after {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}

.mms-shortcode-wrapper {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

/* ============================================
   CONTENITORI
   ============================================ */

.mms-content {
    padding: 30px 0;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ============================================
   PAGE HEADER
   ============================================ */

.mms-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
}

.mms-page-header h1 {
    margin: 0;
    font-size: 28px;
    color: #1a1a1a;
    font-weight: 600;
}

.mms-page-header p {
    margin: 8px 0 0;
    color: #666;
    font-size: 14px;
}

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

.mms-button {
    display: inline-block;
    padding: 10px 20px;
    background: #0073aa;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1.5;
}

.mms-button:hover {
    background: #005a87;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
    text-decoration: none;
}

.mms-button:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.mms-button-secondary {
    background: #f0f0f0;
    color: #333;
}

.mms-button-secondary:hover {
    background: #e0e0e0;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mms-button-danger {
    background: #dc3545;
    color: #ffffff;
}

.mms-button-danger:hover {
    background: #c82333;
    color: #ffffff;
}

.mms-button-small {
    padding: 6px 12px;
    font-size: 13px;
}

.mms-button:disabled,
.mms-button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   STATS GRID
   ============================================ */

.mms-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.mms-stat-card {
    background: #ffffff;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.mms-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.mms-stat-number {
    font-size: 36px;
    font-weight: 700;
    color: #0073aa;
    line-height: 1;
    margin-bottom: 8px;
}

.mms-stat-label {
    color: #666;
    font-size: 14px;
    margin-bottom: 8px;
}

.mms-stat-change {
    font-size: 12px;
    font-weight: 500;
}

.mms-stat-change.positive {
    color: #28a745;
}

.mms-stat-change.negative {
    color: #dc3545;
}

/* ============================================
   CARDS
   ============================================ */

.mms-card {
    background: #ffffff;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mms-card-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e5e5;
}

.mms-card-header h2 {
    margin: 0;
    font-size: 20px;
    color: #1a1a1a;
    font-weight: 600;
}

.mms-card-body {
    padding: 0;
}

/* ============================================
   TABLES
   ============================================ */

.mms-table {
    width: 100%;
    border-collapse: collapse;
}

.mms-table thead {
    background: #f8f8f8;
}

.mms-table th,
.mms-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e5e5e5;
}

.mms-table th {
    font-weight: 600;
    color: #333;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mms-table td {
    color: #666;
    font-size: 14px;
}

.mms-table tbody tr {
    transition: background 0.2s;
}

.mms-table tbody tr:hover {
    background: #f8f8f8;
}

.mms-table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   STATUS BADGES
   ============================================ */

.mms-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    line-height: 1.2;
}

.mms-badge-draft {
    background: #fff3cd;
    color: #856404;
}

.mms-badge-scheduled {
    background: #cfe2ff;
    color: #084298;
}

.mms-badge-sending {
    background: #cff4fc;
    color: #055160;
}

.mms-badge-sent {
    background: #d1e7dd;
    color: #0f5132;
}

.mms-badge-failed {
    background: #f8d7da;
    color: #842029;
}

.mms-badge-success {
    background: #d1e7dd;
    color: #0f5132;
}

.mms-badge-warning {
    background: #fff3cd;
    color: #856404;
}

.mms-badge-danger {
    background: #f8d7da;
    color: #842029;
}

/* ============================================
   FORMS
   ============================================ */

.mms-form-group {
    margin-bottom: 20px;
}

.mms-form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.mms-form-input,
.mms-form-select,
.mms-form-textarea {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
    font-family: inherit;
}

.mms-form-input:focus,
.mms-form-select:focus,
.mms-form-textarea:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.mms-form-textarea {
    resize: vertical;
    min-height: 100px;
}

.mms-form-help {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #999;
}

/* ============================================
   TEMPLATE GRID
   ============================================ */

.mms-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.mms-template-card {
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
}

.mms-template-card:hover {
    border-color: #0073aa;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.mms-template-preview {
    height: 200px;
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
                linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
                linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
}

.mms-template-info {
    padding: 20px;
}

.mms-template-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 8px;
    color: #1a1a1a;
}

.mms-template-description {
    color: #666;
    font-size: 13px;
    margin-bottom: 15px;
    line-height: 1.5;
}

.mms-template-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================
   ALERTS
   ============================================ */

.mms-alert {
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.mms-alert-success {
    background: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

.mms-alert-info {
    background: #cff4fc;
    color: #055160;
    border: 1px solid #b6effb;
}

.mms-alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffecb5;
}

.mms-alert-danger {
    background: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
}

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

.mms-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 115, 170, 0.3);
    border-radius: 50%;
    border-top-color: #0073aa;
    animation: mms-spin 0.8s linear infinite;
}

@keyframes mms-spin {
    to { transform: rotate(360deg); }
}

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

.mms-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999;
    align-items: center;
    justify-content: center;
}

.mms-modal.active {
    display: flex;
}

.mms-modal-content {
    background: #ffffff;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.mms-modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mms-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.mms-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.mms-modal-close:hover {
    color: #333;
}

.mms-modal-body {
    padding: 25px;
}

.mms-modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============================================
   TABS
   ============================================ */

.mms-tabs {
    display: flex;
    gap: 10px;
    padding: 15px;
    border-bottom: 2px solid #e5e5e5;
    overflow-x: auto;
    margin-bottom: 20px;
}

.mms-tab {
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    color: #666;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.mms-tab:hover {
    background: #f8f8f8;
    color: #0073aa;
    text-decoration: none;
}

.mms-tab.active {
    background: #0073aa;
    color: #ffffff;
}

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

@media (max-width: 1024px) {
    .mms-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .mms-content {
        padding: 20px 15px;
    }
    
    .mms-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .mms-template-grid {
        grid-template-columns: 1fr;
    }
    
    .mms-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .mms-card {
        padding: 20px;
    }
    
    .mms-table {
        font-size: 13px;
    }
    
    .mms-table th,
    .mms-table td {
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    .mms-template-actions {
        flex-direction: column;
    }
    
    .mms-template-actions .mms-button {
        width: 100%;
        text-align: center;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.mms-text-center {
    text-align: center;
}

.mms-text-right {
    text-align: right;
}

.mms-mt-0 { margin-top: 0; }
.mms-mt-1 { margin-top: 10px; }
.mms-mt-2 { margin-top: 20px; }
.mms-mt-3 { margin-top: 30px; }

.mms-mb-0 { margin-bottom: 0; }
.mms-mb-1 { margin-bottom: 10px; }
.mms-mb-2 { margin-bottom: 20px; }
.mms-mb-3 { margin-bottom: 30px; }

.mms-hidden {
    display: none;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

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

/* Focus visible for keyboard navigation */
.mms-button:focus-visible,
.mms-form-input:focus-visible,
.mms-form-select:focus-visible,
.mms-form-textarea:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}


/* ============================================
   FIX MODAL FOOTER BUTTONS - FORCE
   ============================================ */

.mms-modal-footer {
    display: flex !important;
    justify-content: flex-end !important;
    gap: 10px !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    padding: 20px 25px !important;
}

.mms-modal-footer .mms-button {
    margin: 0 !important;
    white-space: nowrap !important;
    min-width: 100px !important;
}

/* Fix bottoni azioni tabella */
.mms-table td > div {
    display: flex !important;
    gap: 5px !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
}

.mms-table .mms-button-small {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    padding: 6px 12px !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
    margin: 0 !important;
}
