/* FormMate Modern UI Enhancements */

/* ==================== GENERAL IMPROVEMENTS ==================== */

/* Smooth animations globally */
* {
    transition: all 0.2s ease-in-out;
}

/* Better focus states */
button:focus,
.btn:focus,
input:focus,
textarea:focus,
select:focus {
    box-shadow: 0 0 0 0.2rem rgba(110, 168, 254, 0.25) !important;
    border-color: var(--bs-primary) !important;
}

/* ==================== CARDS & CONTAINERS ==================== */

.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.card-header {
    background: linear-gradient(45deg, var(--bs-primary), var(--bs-primary-rgb, 13, 110, 253));
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    font-weight: 600;
}

    .card-header h5,
    .card-header h6 {
        color: var(--bs-body-color) !important;
        margin: 0;
    }
    .card-header h4 {
        color: var(--bs-body-color) !important;
    }
.card-title {
    color: var(--bs-body-color) !important;
}
/* ==================== BUTTONS ==================== */
.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 0.5rem 1.2rem;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: linear-gradient(45deg, #007bff, #0056b3);
}

.btn-success {
    background: linear-gradient(45deg, #28a745, #1e7e34);
}

.btn-warning {
    background: linear-gradient(45deg, #ffc107, #e0a800);
    color: #212529 !important;
}

.btn-danger {
    background: linear-gradient(45deg, #dc3545, #c82333);
}

.btn-info {
    background: linear-gradient(45deg, #17a2b8, #138496);
}

.btn-outline-primary:hover,
.btn-outline-success:hover,
.btn-outline-warning:hover,
.btn-outline-danger:hover,
.btn-outline-info:hover,
.btn-outline-secondary:hover {
    transform: translateY(-1px);
}

/* ==================== FORMS ==================== */

.form-control,
.form-select {
    border-radius: 8px;
    border: 2px solid var(--bs-border-color);
    padding: 0.7rem 1rem;
    transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.1);
}

.form-label {
    font-weight: 600;
    color: var(--bs-emphasis-color);
    margin-bottom: 0.7rem;
}

/* ==================== TABLES ==================== */

.table {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

    .table thead th {
        background: linear-gradient(45deg, var(--bs-primary), var(--bs-primary-rgb, 13, 110, 253));
        
        color: var(--bs-body-color);
        border: none;
        font-weight: 600;
        padding: 1rem;
    }

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background-color: var(--bs-primary-bg-subtle, rgba(13, 110, 253, 0.1));
    transform: scale(1.01);
}

/* ==================== ALERTS ==================== */

.alert {
    border: none;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin: 1rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.alert-success {
    background: linear-gradient(45deg, #d4edda, #c3e6cb);
    color: #155724;
}

.alert-danger {
    background: linear-gradient(45deg, #f8d7da, #f1b0b7);
    color: #721c24;
}

.alert-warning {
    background: linear-gradient(45deg, #fff3cd, #ffeaa7);
    color: #856404;
}

.alert-info {
    background: linear-gradient(45deg, #d1ecf1, #bee5eb);
    color: #0c5460;
}

/* ==================== BADGES ==================== */

.badge {
    border-radius: 20px;
    padding: 0.5rem 0.8rem;
    font-weight: 500;
    font-size: 0.8rem;
}

/* ==================== DROPDOWNS ==================== */

.dropdown-menu {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 0.5rem 0;
    z-index: 9999 !important;
}

/* Notification dropdown specific - FORCE HIGH Z-INDEX */
#notificationDropdownContent {
    max-height: 400px !important;
    overflow-y: auto !important;
    min-width: 320px !important;
    z-index: 99999 !important;
    position: fixed !important;
    transform: translateZ(0) !important;
}

#notificationDropdown + .dropdown-menu {
    z-index: 99999 !important;
    position: fixed !important;
    transform: translateZ(0) !important;
}

/* Override any card z-index that might interfere */
.card {
    position: relative;
    z-index: 1 !important;
}

/* Specific override for Bootstrap utility classes that might have high z-index */
.card.bg-primary,
.card.bg-secondary, 
.card.bg-success,
.card.bg-danger,
.card.bg-warning,
.card.bg-info,
.card.bg-light,
.card.bg-dark,
.bg-primary,
.bg-secondary,
.bg-success, 
.bg-danger,
.bg-warning,
.bg-info,
.bg-light,
.bg-dark {
    z-index: 1 !important;
    position: relative !important;
}

/* Ensure navbar dropdown container has high z-index */
.navbar .dropdown {
    z-index: 99999 !important;
}

/* NUCLEAR OPTION: Force notification dropdown above everything */
#notificationDropdownContent,
.dropdown-menu[aria-labelledby="notificationDropdown"] {
    z-index: 999999 !important;
    position: fixed !important;
    transform: translateZ(1000px) !important;
}

/* Ensure all content stays below notification dropdown */
.container,
.container-fluid,
main,
section,
article {
    z-index: auto !important;
    position: relative !important;
}

/* ==================== OFFLINE MODE STYLES ==================== */

.offline-mode {
    filter: grayscale(10%);
}

.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99999;
}

.offline-mode::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(45deg, #ffc107, #fd7e14);
    z-index: 99999;
    animation: offline-pulse 2s ease-in-out infinite;
}

@keyframes offline-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* PWA Install Button */
#installApp {
    background: linear-gradient(45deg, #28a745, #20c997);
    border: none;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
    transition: all 0.3s ease;
}

#installApp:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(40, 167, 69, 0.4);
}

/* Form auto-save indicator */
.form-auto-saved {
    position: relative;
}

.form-auto-saved::after {
    content: 'Salvato automaticamente';
    position: absolute;
    top: -25px;
    right: 0;
    font-size: 0.75rem;
    color: #28a745;
    background: rgba(40, 167, 69, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid rgba(40, 167, 69, 0.2);
    opacity: 0;
    animation: auto-save-fade 2s ease-in-out;
}

@keyframes auto-save-fade {
    0%, 100% { opacity: 0; transform: translateY(5px); }
    20%, 80% { opacity: 1; transform: translateY(0); }
}

/* Offline form styling */
.offline-capable[data-offline="true"] {
    border: 2px dashed #ffc107;
    border-radius: 8px;
    padding: 1rem;
    background: rgba(255, 193, 7, 0.05);
}

.offline-capable[data-offline="true"]::before {
    content: '⚠️ Modalità Offline - I dati verranno sincronizzati';
    display: block;
    background: #fff3cd;
    color: #856404;
    padding: 0.5rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    font-size: 0.875rem;
    text-align: center;
}

.dropdown-item {
    padding: 0.7rem 1.5rem;
    transition: all 0.2s ease;
    border-radius: 0;
}

.dropdown-item:hover {
    background: var(--bs-primary);
    color: white;
    transform: translateX(5px);
}

/* ==================== MODALS ==================== */

.modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    background: linear-gradient(45deg, var(--bs-primary), var(--bs-primary-rgb, 13, 110, 253));
    color: white;
    border: none;
    border-radius: 16px 16px 0 0;
}

.modal-header .btn-close {
    filter: invert(1);
    opacity: 0.8;
}

.modal-header h5 {
    color: white !important;
}

/* ==================== NAVBAR ENHANCEMENTS ==================== */

.navbar {
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
}

.nav-link {
    font-weight: 500;
    border-radius: 8px;
    margin: 0 0.2rem;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: var(--bs-primary);
    color: white !important;
    transform: translateY(-1px);
}

/* ==================== LIST GROUPS ==================== */

.list-group {
    border-radius: 12px;
    overflow: hidden;
}

.list-group-item {
    border: none;
    border-bottom: 1px solid var(--bs-border-color);
    padding: 1rem 1.5rem;
    transition: all 0.2s ease;
}

.list-group-item:hover {
    background: var(--bs-primary-bg-subtle, rgba(13, 110, 253, 0.1));
    transform: translateX(5px);
}

.list-group-item:last-child {
    border-bottom: none;
}

/* ==================== PROGRESS BARS ==================== */

.progress {
    border-radius: 20px;
    height: 8px;
}

.progress-bar {
    background: linear-gradient(45deg, var(--bs-primary), var(--bs-primary-rgb, 13, 110, 253));
}

/* ==================== DARK THEME SPECIFIC ==================== */

[data-bs-theme="dark"] .card {
    background-color: var(--bs-secondary-bg);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .table {
    background-color: var(--bs-secondary-bg);
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: var(--bs-secondary-bg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .modal-content {
    background-color: var(--bs-secondary-bg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* ==================== ANIMATIONS ==================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.animate-fade-in {
    animation: fadeInUp 0.6s ease-out;
}

.animate-slide-in {
    animation: slideInLeft 0.5s ease-out;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* ==================== LOADING STATES ==================== */

.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ==================== RESPONSIVE IMPROVEMENTS ==================== */

@media (max-width: 768px) {
    .card {
        border-radius: 8px;
        margin: 0.5rem 0;
    }
    
    .btn {
        width: 100%;
        margin: 0.2rem 0;
    }
    
    .table-responsive {
        border-radius: 12px;
    }
}

/* ==================== UTILITY CLASSES ==================== */

.glass-effect {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.shadow-soft {
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.shadow-strong {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.gradient-primary {
    background: linear-gradient(45deg, var(--bs-primary), var(--bs-primary-rgb, 13, 110, 253));
}

.gradient-success {
    background: linear-gradient(45deg, var(--bs-success), #1e7e34);
}

.text-gradient {
    background: linear-gradient(45deg, var(--bs-primary), var(--bs-info));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}