/*!
 * Bootstrap 5 Inline Editable Styles
 * Custom styles for inline editing functionality
 */

/* Editable elements styling */
.bs5-editable {
    border-bottom: 1px dashed #007bff;
    cursor: pointer;
    text-decoration: none !important;
    color: inherit;
    transition: all 0.2s ease-in-out;
    padding: 2px 4px;
    border-radius: 3px;
}

.bs5-editable:hover {
    background-color: #e3f2fd;
    border-bottom-color: #0056b3;
    text-decoration: none !important;
    color: inherit;
}

.bs5-editable:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Empty value styling */
.bs5-editable-empty {
    color: #6c757d;
    font-style: italic;
    border-bottom-style: dotted;
}

.bs5-editable-empty:hover {
    background-color: #f8f9fa;
    color: #495057;
}

/* Modal customizations */
.bs5-editable .modal-dialog {
    margin-top: 10vh;
}

.bs5-editable .modal-body {
    padding: 1rem;
}

.bs5-editable .modal-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid #dee2e6;
}

/* Form controls in modal */
.bs5-editable-input {
    font-size: 0.9rem;
}

.bs5-editable-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Error styling */
.bs5-editable-error {
    margin-bottom: 0;
    font-size: 0.875rem;
}

/* Button states */
.bs5-editable-save:disabled {
    opacity: 0.6;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .bs5-editable .modal-dialog {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
    
    .bs5-editable .modal-title {
        font-size: 1rem;
    }
}

/* Integration with table styles */
.table .bs5-editable {
    display: inline-block;
    min-width: 60px;
    min-height: 1.2em;
}

.table .bs5-editable-empty {
    min-width: 80px;
}

/* Loading spinner animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fa-spin {
    animation: spin 1s linear infinite;
}

/* Accessibility improvements */
.bs5-editable[aria-label]::after {
    content: " (clicca per modificare)";
    font-size: 0.75rem;
    color: #6c757d;
    font-weight: normal;
    opacity: 0;
    transition: opacity 0.2s;
}

.bs5-editable:hover[aria-label]::after {
    opacity: 1;
}

/* File upload specific styles */
.bs5-editable[data-type="file"] {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.bs5-editable[data-type="file"] i {
    font-size: 1.1em;
}

.bs5-editable[data-type="file"]:hover {
    background-color: rgba(13, 110, 253, 0.1);
}

/* File info in modal */
.current-file-info .alert {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0;
    font-size: 0.875rem;
}

.current-file-info .alert i {
    margin-right: 0.5rem;
}

/* File input styling */
.bs5-editable-input[type="file"] {
    border: 2px dashed #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    background-color: #f8f9fa;
    transition: all 0.2s ease;
}

.bs5-editable-input[type="file"]:hover {
    border-color: #007bff;
    background-color: #e3f2fd;
}

.bs5-editable-input[type="file"]:focus {
    border-color: #007bff;
    background-color: #e3f2fd;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Progress indicator for file uploads */
.file-upload-progress {
    margin-top: 0.5rem;
}

.file-upload-progress .progress {
    height: 0.5rem;
}

/* File type icons styling */
.text-danger { color: #dc3545 !important; }
.text-primary { color: #0d6efd !important; }
.text-muted { color: #6c757d !important; }

/* File links styling */
.file-link {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
    margin-left: 0.25rem; /* Spazio tra icona e link */
}

.file-link:hover {
    color: #0d6efd;
    text-decoration: underline;
}

.file-link i {
    font-size: 0.9em;
    opacity: 0.7;
    margin-left: 0.25rem;
}

.file-link:hover i {
    opacity: 1;
}

/* Alert link styling in modals */
.alert-link {
    color: inherit !important;
    font-weight: bold;
}

.alert-link:hover {
    color: #0d6efd !important;
}

/* Prevent link style interference with editable elements */
.bs5-editable .file-link {
    pointer-events: none; /* Prevent link click when editing */
}

.bs5-editable:hover .file-link {
    pointer-events: auto; /* Re-enable on hover for UX */
}

/* Tab header layout with button */
.d-flex .nav-tabs {
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 0;
}

.d-flex .btn {
    white-space: nowrap;
}

/* Responsive adjustments for tabs with button */
@media (max-width: 768px) {
    .d-flex.justify-content-between {
        flex-direction: column;
        align-items: stretch !important;
    }
    
    .d-flex .nav-tabs {
        margin-bottom: 0.5rem;
        order: 1;
    }
    
    .d-flex .btn {
        order: 2;
        align-self: center;
        margin-left: 0 !important;
        margin-top: 0.5rem;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .bs5-editable {
        border-bottom-color: #0d6efd;
    }
    
    .bs5-editable:hover {
        background-color: rgba(13, 110, 253, 0.1);
    }
    
    .bs5-editable-empty {
        color: #adb5bd;
    }
    
    .bs5-editable-empty:hover {
        background-color: rgba(255, 255, 255, 0.05);
        color: #ced4da;
    }
    
    .bs5-editable-input[type="file"] {
        border-color: #495057;
        background-color: #212529;
        color: #fff;
    }
    
    .bs5-editable-input[type="file"]:hover,
    .bs5-editable-input[type="file"]:focus {
        border-color: #0d6efd;
        background-color: rgba(13, 110, 253, 0.1);
    }
}