.accordion-header .accordion-button {
    background-color: #f8f9fa !important; /* Light gray background */
    color: #333 !important; /* Darker text color */
}
.accordion-header .accordion-button:not(.collapsed) {
    background-color: #e9ecef !important; /* Slightly darker when open */
}

.action-buttons {
    white-space: nowrap;
}

.action-buttons .btn {
    padding: 0.25rem 0.5rem;
    margin: 0 0.25rem;
}

.action-buttons .btn i {
    font-size: 1.1rem;
}

/* ===== Responsive Enhancements ===== */
/* Header */
.app-header .header-actions{transition:all .25s ease;}
@media (max-width: 767.98px){
    .app-header .header-actions{width:100%;order:3;flex-basis:100%;display:none !important;justify-content:space-between;}
    .app-header .header-actions.show-mobile{display:flex !important;}
    .app-header .version-chip{display:none !important;}
}
@media (max-width: 992px){ /* tablet & down */
    .container, .container-fluid{padding-left:12px;padding-right:12px;}
    h1,h2,h3{font-size:clamp(1.15rem, 2.5vw + .6rem, 1.6rem);}
    table th, table td{white-space:nowrap;}
    #members-table th:nth-child(4), #members-table td:nth-child(4), /* Data nascita */
    #members-table th:nth-child(5), #members-table td:nth-child(5), /* Email */
    #members-table th:nth-child(6), #members-table td:nth-child(6) /* Telefono */{
        white-space:normal;min-width:120px;
    }
    #members-table td button.btn{padding:2px 6px;}
}
@media (max-width: 768px){ /* small tablet / large phone */
    .btn-group{flex-wrap:wrap;gap:6px;}
    .btn-group .btn{flex:1 1 auto;}
    /* Turn members table rows into cards if space really tight */
    #members-table thead{display:none;}
    #members-table, #members-table tbody, #members-table tr, #members-table td{display:block;width:100%;}
    #members-table tr{background:#fff;margin-bottom:10px;padding:10px;border:1px solid #e3e3e3;border-radius:8px;}
    #members-table td{border:none;padding:4px 0;}
    #members-table td::before{content:attr(data-label) ": ";font-weight:600;color:#555;}
    #members-table td.actions-cell{display:flex;gap:6px;margin-top:4px;}
}

/* ===== Elegant Notifications ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 350px;
}

.custom-toast {
    background: #fff;
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    margin-bottom: 12px;
    overflow: hidden;
    animation: slideIn 0.3s ease-out;
}

.custom-toast.toast-success {
    border-left: 4px solid #28a745;
}

.custom-toast.toast-error {
    border-left: 4px solid #dc3545;
}

.custom-toast.toast-warning {
    border-left: 4px solid #ffc107;
}

.custom-toast.toast-info {
    border-left: 4px solid #17a2b8;
}

.custom-toast .toast-header {
    background: transparent;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 12px 16px 8px;
}

.custom-toast .toast-body {
    padding: 8px 16px 12px;
    color: #333;
    line-height: 1.4;
}

.custom-toast .toast-icon {
    font-size: 18px;
    margin-right: 8px;
}

.custom-toast.toast-success .toast-icon {
    color: #28a745;
}

.custom-toast.toast-error .toast-icon {
    color: #dc3545;
}

.custom-toast.toast-warning .toast-icon {
    color: #ffc107;
}

.custom-toast.toast-info .toast-icon {
    color: #17a2b8;
}

.custom-toast .btn-close {
    font-size: 12px;
    padding: 8px;
    margin: 0;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}
@media (max-width:480px){
    body{font-size:15px;}
    #members-table tr{padding:8px;}
    #members-table td{font-size:.9rem;}
}

/* Utility classes for future mobile tweaks */
.hide-mobile{display:initial !important;}
@media (max-width:768px){ .hide-mobile{display:none !important;} }
.only-mobile{display:none !important;}
@media (max-width:768px){ .only-mobile{display:initial !important;} }

/* Tablet specific styles for better usability */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Increase base font size for better readability on tablets */
    body {
        font-size: 16px;
    }

    /* Make form elements in overlays more spacious */
    .overlay-panel .form-label {
        font-size: 1.1rem;
        margin-bottom: .5rem;
    }

    .overlay-panel .form-control,
    .overlay-panel .form-select {
        font-size: 1.1rem;
        padding: .8rem 1.1rem;
        height: auto;
    }

    .overlay-panel .btn {
        font-size: 1.1rem;
        padding: .8rem 1.3rem;
    }

    /* Add more space between form groups */
    .overlay-panel .mb-3 {
        margin-bottom: 1.5rem !important;
    }

    /* Increase the size of the overlay panel on tablets */
    .overlay-panel {
        width: min(80vw, 900px) !important;
        max-height: calc(100vh - 40px) !important;
    }

    .overlay-body {
        padding: 2rem !important;
    }
}

/* Desktop styles for overlay */
@media (min-width: 1025px) {
    .overlay-panel {
        width: min(75vw, 1000px) !important;
        max-height: calc(100vh - 60px) !important;
    }
    
    .overlay-body {
        padding: 0.75rem 1.5rem 1.5rem 1.5rem !important; /* Ridotto padding top da 1.5rem a 0.75rem */
    }
    
    /* Better form layout for desktop */
    .overlay-panel #create-member-form {
        padding: 0 !important;
        max-width: none !important;
    }
    
    .overlay-panel .wizard-panel .row {
        margin: 0 -0.75rem;
    }
    
    .overlay-panel .wizard-panel .col-md-6 {
        padding: 0 0.75rem;
    }
}

/* Real-time validation styles */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.form-control.is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.form-control.is-valid {
    border-color: #198754;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc3545;
    font-weight: 500;
}

.form-control:focus.is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.form-control:focus.is-valid {
    border-color: #198754;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
}

/* Real-time validation styles */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.form-control.is-invalid {
    border-color: #dc3545;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23dc3545' viewBox='0 0 12 12'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 4.6 1.4 1.4M7.2 4.6 5.8 6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-valid {
    border-color: #198754;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='m2.3 6.73.7-.4 1.4-2.4h.1L5.6 5l.7.4-1.4 2.4zM.7 3.3l.7-.4L2.8 5.4l-.7.4L.7 3.3z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #dc3545;
    animation: fadeIn 0.3s ease-in;
}

.invalid-feedback.show {
    display: block;
}

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

/* Field validation state indicators */
.form-control:focus.is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.form-control:focus.is-valid {
    border-color: #198754;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
}

/* ===== Member Edit Mode Styles ===== */
.save-indicator {
    margin: 10px 0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9em;
}

/* Stili per i campi editabili */
.editable-field {
    position: relative;
    transition: all 0.3s ease;
    padding: 0 !important;
}

.editable-field:hover {
    background-color: #f8f9fa !important;
}

.editable-field.editing {
    background-color: #e3f2fd !important;
    border: 2px solid #2196F3 !important;
    border-radius: 6px !important;
    padding: 6px 10px !important;
    margin: 2px 0 !important;
    min-width: 150px !important;
    display: inline-block !important;
}

.editable-field.edit-mode-active {
    background-color: #fff3cd !important;
    border: 2px solid #ffc107 !important;
    border-radius: 6px !important;
    padding: 6px 10px !important;
    margin: 2px 0 !important;
    min-width: 150px !important;
    display: inline-block !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

.editable-field.edit-mode-active:hover {
    background-color: #fff2cd !important;
    transform: scale(1.02) !important;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3) !important;
}

/* ===== Enhanced Table Styles ===== */
/* Sfondo tenue per le righe dei soci */
#members-table tbody tr {
    background-color: rgba(248, 249, 250, 0.6) !important;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

#members-table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.08) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Sfondo tenue per le righe degli eventi */
#events-table tbody tr {
    background-color: rgba(248, 249, 250, 0.6) !important;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    min-height: 80px; /* Altezza consistente con i soci */
}

#events-table tbody tr:hover {
    background-color: rgba(25, 135, 84, 0.08) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Migliora l'altezza delle righe degli eventi per consistenza */
#events-table tbody tr td {
    vertical-align: middle;
    padding: 12px 8px; /* Padding consistente con la tabella membri */
}

#members-table tbody tr td {
    vertical-align: middle;
    padding: 12px 8px;
}

/* Stili specifici per stati eventi mantenendo lo sfondo tenue */
#events-table tbody tr.table-success {
    background-color: rgba(25, 135, 84, 0.15) !important;
}

#events-table tbody tr.table-secondary {
    background-color: rgba(108, 117, 125, 0.15) !important;
}

#events-table tbody tr.bg-light {
    background-color: rgba(248, 249, 250, 0.8) !important;
}

/* Stili specifici per stati membri mantenendo lo sfondo tenue */
#members-table tbody tr.table-danger {
    background-color: rgba(220, 53, 69, 0.15) !important;
}

#members-table tbody tr.table-success {
    background-color: rgba(25, 135, 84, 0.15) !important;
}

/* Mobile responsiveness migliorata per eventi */
@media (max-width: 768px) {
    /* Assicura che le card mobile mantengano lo stesso stile */
    .events-mobile-list .event-mobile-item {
        background-color: rgba(248, 249, 250, 0.6) !important;
        border: 1px solid rgba(0, 0, 0, 0.05);
        transition: all 0.2s ease;
        margin-bottom: 12px;
        border-radius: 8px;
        padding: 8px;
    }
    
    .events-mobile-list .event-mobile-item:hover {
        background-color: rgba(25, 135, 84, 0.08) !important;
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    /* Aggiungi poster nella versione mobile degli eventi */
    .event-mobile-poster {
        width: 50px;
        height: 75px;
        object-fit: cover;
        border-radius: 6px;
        flex-shrink: 0;
    }
    
    .event-mobile-poster-placeholder {
        width: 50px;
        height: 75px;
        background-color: #f8f9fa;
        border: 1px solid #dee2e6;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    
    /* Stati specifici per le card mobile */
    .events-mobile-list .event-mobile-item.current {
        background-color: rgba(25, 135, 84, 0.15) !important;
    }
    
    .events-mobile-list .event-mobile-item.expired {
        background-color: rgba(108, 117, 125, 0.15) !important;
    }
    
    .events-mobile-list .event-mobile-item.upcoming {
        background-color: rgba(248, 249, 250, 0.8) !important;
    }
}

/* ===== Form Checkbox Fixes ===== */
/* Remove semi-transparency from disabled form checkboxes - Override Bootstrap */
.form-check-input:disabled,
.form-check-input[disabled],
input.form-check-input:disabled,
input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
    opacity: 1 !important;
}

/* Remove gray color and opacity from unchecked notification checkboxes */
.notification-checkbox:not(:checked) + .form-check-label,
.form-check-label {
    opacity: 1 !important;
    color: inherit !important;
}

/* Also target disabled labels specifically */
.form-check-input:disabled + .form-check-label,
.form-check-input[disabled] + .form-check-label {
    opacity: 1 !important;
    color: inherit !important;
}

/* Hide gender and notification sections when not in active edit mode */
.row:has(.editable-field[data-field="gender"]):not(:has(.edit-mode-active)) {
    display: none !important;
}

/* Alternative approach if :has() is not supported - use a class-based approach */
body:not(.member-edit-active) .member-gender-notifications-row {
    display: none !important;
}
