/* ============================================
   CACHE WIDGET - ADAPTÉ À TON HTML
   ============================================ */

/* PANNEAU (caché par défaut) */
.cache-widget {
    position: fixed;
    top: 80px;
    right: -420px; /* ✅ Caché hors écran */
    width: 400px;
    max-height: calc(100vh - 100px);
    background: var(--background-primary);
    border: 2px solid var(--border-color);
    border-radius: 20px 0 0 20px;
    box-shadow: -5px 5px 40px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    overflow: hidden;
    transition: right 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* État actif = visible */
.cache-widget.active {
    right: 0; /* ✅ Glisse depuis la droite */
}

/* Header du widget */
.cache-widget-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cache-widget-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Bouton fermer */
.cache-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.cache-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Body du widget */
.cache-widget-body {
    padding: 20px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    background: var(--background-primary);
}

.cache-widget-body::-webkit-scrollbar {
    width: 8px;
}

.cache-widget-body::-webkit-scrollbar-track {
    background: var(--background-secondary);
    border-radius: 10px;
}

.cache-widget-body::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

/* Sections */
.cache-section {
    margin-bottom: 25px;
    padding: 15px;
    background: var(--background-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.cache-section h4 {
    margin: 0 0 15px 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cache-section h4 i {
    color: #667eea;
}

/* Stats */
.cache-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.cache-stat-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.cache-stat-value {
    color: #667eea;
    font-weight: 700;
    font-size: 1.1rem;
}

.cache-stat-unit {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-left: 5px;
}

/* Progress bar */
.cache-progress-bar {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 10px;
    margin-bottom: 15px;
}

.cache-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669);
    border-radius: 6px;
    transition: width 0.5s ease, background 0.3s ease;
}

/* Boutons d'action */
.cache-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-cache {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-cache-refresh {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.btn-cache-refresh:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-cache-clear {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.btn-cache-clear:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-cache-export {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: white;
}

.btn-cache-export:hover {
    background: linear-gradient(135deg, #0891b2, #0e7490);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
}

/* Activity */
.cache-activity {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
}

.cache-activity::-webkit-scrollbar {
    width: 6px;
}

.cache-activity::-webkit-scrollbar-track {
    background: var(--background-secondary);
    border-radius: 6px;
}

.cache-activity::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 6px;
}

.cache-activity-entry {
    padding: 8px 12px;
    margin-bottom: 8px;
    background: var(--background-primary);
    border-left: 3px solid #667eea;
    border-radius: 6px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.cache-activity-time {
    color: var(--text-secondary);
    font-size: 0.75rem;
    min-width: 60px;
}

.cache-activity-icon {
    font-size: 1.2rem;
}

.cache-activity-text {
    color: var(--text-primary);
    flex: 1;
    font-size: 0.85rem;
}

.cache-empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
    font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
    .cache-widget {
        width: calc(100% - 20px);
        right: -100%;
        top: 70px;
        border-radius: 20px;
    }
    
    .cache-widget.active {
        right: 10px;
    }
}

/* Dark mode */
[data-theme="dark"] .cache-widget {
    background: #1e293b;
    border-color: #334155;
    box-shadow: -5px 5px 40px rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] .cache-section {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .cache-activity {
    background: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .cache-activity-entry {
    background: rgba(255, 255, 255, 0.05);
    border-left-color: #60a5fa;
}

[data-theme="dark"] .cache-progress-bar {
    background: rgba(255, 255, 255, 0.1);
}