/**
 * ENGIM - Panneau Favoris
 * Styles du panneau latéral des favoris
 * 
 * @version 1.1 - Ajout encoche flottante
 */

/* ============================================================================
   VARIABLES
   ============================================================================ */
.favorites-panel {
    --panel-width: 420px;
    --panel-bg: #ffffff;
    --panel-overlay: rgba(0, 0, 0, 0.5);
    --panel-blue-800: #0f2744;
    --panel-blue-600: #1a4d7c;
    --panel-accent: #ffc700;
    --panel-text: #333;
    --panel-text-light: #666;
    --panel-border: #e2e8f0;
    --panel-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

/* ============================================================================
   STRUCTURE PRINCIPALE
   ============================================================================ */

.favorites-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--panel-width);
    max-width: 100%;
    background: var(--panel-bg);
    box-shadow: var(--panel-shadow);
    z-index: 10000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.favorites-panel--open {
    transform: translateX(0);
}

/* Overlay */
.favorites-panel__overlay {
    position: fixed;
    inset: 0;
    background: var(--panel-overlay);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.favorites-panel__overlay--visible {
    opacity: 1;
    visibility: visible;
}

/* ============================================================================
   HEADER
   ============================================================================ */

.favorites-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: var(--panel-blue-800);
    color: #ffffff;
}

.favorites-panel__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.favorites-panel__title svg {
    color: var(--panel-accent);
}

.favorites-panel__close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.favorites-panel__close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* ============================================================================
   INFO MESSAGE
   ============================================================================ */

.favorites-panel__info {
    padding: 16px 24px;
    background: #f0f7ff;
    border-bottom: 1px solid var(--panel-border);
    font-size: 13px;
    line-height: 1.5;
    color: var(--panel-text-light);
}

.favorites-panel__info svg {
    display: inline;
    vertical-align: middle;
    margin-right: 6px;
    color: var(--panel-blue-600);
}

/* ============================================================================
   LISTE DES FAVORIS
   ============================================================================ */

.favorites-panel__list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.favorites-panel__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px 24px;
    color: var(--panel-text-light);
}

.favorites-panel__empty svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    color: #ddd;
}

.favorites-panel__empty p {
    margin: 0 0 8px;
    font-size: 15px;
    color: var(--panel-text);
}

.favorites-panel__empty span {
    font-size: 13px;
}

/* ============================================================================
   CARTE FAVORI
   ============================================================================ */

.favorites-panel__item {
    display: flex;
    gap: 14px;
    padding: 14px;
    background: #ffffff;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    margin-bottom: 12px;
    transition: box-shadow 0.2s, border-color 0.2s;
    text-decoration: none;
    color: inherit;
}

.favorites-panel__item:hover {
    border-color: var(--panel-blue-600);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.favorites-panel__item-image {
    width: 100px;
    height: 75px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.favorites-panel__item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.favorites-panel__item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.favorites-panel__item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--panel-text);
    margin: 0 0 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.favorites-panel__item-location {
    font-size: 12px;
    color: var(--panel-text-light);
    display: flex;
    align-items: center;
    gap: 4px;
}

.favorites-panel__item-location svg {
    width: 12px;
    height: 12px;
}

.favorites-panel__item-details {
    display: flex;
    gap: 12px;
    margin-top: 6px;
}

.favorites-panel__item-detail {
    font-size: 12px;
    font-weight: 600;
    color: var(--panel-blue-600);
}

.favorites-panel__item-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    color: #ef4444;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.favorites-panel__item:hover .favorites-panel__item-remove {
    opacity: 1;
}

.favorites-panel__item-remove:hover {
    background: #ffffff;
    transform: scale(1.1);
}

/* ============================================================================
   FOOTER
   ============================================================================ */

.favorites-panel__footer {
    padding: 16px 24px;
    border-top: 1px solid var(--panel-border);
    background: var(--panel-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.favorites-panel__export {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #1a4d7c 0%, #0f2744 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.favorites-panel__export:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1a4d7c 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 77, 124, 0.3);
}

.favorites-panel__export svg {
    flex-shrink: 0;
}

.favorites-panel__clear {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--panel-text-light);
    background: transparent;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.favorites-panel__clear:hover {
    background: #fef2f2;
    border-color: #ef4444;
    color: #ef4444;
}

/* ============================================================================
   TOOLTIP HEADER FAVORITES
   ============================================================================ */

.header__favorites {
    position: relative;
}

.header__favorites-tooltip {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 16px;
    background: #0f2744;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    border-radius: 8px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.header__favorites-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-bottom-color: #0f2744;
}

.header__favorites:hover .header__favorites-tooltip {
    opacity: 1;
    visibility: visible;
}

/* ============================================================================
   LOADER EXPORT PDF
   ============================================================================ */

.favorites-panel__loader {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 30px;
    text-align: center;
    flex: 1;
}

/* Spinner animé */
.favorites-panel__loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e5e7eb;
    border-top-color: #1a4d7c;
    border-radius: 50%;
    animation: panelSpinner 0.8s linear infinite;
    margin-bottom: 24px;
}

@keyframes panelSpinner {
    to {
        transform: rotate(360deg);
    }
}

/* Texte principal du loader */
.favorites-panel__loader-text {
    font-size: 16px;
    font-weight: 600;
    color: #1a4d7c;
    margin: 0 0 8px 0;
}

/* Sous-texte du loader (progression) */
.favorites-panel__loader-subtext {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
    animation: pulseText 1.5s ease-in-out infinite;
}

@keyframes pulseText {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* ============================================================================
   ENCOCHE FAVORIS FLOTTANTE (côté droit)
   ============================================================================ */

.floating-favorites {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.floating-favorites__btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: #0f2744;
    color: #ffffff;
    border: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.15);
}

.floating-favorites__btn:hover {
    padding-right: 20px;
    background: #1a4d7c;
}

.floating-favorites__btn svg {
    width: 22px;
    height: 22px;
    fill: #ef4444;
    stroke: #ef4444;
}

.floating-favorites__count {
    background: #ef4444;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

.floating-favorites__count:empty {
    display: none;
}

/* Animation pulse quand ajout */
@keyframes favPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.floating-favorites__btn--pulse .floating-favorites__count {
    animation: favPulse 0.4s ease;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .floating-favorites__btn {
        padding: 10px 12px;
    }
    
    .floating-favorites__btn svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .favorites-panel {
        --panel-width: 100%;
    }
    
    .favorites-panel__item {
        flex-direction: column;
    }
    
    .favorites-panel__item-image {
        width: 100%;
        height: 140px;
    }
}

/* ============================================================================
   LOADER & ERROR (pour chargement async)
   ============================================================================ */

.favorites-panel__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--gray-500, #6b7280);
}

.favorites-panel__loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200, #e5e7eb);
    border-top-color: var(--gold-500, #f5b800);
    border-radius: 50%;
    animation: favSpinner 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes favSpinner {
    to { transform: rotate(360deg); }
}

.favorites-panel__loading p {
    font-size: 14px;
    margin: 0;
}

.favorites-panel__error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--gray-500, #6b7280);
}

.favorites-panel__error p {
    font-size: 14px;
    margin: 0 0 16px;
}

.favorites-panel__error-link,
.favorites-panel__view-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--gold-500, #f5b800);
    color: var(--blue-900, #0f2744);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.favorites-panel__error-link:hover,
.favorites-panel__view-link:hover {
    background: var(--gold-400, #ffc700);
    transform: translateY(-2px);
}
