/**
 * MLM Lead Manager - Frontend Styles
 * Tutti i selettori utilizzano il prefisso .mlm- per evitare conflitti
 */

/* Container principale */
.mlm-db-query-results {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    max-width: 100%;
    margin: 20px 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Sezione filtri */
.mlm-db-query-filters {
    background: #f8f9fa;
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.mlm-db-query-filters h4 {
    margin: 0;
    color: #495057;
    font-size: 16px;
    font-weight: 600;
    min-width: 60px;
}

.mlm-filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 150px;
}

.mlm-filter-group label {
    font-size: 12px;
    font-weight: 500;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mlm-db-filter {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.mlm-db-filter:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.25);
}

.mlm-reset-btn {
    background: #6c757d;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.15s ease-in-out;
}

.mlm-reset-btn:hover {
    background: #5a6268;
}

/* Bottoni sidebar */
.mlm-sidebar-buttons {
    margin-left: auto;
    display: flex;
    gap: 10px;
}

.mlm-sidebar-btn {
    background: #007cba;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.15s ease-in-out;
}

.mlm-sidebar-btn:hover {
    background: #005a87;
}

/* Tabella risultati */
.mlm-db-query-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    background: #fff;
}

.mlm-db-query-table th {
    background: #f8f9fa;
    padding: 12px 8px;
    text-align: left;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
    font-size: 13px;
    position: relative;
    cursor: pointer;
    user-select: none;
}

.mlm-db-query-table th.mlm-sortable:hover {
    background: #e9ecef;
}

.mlm-column-title {
    display: inline-block;
    margin-right: 5px;
}

.mlm-sort-indicator {
    font-size: 12px;
    color: #6c757d;
    opacity: 0.7;
}

.mlm-db-query-table th[data-sort="asc"] .mlm-sort-indicator::before {
    content: "↑";
}

.mlm-db-query-table th[data-sort="desc"] .mlm-sort-indicator::before {
    content: "↓";
}

.mlm-db-query-table td {
    padding: 12px 8px;
    border-bottom: 1px solid #dee2e6;
    font-size: 14px;
    vertical-align: top;
    max-width: 200px;
    word-wrap: break-word;
}

.mlm-db-query-table tr:hover {
    background: #f8f9fa;
}

/* Celle speciali */
.mlm-status-cell, .mlm-owner-cell {
    min-width: 150px;
}

.mlm-status-select, .mlm-owner-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: #fff;
    font-size: 13px;
}

.mlm-file-cell {
    max-width: 150px;
}

.mlm-file-link {
    color: #007cba;
    text-decoration: none;
    font-size: 12px;
    display: inline-block;
    margin: 2px 0;
}

.mlm-file-link:hover {
    text-decoration: underline;
}

.mlm-no-file {
    color: #6c757d;
    font-style: italic;
    font-size: 12px;
}

.mlm-cell-preview {
    display: inline;
}

.mlm-cell-full {
    display: none;
}

.mlm-toggle-cell {
    background: none;
    border: none;
    color: #007cba;
    cursor: pointer;
    font-size: 12px;
    text-decoration: underline;
    padding: 0;
    margin-left: 5px;
}

.mlm-toggle-cell:hover {
    color: #005a87;
}

/* Sidebar */
.mlm-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: #fff;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: right 0.3s ease-in-out;
    overflow-y: auto;
}

.mlm-sidebar.mlm-active {
    right: 0;
}

.mlm-sidebar-header {
    background: #007cba;
    color: #fff;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mlm-sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.mlm-sidebar-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.15s ease-in-out;
}

.mlm-sidebar-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mlm-sidebar-content {
    padding: 20px;
}

.mlm-sidebar-content h4 {
    margin: 0 0 15px 0;
    color: #495057;
    font-size: 16px;
    font-weight: 600;
}

.mlm-sidebar-content hr {
    border: none;
    border-top: 1px solid #dee2e6;
    margin: 20px 0;
}

/* Form inputs nelle sidebar */
.mlm-status-input, .mlm-owner-input, .mlm-prodotto-input, .mlm-cliente-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 10px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.mlm-status-input:focus, .mlm-owner-input:focus, .mlm-prodotto-input:focus, .mlm-cliente-input:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.25);
}

.mlm-status-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.mlm-status-color-input {
    width: 50px;
    height: 42px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
}

.mlm-prodotto-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 10px;
    background: #fff;
}

.mlm-select-container {
    position: relative;
}

.mlm-add-btn {
    background: #28a745;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.15s ease-in-out;
    width: 100%;
}

.mlm-add-btn:hover {
    background: #218838;
}

/* Liste nelle sidebar */
.mlm-status-list-container, .mlm-owner-list-container, .mlm-prodotti-list-container, .mlm-clienti-list-container {
    max-height: 400px;
    overflow-y: auto;
}

.mlm-status-item, .mlm-owner-item, .mlm-prodotto-item, .mlm-cliente-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mlm-status-info, .mlm-owner-info, .mlm-prodotto-info, .mlm-cliente-info {
    flex: 1;
}

.mlm-status-name, .mlm-owner-name, .mlm-prodotto-name, .mlm-cliente-name {
    font-weight: 600;
    color: #495057;
    margin-bottom: 2px;
}

.mlm-status-color-preview {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    border: 1px solid #dee2e6;
}

.mlm-owner-email, .mlm-prodotto-details, .mlm-cliente-details {
    font-size: 12px;
    color: #6c757d;
}

.mlm-item-actions {
    display: flex;
    gap: 5px;
}

.mlm-edit-btn, .mlm-delete-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.15s ease-in-out;
}

.mlm-edit-btn {
    background: #ffc107;
    color: #212529;
}

.mlm-edit-btn:hover {
    background: #e0a800;
}

.mlm-delete-btn {
    background: #dc3545;
    color: #fff;
}

.mlm-delete-btn:hover {
    background: #c82333;
}

/* Filtro prodotti */
.mlm-prodotti-filter-section {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.mlm-filter-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.mlm-clear-filter-btn {
    background: #6c757d;
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.mlm-clear-filter-btn:hover {
    background: #5a6268;
}

/* Overlay */
.mlm-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.mlm-sidebar-overlay.mlm-active {
    display: block;
}

/* Loading states */
.mlm-loading-status, .mlm-loading-owner, .mlm-loading-prodotti, .mlm-loading-clienti {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    font-style: italic;
}

/* Messaggi di errore */
.mlm-db-query-error {
    background: #f8d7da;
    color: #721c24;
    padding: 12px 16px;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 10px 0;
}

/* Nessun risultato */
.mlm-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-size: 16px;
}

/* Responsive */
@media (max-width: 768px) {
    .mlm-db-query-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .mlm-filter-group {
        min-width: auto;
    }
    
    .mlm-sidebar-buttons {
        margin-left: 0;
        justify-content: center;
    }
    
    .mlm-sidebar {
        width: 100%;
        right: -100%;
    }
    
    .mlm-db-query-table {
        font-size: 12px;
    }
    
    .mlm-db-query-table th,
    .mlm-db-query-table td {
        padding: 8px 4px;
    }
}

@media (max-width: 480px) {
    .mlm-db-query-filters {
        padding: 15px;
    }
    
    .mlm-sidebar-content {
        padding: 15px;
    }
    
    .mlm-status-input-group {
        flex-direction: column;
    }
    
    .mlm-status-color-input {
        width: 100%;
    }
}

/* Animazioni */
@keyframes mlm-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mlm-fade-in {
    animation: mlm-fadeIn 0.3s ease-in-out;
}

/* Utility classes */
.mlm-hidden {
    display: none !important;
}

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

.mlm-text-muted {
    color: #6c757d;
}

.mlm-font-weight-bold {
    font-weight: 600;
}

.mlm-mb-0 {
    margin-bottom: 0;
}

.mlm-mt-2 {
    margin-top: 10px;
}

.mlm-p-2 {
    padding: 10px;
}