/* Styles du bouton admin feedback - UNIQUEMENT quand il est en fallback (pas dans le groupe) */
#feedbackAdminBtn:not(.header-action-btn) {
    background: #ed747000;
    color: rgb(2, 2, 2);
    border: none;
    padding: 15px;
    border-radius: 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    font-size: 14px;
    transition: all 0.3s ease;
    margin-right: 15px;
    position: fixed;
    top: 20px;
    right: 120px;
    box-shadow: 0 2px 5px rgba(76, 175, 80, 0.2);
    animation: slideInFromRight 0.3s ease-out;
}

#feedbackAdminBtn:not(.header-action-btn):hover {
    transform: scale(1.05);
    background: #ed747000;;
}

#feedbackAdminBtn:not(.header-action-btn).active {
    background: #3B4757;
    color: white;
}

#feedbackAdminBtn i {
    transition: transform 0.3s ease;
}

/* Badge pour feedbacks en attente */
#feedbackAdminBtn::after {
    content: attr(data-pending);
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ED7470;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

#feedbackAdminBtn[data-pending]:not([data-pending="0"])::after {
    opacity: 1;
}

#feedbackAdminBtn.has-alerts {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 2px 5px rgba(237, 116, 112, 0.2); }
    50% { box-shadow: 0 4px 15px rgba(237, 116, 112, 0.6); }
    100% { box-shadow: 0 2px 5px rgba(237, 116, 112, 0.2); }
}

@keyframes slideInFromRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Styles de la modal admin avec corrections de scroll */
#feedback-admin-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
}

#feedback-admin-panel.show {
    display: block;
}

.admin-panel-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto; /* CORRECTION : Ajout du scroll pour la backdrop */
}

.admin-panel-container {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 1200px;
    height: 90vh;
    max-height: 90vh; /* CORRECTION : Hauteur maximum fixe */
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    margin: auto; /* CORRECTION : Centrage automatique */
}

.admin-panel-header {
    padding: 20px;
    background: var(--primary-color);
    color: white;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-panel-header h3 {
    margin: 0;
    font-size: 20px;
}

.admin-close-btn {
    background: var(--primary-color);
    border: none;
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    width: 30px;
    height: 30px;
    position: relative;
    line-height: 30px;     /* Même hauteur que le conteneur */
    text-align: center;    /* Centre horizontalement */
}

.admin-close-btn:hover {
    background: var(--primary-color);
}

.admin-panel-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
}

/* Statistiques */
.admin-stats-section {
    margin-bottom: 20px;
    flex-shrink: 0; /* CORRECTION : Empêche la section stats de se rétrécir */
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.stat-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border-left: 4px solid #ddd;
}

.stat-card.pending {
    border-left-color: #ffc107;
}

.stat-card.approved {
    border-left-color: #28a745;
}

.stat-card.rejected {
    border-left-color: #ED7470;
}

.stat-card.rate {
    border-left-color: #3498db;
}

.feed-stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

.feed-stat-label {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

/* Filtres */
.admin-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
    flex-shrink: 0; /* CORRECTION : Empêche les filtres de se rétrécir */
}

.admin-filters select {
    min-width: 150px;
    padding: 8px 12px; /* CORRECTION : Ajout du padding */
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
}

.admin-filters button {
    padding: 8px 16px; /* CORRECTION : Style des boutons */
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.admin-filters button:hover {
    background: var(--secondary-color);
}

/* Container principal avec scroll corrigé */
.feedbacks-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    flex: 1;
    min-height: 0; /* CORRECTION : Important pour permettre le scroll */
    overflow: hidden; /* CORRECTION : Contrôle du débordement */
}

/* Liste des feedbacks avec scroll corrigé */
.feedbacks-list {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow-y: auto; /* CORRECTION : Scroll vertical activé */
    background: white;
    max-height: 100%; /* CORRECTION : Hauteur maximum */
}

.feedback-item {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.feedback-item:hover {
    background: #f8f9fa;
}

.feedback-item.selected {
    background: #e3f2fd;
    border-left: 4px solid #3498db;
}

.feedback-item:last-child {
    border-bottom: none;
}

.feedback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.feedback-rating {
    display: flex;
    gap: 2px;
}

.feedback-star {
    color: #ffd700;
    font-size: 14px;
}

.feedback-star.empty {
    color: #ddd;
}

.feedback-status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

.feedback-status.pending {
    background: #fff3cd;
    color: #856404;
}

.feedback-status.approved {
    background: #d4edda;
    color: #155724;
}

.feedback-status.rejected {
    background: #f8d7da;
    color: #721c24;
}

.feedback-preview {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.feedback-query {
    font-weight: 500;
    margin-bottom: 4px;
    word-break: break-word; /* CORRECTION : Gestion des mots longs */
}

.feedback-response {
    color: #888;
    word-break: break-word; /* CORRECTION : Gestion des mots longs */
}

.feedback-timestamp {
    font-size: 11px;
    color: #999;
    margin-top: 8px;
}

/* Détails du feedback avec scroll corrigé */
.feedback-details {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* CORRECTION : Contrôle du débordement */
    max-height: 100%; /* CORRECTION : Hauteur maximum */
}

.no-selection {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    padding: 40px 20px; /* CORRECTION : Ajout du padding */
}

.no-selection i {
    font-size: 48px;
    margin-bottom: 15px;
}

.feedback-detail-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto; /* CORRECTION : Scroll pour le contenu des détails */
    min-height: 0; /* CORRECTION : Permet le rétrécissement */
}

.detail-section {
    margin-bottom: 20px;
}

.detail-section h4 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #333;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 5px;
    position: sticky; /* CORRECTION : Garde les titres visibles */
    top: 0;
    background: white;
    z-index: 1;
}

.detail-content {
    font-size: 14px;
    line-height: 1.5;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #3498db;
    word-break: break-word; /* CORRECTION : Gestion des mots longs */
    white-space: pre-wrap; /* CORRECTION : Préserve les retours à la ligne */
    max-height: 200px; /* CORRECTION : Hauteur max pour le contenu */
    overflow-y: auto; /* CORRECTION : Scroll si contenu trop long */
}

.improvement-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.improvement-tag {
    background: #e3f2fd;
    color: #3498db;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
}

/* Actions de validation */
.validation-actions {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    flex-shrink: 0; /* CORRECTION : Empêche les actions de se rétrécir */
}

.validation-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.validation-notes {
    width: 100%;
    height: 80px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit; /* CORRECTION : Police cohérente */
}

.btn-validate {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-approve {
    background: #28a745;
    color: white;
}

.btn-approve:hover {
    background: #218838;
    transform: translateY(-1px);
}

.btn-reject {
    background: #ED7470;
    color: white;
}

.btn-reject:hover {
    background: #ED7470;
    transform: translateY(-1px);
}

.btn-review {
    background: #ffc107;
    color: #212529;
}

.btn-review:hover {
    background: #e0a800;
    transform: translateY(-1px);
}

/* Loading state */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #666;
}

.loading i {
    margin-right: 10px;
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    #feedbackAdminBtn {
        padding: 12px;
        margin-right: 10px;
    }
    
    .feedbacks-container {
        grid-template-columns: 1fr;
    }
    
    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .admin-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .admin-panel-container {
        height: 95vh; /* CORRECTION : Plus de hauteur sur mobile */
        max-height: 95vh;
    }
}

/* Bouton de suppression dans les filtres */
#clearAllBtn {
    background: #ED7470;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 10px;
}

#clearAllBtn:hover {
    background: #ED7470;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

#clearAllBtn:active {
    transform: translateY(0);
}

#clearAllBtn i {
    margin-right: 5px;
}

/* Style pour les confirmations */
.confirmation-dialog {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 15px;
    margin: 10px 0;
    color: #856404;
}

.confirmation-dialog.danger {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* Améliorations pour la liste des feedbacks quand elle est vide */
.feedbacks-list .loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px 20px;
    color: #666;
    font-size: 16px;
}

.feedbacks-list .loading i {
    font-size: 48px;
    margin-bottom: 15px;
    color: #ddd;
}

.feedbacks-list .loading.empty-state {
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px;
}

/* Style pour l'état vide (sans spinner) */
.feedbacks-list .empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px 20px;
    color: #666;
    font-size: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px;
    text-align: center;
}

/* Animation pour le bouton de suppression */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

#clearAllBtn.danger-confirm {
    animation: shake 0.5s ease-in-out;
    background: #ED7470;
}

/* Styles pour les toasts de notification */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999;
}

.toast {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    margin-bottom: 10px;
    border-left: 4px solid #007bff;
    max-width: 350px;
    animation: slideInToast 0.3s ease-out;
    z-index: 999999;
}

.toast.success {
    border-left-color: #28a745;
}

.toast.error {
    border-left-color: #dc3545;
}

.toast.warning {
    border-left-color: #ffc107;
}

.toast.info {
    border-left-color: #3498db;
}

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

/* Amélioration des filtres pour une meilleure persistance visuelle */
.admin-filters select.has-filter {
    border-color: #3498db;
    background-color: #e3f2fd;
}

.admin-filters select option:checked {
    background-color: #3498db;
    color: white;
}

/* Indicateur de chargement amélioré */
.feedbacks-list .loading i.fa-spinner {
    animation: spin 1s linear infinite;
}

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

/* Styles pour l'état vide après suppression */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-state i {
    font-size: 64px;
    color: #ddd;
    margin-bottom: 20px;
}

.empty-state h4 {
    color: #999;
    margin-bottom: 10px;
}

.empty-state p {
    color: #666;
    font-size: 14px;
}

/* Responsive pour les petits écrans */
@media (max-width: 768px) {
    .admin-filters {
        flex-direction: column;
        gap: 10px;
    }
    
    .admin-filters select,
    .admin-filters button {
        width: 100%;
    }
    
    #clearAllBtn {
        margin-left: 0;
        margin-top: 10px;
    }
}

/* Animation pour le badge du bouton admin */
@keyframes badgePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

#feedbackAdminBtn[data-pending]:not([data-pending="0"])::after {
    animation: badgePulse 2s infinite;
}

/* Style pour les tooltips personnalisés */
.custom-tooltip {
    position: relative;
}

.custom-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    margin-bottom: 5px;
}

.custom-tooltip:hover::after {
    opacity: 1;
}

/* Correction du scroll dans la modal admin feedback */
#feedback-admin-panel .admin-panel-body {
    height: calc(100vh - 120px) !important;
    overflow-y: auto !important;
    padding: 20px !important;
}

#feedback-admin-panel .feedbacks-container {
    height: calc(100vh - 300px) !important;
    overflow: hidden !important;
}

#feedback-admin-panel .feedbacks-list {
    height: 100% !important;
    overflow-y: auto !important;
    padding-right: 5px !important;
}

/* ESSENTIEL: Scroll pour les détails où sont les boutons */
#feedback-admin-panel .feedback-details {
    height: 100% !important;
    overflow-y: auto !important;
    padding: 0 15px !important;
}

/* Styles des boutons de validation - TOUJOURS VISIBLES */
#feedback-admin-panel .validation-actions {
    display: block !important;
    position: relative !important;
    margin-top: 20px !important;
    padding: 20px !important;
    background: #f8f9fa !important;
    border-top: 2px solid #3498db !important;
    border-radius: 8px !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1) !important;
}

#feedback-admin-panel .validation-buttons {
    display: flex !important;
    gap: 10px !important;
    margin-bottom: 15px !important;
}

#feedback-admin-panel .btn-validate {
    flex: 1 !important;
    padding: 12px 20px !important;
    border: none !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-weight: bold !important;
    font-size: 14px !important;
    transition: all 0.2s ease !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

#feedback-admin-panel .btn-approve {
    background: #28a745 !important;
    color: white !important;
}

#feedback-admin-panel .btn-approve:hover {
    background: #218838 !important;
    transform: translateY(-1px) !important;
}

#feedback-admin-panel .btn-reject {
    background: #ED7470 !important;
    color: white !important;
}

#feedback-admin-panel .btn-reject:hover {
    background: #ED7470 !important;
    transform: translateY(-1px) !important;
}

#feedback-admin-panel .btn-review {
    background: #ffc107 !important;
    color: #212529 !important;
}

#feedback-admin-panel .btn-review:hover {
    background: #e0a800 !important;
    transform: translateY(-1px) !important;
}

#feedback-admin-panel .validation-notes {
    width: 100% !important;
    height: 80px !important;
    padding: 10px !important;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    font-family: inherit !important;
    resize: vertical !important;
}

/* Scrollbar personnalisée */
#feedback-admin-panel .feedback-details::-webkit-scrollbar,
#feedback-admin-panel .feedbacks-list::-webkit-scrollbar {
    width: 8px;
}

#feedback-admin-panel .feedback-details::-webkit-scrollbar-track,
#feedback-admin-panel .feedbacks-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#feedback-admin-panel .feedback-details::-webkit-scrollbar-thumb,
#feedback-admin-panel .feedbacks-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#feedback-admin-panel .feedback-details::-webkit-scrollbar-thumb:hover,
#feedback-admin-panel .feedbacks-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Bouton tout supprimer */
#clearAllBtn {
    background: #ED7470 !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    margin-left: 10px !important;
}

#clearAllBtn:hover {
    background: #ED7470 !important;
    transform: translateY(-1px) !important;
}

#clearAllBtn i {
    margin-right: 5px !important;
}