/* Stili per DB Query V2 - Versione duplicata con isolamento completo */

/* Contenitore principale V2 */
.db-query-results-v2 {
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Filtri V2 */
.db-query-filters-v2 {
   background-color: #f8f9fa;
  padding: 20px;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  margin-bottom: 20px;
}

.db-query-filters-v2 h4 {
   margin-top: 0;
  margin-bottom: 15px;
  color: #333;
}

.filter-group-v2 {
   display: inline-block;
  margin-right: 20px;
  margin-bottom: 0;
  vertical-align: top;
}

.filter-group-v2 label {
    font-weight: 600;
    color: #555;
    font-size: 14px;
}

.filter-group-v2 select,
.filter-group-v2 input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    transition: border-color 0.3s ease;
}

.filter-group-v2 select:focus,
.filter-group-v2 input:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.reset-btn-v2 {
  padding: 8px 16px;
  background-color: #dc3545;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  margin-top: 20px;
}

.reset-btn-v2:hover {
    background: #c82333;
}

/* Bottoni sidebar V2 */
.sidebar-buttons-v2{ 
    float: right; 
    margin-left: auto;
}

/* Legenda urgenza V2 */
.urgency-legend-v2 {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
    min-width: 280px;
}

.urgency-legend-v2 h5 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}

.legend-items-v2 {
    display: inline-block;
   
}

.legend-item-v2 {
	display: inline-block;
	margin-left: 10px;
}

.legend-color-v2 {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}

.legend-text-v2 {
    font-size: 13px;
    color: #495057;
    font-weight: 500;
}

.sidebar-btn-v2 {
	padding: 8px 16px;
	background-color: #007cba;
	color: white;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 14px;
	margin-left: 10px;
	transition: background-color 0.3s;
}

.sidebar-btn-v2:hover {
    background: #005a87;
    transform: translateY(-1px);
}

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

.sidebar-v2.open {
    right: 0;
}

.sidebar-header-v2 {
    background: #007cba;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1001;
}

.sidebar-header-v2 h3 {
    margin: 0;
    font-size: 18px;
}

.sidebar-close-v2 {
    background: none;
    border: none;
    color: white;
    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.3s ease;
}

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

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

.sidebar-content-v2 h4 {
    color: #333;
    margin: 0 0 15px 0;
    font-size: 16px;
    border-bottom: 2px solid #007cba;
    padding-bottom: 5px;
}

.sidebar-content-v2 hr {
    border: none;
    height: 1px;
    background: #eee;
    margin: 20px 0;
}

/* Overlay V2 */
.sidebar-overlay-v2 {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay-v2.active {
    opacity: 1;
    visibility: visible;
}

/* Tabella V2 */
.db-query-table-v2 {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.db-query-table-container-v2 {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.db-query-table-v2 th,
.db-query-table-v2 td {
   width: 140px;
  min-width: 140px;
  white-space: normal;
  overflow: visible;
  word-wrap: break-word;
  word-break: break-word; padding:8px; background: none;
}
.db-query-table-v2 th:nth-child(3), .db-query-table-v2 td:nth-child(3), .db-query-table-v2 th:nth-child(4), .db-query-table-v2 td:nth-child(4), .db-query-table-v2 th:nth-child(5), .db-query-table-v2 td:nth-child(5) {
	width: 200px;
	min-width: 200px;
	white-space: normal;
	word-wrap: break-word;
	word-break: break-word;
}
.db-query-table-v2 th.sortable-v2 {
	cursor: pointer;
	user-select: none;
	padding-right: 25px; text-align: left;;
}
.db-query-table-v2 th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    position: sticky;
    top: 0;
    z-index: 10;
}

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

.db-query-table-v2 tbody tr:nth-child(even) {
    background: #fafafa;
}

.db-query-table-v2 tbody tr:nth-child(even):hover {
    background: #f0f0f0;
}
.status-select-v2,.owner-select-v2 {
	width: 100%;
	padding: 5px 8px;
	border: 1px solid #ddd;
	border-radius: 4px;
	background-color: #fff;
	font-size: 13px;
	transition: all 0.3s ease;
}
.db-query-table th:first-child {
	background-color: #f2f2f2;
	z-index: 3;
	position: sticky;
	top: 0;
	left: 0;
	box-shadow: 2px 0 5px -2px rgba(0,0,0,0.1), 0 2px 5px -2px rgba(0,0,0,0.1);
	width: auto;
	min-width: 0;
	box-shadow: 2px 0 5px -2px rgba(0,0,0,0.1);
}
/* Celle speciali V2 */
.sort-indicator-v2 {
	position: absolute;
	right: 8px;
	top: 50%;
	transform: translateY(-50%);
	font-size: 12px;
	color: #666;
	transition: color 0.2s;
}
.status-cell-v2 {
    text-align: center;
}

.status-badge-v2 {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.owner-cell-v2 {
    font-weight: 500;
}

.ticket-cell-v2 {
    text-align: center;
}

.ticket-badge-v2 {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.has-tickets-v2 {
    background: #d4edda;
    color: #155724;
}

.no-tickets-v2 {
    background: #f8d7da;
    color: #721c24;
}

.actions-cell-v2 {
    text-align: center;
}

.action-btn-v2 {
    background: #007cba;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin: 0 2px;
    transition: background-color 0.3s ease;
}

.action-btn-v2:hover {
    background: #005a87;
}

/* Messaggi di errore e stato V2 */
.db-query-error-v2 {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
    margin: 20px 0;
}

.no-results-v2 {
    background: #d1ecf1;
    color: #0c5460;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #bee5eb;
    margin: 20px 0;
    text-align: center;
}

/* Contenitore risultati V2 */
#db-query-results-container-v2 {
    position: relative;
    overflow-y: auto;
    border-radius: 8px;
    /*overflow-x: hidden;*/
}

#db-query-results-container-v2::-webkit-scrollbar {
    width: 8px;
}

#db-query-results-container-v2::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#db-query-results-container-v2::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#db-query-results-container-v2::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Sezioni sidebar V2 */
.status-add-section-v2,
.owner-add-section-v2,
.prodotti-add-section-v2,
.clienti-add-section-v2 {
    margin-bottom: 20px;
}

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

.status-input-v2,
.owner-input-v2,
.prodotto-input-v2,
.cliente-input-v2 {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 10px;
}

.status-color-input-v2 {
    width: 50px;
    height: 38px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.add-btn-v2 {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

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

.select-container-v2 {
    position: relative;
    margin-bottom: 10px;
}

.prodotto-select-v2 {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.filter-input-v2 {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 10px;
}

.clear-filter-btn-v2 {
    background: #6c757d;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 10px;
}

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

.loading-status-v2,
.loading-owner-v2,
.loading-prodotti-v2,
.loading-clienti-v2 {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

/* Modal V2 */
.modal-v2 {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content-v2 {
    background: white;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

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

.modal-header-v2 h3 {
    margin: 0;
    font-size: 18px;
}

.close-modal-v2 {
    background: none;
    border: none;
    color: white;
    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.3s ease;
}

.close-modal-v2:hover {
    background: rgba(255,255,255,0.2);
}

.modal-body-v2 {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.loading-message-v2,
.error-message-v2 {
    text-align: center;
    padding: 20px;
    font-size: 16px;
}

.error-message-v2 {
    color: #dc3545;
}

.product-info-section-v2,
.audit-history-section-v2 {
    margin-bottom: 20px;
}

.audit-controls-v2 {
    margin-bottom: 15px;
}

.export-btn-v2 {
    background: #17a2b8;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.export-btn-v2:hover {
    background: #138496;
}

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

@media (max-width: 480px) {
    .status-input-group-v2 {
        flex-direction: column;
    }
    
    .status-color-input-v2 {
        width: 100%;
    }
    
    .modal-content-v2 {
        max-width: 95%;
        max-height: 95%;
    }
}

/* Stili per il caricamento */
.loading-v2 {
    opacity: 0.6;
    pointer-events: none;
}

.loading-v2::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Stili per le frecce di scorrimento V2 */
.scroll-arrows-container-v2 {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
    padding: 5px;
    background-color: rgba(242, 242, 242, 0.9);
    border-radius: 4px;
    gap: 5px;
}

.scroll-arrows-v2 {
    position: absolute;
    top: 8px;
    right: 5px;
    z-index: 10;
    display: flex;
    background-color: rgba(242, 242, 242, 0.9);
    border-radius: 4px;
    padding: 2px;
    gap: 3px;
    opacity: 1;
    visibility: visible;
}

.scroll-arrow-v2 {
    background: rgba(0, 124, 186, 0.8);
    color: white;
    border: none;
    border-radius: 3px;
    width: 24px;
    height: 22px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    margin: 0 1px;
}

.scroll-arrow-v2:hover {
    background: rgba(0, 124, 186, 1);
    transform: scale(1.1);
}

.scroll-arrow-v2:disabled {
    background: rgba(128, 128, 128, 0.5);
    cursor: not-allowed;
    transform: none;
}

/* Stili per i ticket V2 */
.ticket-saved-v2 {
    background-color: #d4edda !important;
    border-left: 4px solid #28a745 !important;
    transition: all 0.3s ease;
}

.ticket-saved-v2 td {
    background-color: #d4edda !important;
}

.ticket-controls-v2 {
    align-items: center;
    gap: 8px;
}

.ticket-checkbox-v2 {
    margin: 0;
    cursor: pointer;
}

.ticket-toggle-v2 {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 3px;
    transition: all 0.3s ease;
    color: #425c74 !important;
    border: none;
    padding: 0;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ticket-toggle-v2:hover {
    background-color: #f0f0f0;
    color: #007bff;
    transform: scale(1.1);
}

.ticket-icon-v2 {
    transition: all 0.3s ease;
    display: inline-block;
}

.ticket-count-v2 {
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: bold;
    min-width: 16px;
    text-align: center;
}

.ticket-column-v2 {
    width: 80px;
    min-width: 80px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 8px 12px;
    text-align: center;
    font-weight: bold;
    color: #495057;
}

.ticket-cell-v2 {
    padding: 8px 12px;
    text-align: left;
	vertical-align: top;
    background-color: #f8f9fa;
}


/* Stili per il toggle del testo V2 */
.toggle-text-v2 {
    background-color: #007cba;
    color: white;
    border: none;
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.toggle-text-v2:hover {
    background-color: #005a87;
}

.toggle-text-v2:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.3);
}
.file-link-v2 {
	display: inline-block;
	margin: 2px 0;
	padding: 3px 8px;
	background-color: #f0f0f0;
	border-radius: 4px;
	color: #0073aa;
	text-decoration: none;
	font-size: 0.9em;
	transition: all 0.2s ease;
	border: 1px solid #ddd;
}

/* Stili per le classi di scadenza ticket V2 */
.ticket-safe-v2 {
    background-color: #d4edda !important; /* Verde chiaro */
    border-left: 4px solid #28a745 !important;
}

.ticket-warning-v2 {
    background-color: #fff3cd !important; /* Giallo chiaro */
    border-left: 4px solid #ffc107 !important;
}

.ticket-urgent-v2 {
    background-color: #f8d7da !important; /* Rosso chiaro */
    border-left: 4px solid #dc3545 !important;
}

/* Hover effects per le righe con scadenza */
.ticket-safe-v2:hover {
    background-color: #c3e6cb !important;
}

.ticket-warning-v2:hover {
    background-color: #ffeaa7 !important;
}

.ticket-urgent-v2:hover {
    background-color: #f5c6cb !important;
}

/* Effetto di sincronizzazione tra viste */
.status-updated {
    background-color: #d4edda !important;
    border: 2px solid #28a745 !important;
    transition: all 0.3s ease;
}

.status-updated .ticket-status-select-v2 {
    background-color: #c3e6cb !important;
    border-color: #28a745 !important;
}

/* Indicatore di campo richiesto V2 */
.field-required {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

/* Animazione per i cambiamenti di status */
@keyframes statusSync {
    0% { 
        background-color: #fff3cd; 
        border-color: #ffc107; 
    }
    50% { 
        background-color: #d4edda; 
        border-color: #28a745; 
    }
    100% { 
        background-color: transparent; 
        border-color: #ddd; 
    }
}

.ticket-status-select-v2.status-syncing {
    animation: statusSync 1.5s ease-in-out;
}
.date-close-expected-input-v2,.ticket-date-closed-v2 { font-size: 12px !important;border: 1px solid #ced4da} 
textarea.notes-ticket-input-v2 {
	width: 100%;
	padding: 6px 8px;
	border: 1px solid #ced4da;
	border-radius: 4px;
	font-size: 13px;
	font-family: inherit;
	resize: vertical;
	min-height: 40px;
}
