/**
 * ================================================================
 * Fortune Wheel - Roue de la fortune (Mobile-First v3.29.0)
 * ================================================================
 *
 * Roue de la fortune animée avec canvas, historique des gains,
 * et overlay de résultats
 * Architecture mobile-first avec breakpoints progressifs
 *
 * @version 3.29.0
 */

/* ================================================================
   1. CSS VARIABLES
   ================================================================ */
:root {
    --cal-primary: #667eea; /* v3.9.5 - Fallback simplifié */
    --cal-secondary: #764ba2; /* v3.9.5 - Fallback simplifié */
    --cal-danger: #ff4757; /* v3.9.5 - Fallback simplifié */
    --fortune-primary: var(--cal-primary);
    --fortune-secondary: var(--cal-secondary);
    --fortune-gradient: linear-gradient(135deg, var(--fortune-primary) 0%, var(--fortune-secondary) 100%);
    --fortune-reward: linear-gradient(135deg, #f093fb 0%, var(--cal-danger) 100%);
    --fortune-text: #2B3674;
    --fortune-muted: #666;
    --fortune-arrow: #e74c3c;
    --fortune-white: #FFFFFF;

    --cal-transition-base: 0.3s ease;
    --cal-transition-fast: 0.2s ease;
}

/* ================================================================
   2. CONTAINER
   ================================================================ */
.fortune-wheel-activity {
    max-width: 100%;
    margin: 0 auto;
    padding: 15px;
}

@media (min-width: 768px) {
    .fortune-wheel-activity {
        max-width: 900px;
        padding: 20px;
    }
}

/* ================================================================
   3. HEADER
   ================================================================ */
.fortune-header {
    text-align: center;
    margin-bottom: 30px;
}

@media (min-width: 768px) {
    .fortune-header {
        margin-bottom: 40px;
    }
}

.fortune-header h2 {
    font-size: 28px;
    color: var(--fortune-text);
    margin: 0 0 10px;
}

@media (min-width: 768px) {
    .fortune-header h2 {
        font-size: 36px;
    }
}

.fortune-subtitle {
    font-size: 16px;
    color: var(--fortune-muted);
    margin: 0;
}

@media (min-width: 768px) {
    .fortune-subtitle {
        font-size: 18px;
    }
}

/* ================================================================
   4. WHEEL
   ================================================================ */
.wheel-container {
    display: flex;
    justify-content: center;
    margin: 30px 0;
}

@media (min-width: 768px) {
    .wheel-container {
        margin: 40px 0;
    }
}

.wheel-wrapper {
    position: relative;
    display: inline-block;
}

.wheel-arrow {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 32px;
    color: var(--fortune-arrow);
    z-index: 10;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

@media (min-width: 768px) {
    .wheel-arrow {
        font-size: 40px;
    }
}

#fortune-wheel {
    display: block;
    border-radius: 50%;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    width: 300px;
    height: 300px;
}

@media (min-width: 768px) {
    #fortune-wheel {
        width: 400px;
        height: 400px;
    }
}

.spin-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--fortune-gradient);
    color: var(--fortune-white);
    border: 5px solid var(--fortune-white);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--cal-transition-base);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    z-index: 20;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@media (min-width: 768px) {
    .spin-button {
        width: 100px;
        height: 100px;
        font-size: 16px;
    }
}

.spin-button:hover:not(:disabled):not(.spinning) {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

@media (hover: none) {
    .spin-button:active:not(:disabled):not(.spinning) {
        opacity: 0.85;
    }
}

.spin-button:disabled,
.spin-button.spinning {
    opacity: 0.6;
    cursor: not-allowed;
    animation: pulse-spin 1s infinite;
}

@keyframes pulse-spin {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
    }
}

/* ================================================================
   5. REWARDS INFO
   ================================================================ */
.rewards-info {
    text-align: center;
    margin: 30px 0;
    padding: 20px;
    background: var(--fortune-white);
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

@media (min-width: 768px) {
    .rewards-info {
        margin: 40px 0;
        padding: 30px;
    }
}

.rewards-info h4 {
    font-size: 18px;
    color: var(--fortune-text);
    margin: 0 0 15px;
}

@media (min-width: 768px) {
    .rewards-info h4 {
        font-size: 20px;
        margin: 0 0 20px;
    }
}

.rewards-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.reward-chip {
    display: inline-block;
    padding: 8px 16px;
    background: var(--fortune-reward);
    color: var(--fortune-white);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(240, 147, 251, 0.3);
}

/* ================================================================
   6. RESULT
   ================================================================ */
.fortune-result-container {
    display: flex;
    justify-content: center;
    margin: 30px 0;
}

@media (min-width: 768px) {
    .fortune-result-container {
        margin: 40px 0;
    }
}

.fortune-result-box {
    background: var(--fortune-gradient);
    color: var(--fortune-white);
    padding: 40px 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.4);
    animation: bounceIn 0.6s;
    width: 100%;
    max-width: 500px;
}

@media (min-width: 768px) {
    .fortune-result-box {
        padding: 60px 80px;
    }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.result-icon {
    font-size: 60px;
    margin-bottom: 15px;
}

@media (min-width: 768px) {
    .result-icon {
        font-size: 80px;
        margin-bottom: 20px;
    }
}

.fortune-result-box h3 {
    font-size: 24px;
    margin: 0 0 15px;
    color: var(--fortune-white);
}

@media (min-width: 768px) {
    .fortune-result-box h3 {
        font-size: 32px;
        margin: 0 0 20px;
    }
}

.reward-display {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px 30px;
    border-radius: 12px;
    font-size: 20px;
    font-weight: 700;
    margin: 15px 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

@media (min-width: 768px) {
    .reward-display {
        padding: 20px 40px;
        font-size: 24px;
        margin: 20px 0;
    }
}

.fortune-result-box p {
    font-size: 14px;
    margin: 10px 0 0;
    opacity: 0.9;
}

@media (min-width: 768px) {
    .fortune-result-box p {
        font-size: 16px;
    }
}

/* ================================================================
   7. HISTORY
   ================================================================ */
.fortune-history-section {
    margin-top: 40px;
}

@media (min-width: 768px) {
    .fortune-history-section {
        margin-top: 60px;
    }
}

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

@media (min-width: 768px) {
    .history-header {
        margin-bottom: 30px;
    }
}

.history-header h3 {
    font-size: 20px;
    color: var(--fortune-text);
    margin: 0;
}

@media (min-width: 768px) {
    .history-header h3 {
        font-size: 26px;
    }
}

.btn-refresh {
    padding: 10px 20px;
    background: var(--fortune-white);
    border: 2px solid var(--fortune-primary);
    color: var(--fortune-primary);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--cal-transition-fast);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@media (min-width: 768px) {
    .btn-refresh {
        font-size: 15px;
    }
}

.btn-refresh:hover {
    background: var(--fortune-primary);
    color: var(--fortune-white);
}

@media (hover: none) {
    .btn-refresh:active {
        opacity: 0.85;
    }
}

.history-list {
    display: grid;
    gap: 16px;
}

.history-item {
    background: var(--fortune-white);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 15px;
    transition: all var(--cal-transition-fast);
}

@media (min-width: 768px) {
    .history-item {
        padding: 20px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.history-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.history-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--fortune-primary);
}

.history-user strong {
    display: block;
    font-size: 15px;
    color: var(--fortune-text);
}

.history-time {
    font-size: 13px;
    color: #999;
    margin-top: 2px;
}

.history-reward {
    font-size: 15px;
    font-weight: 700;
    color: var(--fortune-primary);
    background: rgba(102, 126, 234, 0.1);
    padding: 8px 16px;
    border-radius: 8px;
    text-align: center;
}

@media (min-width: 768px) {
    .history-reward {
        font-size: 16px;
    }
}

/* ================================================================
   8. LOADING & EMPTY STATES
   ================================================================ */
.loading-spinner,
.no-history {
    text-align: center;
    padding: 40px 20px;
}

@media (min-width: 768px) {
    .loading-spinner,
    .no-history {
        padding: 60px 20px;
    }
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--fortune-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-spinner p,
.no-history p {
    color: var(--fortune-muted);
    font-size: 15px;
}

.no-history {
    background: var(--fortune-white);
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* ================================================================
   9. RESULT OVERLAY
   ================================================================ */
.fortune-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.fortune-result-content {
    background: var(--fortune-white);
    padding: 40px 30px;
    border-radius: 20px;
    text-align: center;
    animation: resultPop 0.6s ease-out;
    max-width: 500px;
    width: 100%;
}

@media (min-width: 768px) {
    .fortune-result-content {
        padding: 60px 80px;
    }
}

@keyframes resultPop {
    0% { transform: scale(0.5) rotate(-5deg); opacity: 0; }
    50% { transform: scale(1.1) rotate(2deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.result-confetti {
    font-size: 64px;
    margin-bottom: 15px;
    animation: confetti 1s infinite;
}

@media (min-width: 768px) {
    .result-confetti {
        font-size: 80px;
        margin-bottom: 20px;
    }
}

@keyframes confetti {
    0%, 100% { transform: rotate(-10deg); }
    50% { transform: rotate(10deg); }
}

.fortune-result-content h2 {
    font-size: 24px;
    color: var(--fortune-text);
    margin: 0 0 15px;
}

@media (min-width: 768px) {
    .fortune-result-content h2 {
        font-size: 32px;
        margin: 0 0 20px;
    }
}

.result-reward {
    background: var(--fortune-gradient);
    color: var(--fortune-white);
    padding: 15px 30px;
    border-radius: 12px;
    font-size: 20px;
    font-weight: 700;
    margin: 15px 0;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

@media (min-width: 768px) {
    .result-reward {
        padding: 20px 40px;
        font-size: 24px;
        margin: 20px 0;
    }
}

.btn-close-result {
    margin-top: 20px;
    padding: 12px 40px;
    background: var(--fortune-primary);
    color: var(--fortune-white);
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--cal-transition-fast);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-close-result:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

@media (hover: none) {
    .btn-close-result:active {
        opacity: 0.85;
    }
}
