/**
 * RPG Life — Styles du widget + panneau + notifications
 */

/* ============================================================
 * 1. WIDGET flottant (top-right)
 * ============================================================ */

#luafi-rpg-widget {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9998;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid #f59e0b;
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.3);
    font-family: 'Inter', sans-serif;
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 200px;
}

#luafi-rpg-widget:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.4);
}

#luafi-rpg-widget:focus-visible {
    outline: 3px solid #f59e0b;
    outline-offset: 2px;
}

.rpg-widget-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.rpg-widget-content {
    flex: 1;
    min-width: 0;
}

.rpg-widget-level {
    font-size: 0.78rem;
    font-weight: 700;
    color: #78350f;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.rpg-widget-xp-bar {
    width: 100%;
    height: 6px;
    background: rgba(120, 53, 15, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.rpg-widget-xp-fill {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #d97706);
    border-radius: 3px;
    transition: width 0.4s ease-out;
}

.rpg-widget-xp-text {
    font-size: 0.7rem;
    color: #92400e;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.rpg-widget-boss {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-left: 8px;
    border-left: 1px solid rgba(120, 53, 15, 0.25);
    min-width: 36px;
}

.rpg-boss-icon { font-size: 1rem; }
.rpg-boss-pct {
    font-size: 0.7rem;
    font-weight: 700;
    color: #78350f;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
 * 2. PANEL détaillé
 * ============================================================ */

.rpg-panel {
    position: fixed;
    top: 140px;
    right: 20px;
    width: 340px;
    max-height: 70vh;
    overflow-y: auto;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
    z-index: 10002;
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    color: #1f2937;
    animation: rpg-panel-appear 0.25s ease-out;
}

@keyframes rpg-panel-appear {
    from { opacity: 0; transform: translateY(-8px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.rpg-panel[hidden] { display: none; }

.rpg-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    border-radius: 16px 16px 0 0;
    position: sticky;
    top: 0;
    z-index: 1;
}

.rpg-panel-header strong {
    font-size: 1rem;
    font-weight: 700;
}

.rpg-panel-close {
    background: rgba(255, 255, 255, 0.25);
    border: none;
    color: #ffffff;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.rpg-panel-close:hover { background: rgba(255, 255, 255, 0.4); }

.rpg-panel-body { padding: 16px 18px; }

.rpg-section {
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f6;
}

.rpg-section:last-child { border-bottom: none; }

.rpg-section h3 {
    margin: 0 0 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Niveau display */
.rpg-section-level { text-align: center; }

.rpg-level-display {
    display: flex;
    justify-content: space-around;
    align-items: baseline;
    margin-bottom: 10px;
}

.rpg-level-num {
    font-size: 1.5rem;
    font-weight: 800;
    color: #d97706;
}

.rpg-level-xp {
    font-size: 0.85rem;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
}

.rpg-progress-bar {
    width: 100%;
    height: 10px;
    background: #f3f4f6;
    border-radius: 5px;
    overflow: hidden;
}

.rpg-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #d97706);
    border-radius: 5px;
    transition: width 0.4s ease-out;
}

.rpg-progress-text {
    margin-top: 6px;
    font-size: 0.78rem;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
}

/* Boss card */
.rpg-boss-card {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    border: 1px solid #fca5a5;
    border-radius: 12px;
    padding: 14px;
}

.rpg-boss-card.defeated {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    border-color: #6ee7b7;
}

.rpg-boss-name {
    font-weight: 700;
    color: #991b1b;
    font-size: 1rem;
    margin-bottom: 4px;
}

.rpg-boss-card.defeated .rpg-boss-name { color: #065f46; }

.rpg-boss-desc {
    font-size: 0.82rem;
    color: #7f1d1d;
    margin-bottom: 10px;
}

.rpg-boss-card.defeated .rpg-boss-desc { color: #064e3b; }

.rpg-boss-progress {
    height: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.rpg-boss-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ef4444, #dc2626);
    transition: width 0.4s ease-out;
}

.rpg-boss-card.defeated .rpg-boss-progress-fill {
    background: linear-gradient(90deg, #10b981, #059669);
}

.rpg-boss-stats {
    font-size: 0.78rem;
    color: #7f1d1d;
    font-variant-numeric: tabular-nums;
}

.rpg-boss-card.defeated .rpg-boss-stats { color: #064e3b; }

.rpg-boss-reward {
    margin-top: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #d97706;
}

/* Stats grid */
.rpg-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.rpg-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
}

.rpg-stat-item span { color: #6b7280; }
.rpg-stat-item strong { color: #1f2937; font-variant-numeric: tabular-nums; }

/* Badges */
.rpg-badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
}

.rpg-badge {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
    transition: all 0.2s;
}

.rpg-badge.unlocked {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-color: #f59e0b;
}

.rpg-badge.locked {
    opacity: 0.5;
    filter: grayscale(1);
}

.rpg-badge-icon { font-size: 1.4rem; line-height: 1; margin-bottom: 4px; }
.rpg-badge-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #4b5563;
    line-height: 1.2;
}

.rpg-badge.unlocked .rpg-badge-label { color: #78350f; }

/* Leaderboard */
.rpg-leaderboard {
    max-height: 200px;
    overflow-y: auto;
}

.rpg-leaderboard-row {
    display: grid;
    grid-template-columns: 80px 1fr 60px;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.82rem;
    align-items: center;
}

.rpg-lb-date { color: #9ca3af; font-variant-numeric: tabular-nums; }
.rpg-lb-label { color: #4b5563; }
.rpg-lb-xp {
    text-align: right;
    font-weight: 700;
    color: #d97706;
    font-variant-numeric: tabular-nums;
}

.rpg-empty {
    color: #9ca3af;
    font-style: italic;
    text-align: center;
    padding: 16px;
}

/* ============================================================
 * 3. NOTIFICATIONS — Level-up modal + Badge toast + Boss toast
 * ============================================================ */

.rpg-levelup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: grid;
    place-items: center;
    z-index: 10020;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.rpg-levelup.visible { opacity: 1; }

.rpg-levelup-card {
    background: linear-gradient(135deg, #fef3c7, #fde68a, #fcd34d);
    border: 3px solid #f59e0b;
    border-radius: 24px;
    padding: 40px 32px;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 32px 80px rgba(245, 158, 11, 0.4);
    transform: scale(0.8);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: 'Inter', sans-serif;
}

.rpg-levelup.visible .rpg-levelup-card { transform: scale(1); }

.rpg-levelup-icon {
    font-size: 4rem;
    line-height: 1;
    margin-bottom: 12px;
    animation: rpg-bounce 0.6s ease-out;
}

@keyframes rpg-bounce {
    0%   { transform: scale(0) rotate(-180deg); }
    60%  { transform: scale(1.2) rotate(20deg); }
    100% { transform: scale(1) rotate(0); }
}

.rpg-levelup-card h2 {
    margin: 0 0 8px;
    font-size: 1.8rem;
    font-weight: 800;
    color: #78350f;
}

.rpg-levelup-card p {
    margin: 0 0 20px;
    color: #92400e;
    font-size: 0.95rem;
    line-height: 1.5;
}

.rpg-levelup-close {
    padding: 10px 24px;
    background: #d97706;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.rpg-levelup-close:hover { background: #b45309; }

/* Badge notification */
.rpg-badge-notif,
.rpg-boss-notif {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: #ffffff;
    border: 2px solid #f59e0b;
    border-radius: 12px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 10019;
    font-family: 'Inter', sans-serif;
    opacity: 0;
    transition: opacity 0.4s, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 360px;
}

.rpg-badge-notif.visible,
.rpg-boss-notif.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.rpg-badge-notif-icon,
.rpg-boss-notif-icon {
    font-size: 2rem;
    line-height: 1;
}

.rpg-badge-notif-content,
.rpg-boss-notif-content {
    flex: 1;
}

.rpg-badge-notif-title,
.rpg-boss-notif-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #d97706;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.rpg-boss-notif-title { color: #dc2626; }

.rpg-badge-notif-label,
.rpg-boss-notif-label {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin-top: 2px;
}

.rpg-badge-notif-desc {
    font-size: 0.78rem;
    color: #6b7280;
    margin-top: 2px;
}

.rpg-boss-notif-reward {
    font-size: 0.85rem;
    font-weight: 700;
    color: #d97706;
    margin-top: 2px;
}

/* ============================================================
 * 4. RESPONSIVE
 * ============================================================ */

@media (max-width: 640px) {
    #luafi-rpg-widget {
        top: 70px;
        right: 12px;
        min-width: 160px;
        padding: 8px 10px;
    }
    .rpg-widget-level { font-size: 0.7rem; }
    .rpg-widget-xp-text { font-size: 0.65rem; }
    .rpg-widget-boss { display: none; }

    .rpg-panel {
        top: 110px;
        right: 12px;
        left: 12px;
        width: auto;
        max-height: 60vh;
    }
}

/* ============================================================
 * 5. DARK MODE
 * ============================================================ */

@media (prefers-color-scheme: dark) {
    .rpg-panel {
        background: #1f2937;
        color: #f3f4f6;
        box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    }
    .rpg-section { border-bottom-color: #374151; }
    .rpg-section h3 { color: #9ca3af; }
    .rpg-level-num { color: #fbbf24; }
    .rpg-level-xp { color: #9ca3af; }
    .rpg-progress-bar { background: #374151; }
    .rpg-boss-name { color: #fca5a5; }
    .rpg-boss-desc { color: #fecaca; }
    .rpg-boss-stats { color: #fecaca; }
    .rpg-boss-card.defeated .rpg-boss-name { color: #86efac; }
    .rpg-boss-card.defeated .rpg-boss-desc { color: #bbf7d0; }
    .rpg-boss-card.defeated .rpg-boss-stats { color: #bbf7d0; }
    .rpg-stat-item { background: #374151; }
    .rpg-stat-item span { color: #9ca3af; }
    .rpg-stat-item strong { color: #f3f4f6; }
    .rpg-badge { background: #374151; border-color: #4b5563; }
    .rpg-badge.unlocked { background: linear-gradient(135deg, #78350f, #92400e); border-color: #f59e0b; }
    .rpg-badge.locked { opacity: 0.4; }
    .rpg-badge-label { color: #d1d5db; }
    .rpg-badge.unlocked .rpg-badge-label { color: #fef3c7; }
    .rpg-leaderboard-row { border-bottom-color: #374151; }
    .rpg-lb-date { color: #6b7280; }
    .rpg-lb-label { color: #d1d5db; }
    .rpg-lb-xp { color: #fbbf24; }
    .rpg-empty { color: #6b7280; }
    .rpg-badge-notif,
    .rpg-boss-notif {
        background: #1f2937;
        border-color: #f59e0b;
        color: #f3f4f6;
    }
    .rpg-badge-notif-label,
    .rpg-boss-notif-label { color: #f3f4f6; }
}

body.dark-mode .rpg-panel { background: #1f2937; color: #f3f4f6; }
body.dark-mode .rpg-section { border-bottom-color: #374151; }
body.dark-mode .rpg-section h3 { color: #9ca3af; }
body.dark-mode .rpg-stat-item { background: #374151; }
body.dark-mode .rpg-badge { background: #374151; border-color: #4b5563; }
body.dark-mode .rpg-leaderboard-row { border-bottom-color: #374151; }
body.dark-mode .rpg-badge-notif,
body.dark-mode .rpg-boss-notif { background: #1f2937; color: #f3f4f6; }

/* ============================================================
 * 6. ACCESSIBILITÉ — prefers-reduced-motion
 * ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .rpg-levelup,
    .rpg-levelup-card,
    .rpg-levelup-icon,
    .rpg-badge-notif,
    .rpg-boss-notif,
    .rpg-panel,
    .rpg-widget-xp-fill,
    .rpg-progress-fill,
    .rpg-boss-progress-fill {
        animation: none !important;
        transition: none !important;
    }
}
