/* Custom Table Editor Styles */

.cte-wrapper {
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.cte-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #ddd;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.cte-table th {
    background: #f8f9fa;
    border: 1px solid #ddd;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: #333;
}

.cte-table td {
    border: 1px solid #ddd;
    padding: 8px;
    vertical-align: top;
    min-height: 40px;
}

.cte-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.cte-table tbody tr:hover {
    background-color: #f5f5f5;
}

/* Editable cells */
.cte-editable {
    cursor: pointer;
    position: relative;
}

.cte-editable:hover {
    background-color: #e3f2fd !important;
}

.cte-editable.cte-required {
    background-color: #fff3cd;
}

.cte-editable.cte-required:hover {
    background-color: #ffeaa7 !important;
}

/* Non-editable cells when editable_rows is specified */
.cte-non-editable {
    background-color: #f8f9fa !important;
    color: #6c757d;
    cursor: not-allowed;
    position: relative;
}

.cte-non-editable:hover {
    background-color: #e9ecef !important;
}

.cte-non-editable::after {
    content: "🔒";
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 12px;
    opacity: 0.7;
    pointer-events: none;
}

.cte-non-editable:hover::before {
    content: "Cella non editabile";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0.9;
}

/* Non-editable cells in alternating rows */
.cte-table tbody tr:nth-child(even) .cte-non-editable {
    background-color: #f1f3f4 !important;
}

.cte-table tbody tr:nth-child(even) .cte-non-editable:hover {
    background-color: #e2e6ea !important;
}

/* Ensure non-editable cells are visually distinct from editable ones */
.cte-non-editable span {
    color: #6c757d;
    font-style: italic;
}

/* Editable cells with hover effect */
.cte-editable-hover {
    transition: all 0.2s ease;
}

.cte-editable-hover:hover {
    background-color: #e3f2fd !important;
    box-shadow: inset 0 0 0 2px #007cba;
}

.cte-editable-hover.cte-required:hover {
    background-color: #ffeaa7 !important;
    box-shadow: inset 0 0 0 2px #ffc107;
}

/* Cell states */
.cte-loading {
    color: #007cba;
    font-style: italic;
}

.cte-saved {
    color: #28a745;
    font-weight: 500;
}

.cte-error {
    color: #dc3545;
    font-weight: 500;
}

/* Required field error state */
.cte-required.cte-error {
    background-color: #f8d7da !important;
    border: 2px solid #dc3545 !important;
}

.cte-required.cte-error span {
    color: #dc3545;
    font-weight: bold;
}

/* Placeholder text for empty dropdown cells */
.cte-placeholder {
    color: #999;
    font-style: italic;
}

/* Input and select styles */
.cte-input, .cte-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.cte-input:focus, .cte-select:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 1px #007cba;
}

.cte-input[type="number"] {
    text-align: right;
}

/* Dropdown column width */
.cte-table th:has(+ tbody td .cte-select),
.cte-table td:has(.cte-select) {
    min-width: 200px;
    width: auto;
}

/* Specific column widths for better readability */
.cte-table th:nth-child(4), /* Tipologia column */
.cte-table td:nth-child(4) {
    min-width: 180px;
    width: auto;
}

/* Make table horizontally scrollable if needed */
.cte-wrapper {
    overflow-x: auto;
    max-width: 100%;
}

.cte-table {
    min-width: 800px; /* Ensure minimum width for readability */
}

/* Disabled cells */
.cte-disabled {
    background-color: #f8f9fa !important;
    color: #6c757d !important;
    cursor: not-allowed;
    opacity: 0.7;
    position: relative;
}

.cte-disabled::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.03);
    pointer-events: none;
}

.cte-disabled:hover {
    background-color: #f8f9fa !important;
    cursor: not-allowed;
}

.cte-disabled input,
.cte-disabled select {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Buttons */
.cte-add-row,
.cte-save,
.cte-delete-row {
    padding: 8px 16px;
    margin: 5px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.cte-add-row {
    background-color: #28a745;
    color: white;
    padding: 10px 20px;
    margin: 15px 10px 15px 0;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cte-add-row::before {
    content: "+";
    margin-right: 6px;
    font-weight: bold;
    font-size: 16px;
}

.cte-add-row:hover {
    background-color: #218838;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.cte-add-row:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cte-save-all {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    margin: 15px 10px 15px 0;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cte-save-all::before {
    content: "💾";
    margin-right: 6px;
    font-size: 14px;
}

.cte-save-all:hover {
    background-color: #0056b3;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.cte-save-all:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cte-save-all:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    opacity: 0.6;
}

.cte-save {

.cte-save {
    background-color: #007cba;
    color: white;
}

.cte-save:hover {
    background-color: #005a87;
}

.cte-delete-row {
    background-color: #dc3545;
    color: white;
    padding: 4px 8px;
    font-size: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.cte-delete-row::before {
    content: "×";
    margin-right: 3px;
    font-weight: bold;
    font-size: 14px;
}

.cte-delete-row:hover {
    background-color: #c82333;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.cte-delete-row:active {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Error states */
.cte-error {
    border-color: #dc3545 !important;
    background-color: #f8d7da !important;
}

.cte-error:focus {
    box-shadow: 0 0 0 1px #dc3545 !important;
}

/* Loading state */
.cte-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Button loading states */
.cte-add-row:disabled,
.cte-save-all:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Preloader spinner */
.cte-loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: cte-spin 1s ease-in-out infinite;
    margin-right: 6px;
}

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

/* Success state */
.cte-success {
    background-color: #28a745 !important;
    color: white !important;
}

.cte-success-icon {
    color: white;
    font-weight: bold;
    margin-right: 6px;
    font-size: 16px;
}

/* Button states */
.cte-add-row.cte-loading,
.cte-add-row-new.cte-loading {
    background-color: #6c757d;
    cursor: not-allowed;
}

.cte-add-row.cte-success,
.cte-add-row-new.cte-success {
    background-color: #28a745;
    animation: cte-success-pulse 0.5s ease-in-out;
}

.cte-save-all.cte-loading {
    background-color: #6c757d;
    cursor: not-allowed;
}

.cte-save-all.cte-success {
    background-color: #28a745;
    animation: cte-success-pulse 0.5s ease-in-out;
}

@keyframes cte-success-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .cte-table {
        font-size: 12px;
    }
    
    .cte-table th,
    .cte-table td {
        padding: 6px 4px;
    }
    
    .cte-add-row,
    .cte-save-all {
        padding: 10px 16px;
        font-size: 13px;
        min-width: 120px;
        margin: 8px 5px;
    }
    
    .cte-delete-row {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* Button container for better layout */
.cte-wrapper {
    position: relative;
}

.cte-wrapper:after {
    content: "";
    display: block;
    clear: both;
}

/* Enhanced button spacing and layout */
.cte-add-row,
.cte-save-all {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Button hover effects enhancement */
.cte-add-row:hover::before,
.cte-save-all:hover::before {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* Print styles */
@media print {
    .cte-add-row,
    .cte-save,
    .cte-delete-row {
        display: none;
    }
    
    .cte-table {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .cte-table th,
    .cte-table td {
        border: 1px solid #000;
    }
}

/* Fallback message styles */
.cte-fallback-message {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 30px;
    margin: 20px 0;
    text-align: center;
}

.cte-fallback-content {
    max-width: 600px;
    margin: 0 auto;
}

.cte-fallback-content p {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #495057;
}

.cte-fallback-content strong {
    color: #212529;
    font-weight: 600;
}

.cte-fallback-content ul {
    list-style: none;
    padding: 0;
    margin: 15px 0;
}

.cte-fallback-content li {
    background-color: #e9ecef;
    padding: 8px 15px;
    margin: 5px 0;
    border-radius: 4px;
    display: inline-block;
    margin-right: 10px;
    font-weight: 500;
    color: #495057;
}

.cte-fallback-note {
    font-size: 14px !important;
    color: #6c757d !important;
    font-style: italic;
    margin-top: 20px !important;
}



