/**
 * COMPOS TOAST NOTIFICATIONS
 * Beautiful, branded toast notifications
 * Overrides GamiPress ugly popups + Custom notification system
 * 
 * Matches: Black/Orange Compos Design System
 */

/* ============================================================================
   CSS VARIABLES (inherit from main theme)
   ============================================================================ */

:root {
    /* Brand Colors */
    --compos-orange: #FF650E;
    --compos-orange-light: #FF8B4A;
    --compos-orange-dark: #E5470A;
    --compos-orange-glow: rgba(255, 101, 14, 0.4);
    
    /* Backgrounds */
    --compos-bg-dark: #0a0a0a;
    --compos-bg-card: #141414;
    --compos-bg-lighter: #1e1e1e;
    --compos-border: #2a2a2a;
    
    /* Text */
    --compos-text-white: #ffffff;
    --compos-text-gray: #b3b3b3;
    
    /* Status Colors */
    --compos-success: #4ade80;
    --compos-error: #ef4444;
    --compos-warning: #f59e0b;
    --compos-info: #3b82f6;
}

/* ============================================================================
   TOAST NOTIFICATION CONTAINER
   ============================================================================ */

.compos-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
    width: calc(100vw - 48px);
    pointer-events: none;
}

/* Mobile positioning */
@media (max-width: 768px) {
    .compos-toast-container {
        top: auto;
        bottom: 24px;
        right: 12px;
        left: 12px;
        max-width: none;
        width: auto;
    }
}

/* ============================================================================
   INDIVIDUAL TOAST NOTIFICATION
   ============================================================================ */

.compos-toast {
    background: linear-gradient(135deg, var(--compos-bg-card) 0%, var(--compos-bg-lighter) 100%);
    border-radius: 16px;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 0 1px var(--compos-border);
    pointer-events: auto;
    animation: toastSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: top right;
    position: relative;
}

.compos-toast.exiting {
    animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
    0% {
        transform: translateX(100%) scale(0.8);
        opacity: 0;
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateX(100%) scale(0.8);
        opacity: 0;
    }
}

/* Mobile animation */
@media (max-width: 768px) {
    @keyframes toastSlideIn {
        0% {
            transform: translateY(100%) scale(0.8);
            opacity: 0;
        }
        100% {
            transform: translateY(0) scale(1);
            opacity: 1;
        }
    }
    
    @keyframes toastSlideOut {
        0% {
            transform: translateY(0) scale(1);
            opacity: 1;
        }
        100% {
            transform: translateY(100%) scale(0.8);
            opacity: 0;
        }
    }
}

/* ============================================================================
   TOAST COLOR STRIPE (Top indicator)
   ============================================================================ */

.compos-toast::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--toast-color, var(--compos-orange));
}

.compos-toast.success { --toast-color: var(--compos-success); }
.compos-toast.error { --toast-color: var(--compos-error); }
.compos-toast.warning { --toast-color: var(--compos-warning); }
.compos-toast.info { --toast-color: var(--compos-info); }
.compos-toast.achievement { --toast-color: var(--compos-orange); }
.compos-toast.winner { --toast-color: linear-gradient(90deg, #ffd700, #ff6600, #ffd700); }

.compos-toast.winner::before {
    background: linear-gradient(90deg, #ffd700, #ff6600, #ffd700);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ============================================================================
   TOAST CONTENT
   ============================================================================ */

.compos-toast-content {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
}

.compos-toast-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.compos-toast.success .compos-toast-icon { 
    background: rgba(74, 222, 128, 0.15); 
    border-color: rgba(74, 222, 128, 0.3);
}
.compos-toast.error .compos-toast-icon { 
    background: rgba(239, 68, 68, 0.15); 
    border-color: rgba(239, 68, 68, 0.3);
}
.compos-toast.warning .compos-toast-icon { 
    background: rgba(245, 158, 11, 0.15); 
    border-color: rgba(245, 158, 11, 0.3);
}
.compos-toast.info .compos-toast-icon { 
    background: rgba(59, 130, 246, 0.15); 
    border-color: rgba(59, 130, 246, 0.3);
}
.compos-toast.achievement .compos-toast-icon { 
    background: rgba(255, 101, 14, 0.15); 
    border-color: rgba(255, 101, 14, 0.3);
}
.compos-toast.winner .compos-toast-icon {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 101, 14, 0.2));
    border-color: rgba(255, 215, 0, 0.4);
    animation: winnerPulse 1.5s ease-in-out infinite;
}

@keyframes winnerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.compos-toast-text {
    flex: 1;
    min-width: 0;
}

.compos-toast-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--compos-text-white);
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.compos-toast-message {
    font-size: 14px;
    color: var(--compos-text-gray);
    margin: 0;
    line-height: 1.5;
}

.compos-toast-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--compos-text-gray);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.compos-toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--compos-text-white);
}

/* ============================================================================
   TOAST PROGRESS BAR
   ============================================================================ */

.compos-toast-progress {
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.compos-toast-progress-bar {
    height: 100%;
    background: var(--toast-color, var(--compos-orange));
    animation: progressShrink var(--toast-duration, 5s) linear forwards;
}

@keyframes progressShrink {
    0% { width: 100%; }
    100% { width: 0%; }
}

/* ============================================================================
   TOAST ACTION BUTTONS
   ============================================================================ */

.compos-toast-actions {
    display: flex;
    gap: 8px;
    padding: 0 20px 16px;
}

.compos-toast-action {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.compos-toast-action.primary {
    background: var(--compos-orange);
    color: white;
}

.compos-toast-action.primary:hover {
    background: var(--compos-orange-light);
    transform: translateY(-1px);
}

.compos-toast-action.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--compos-text-white);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.compos-toast-action.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ============================================================================
   WINNER CELEBRATION TOAST (Special)
   ============================================================================ */

.compos-toast.winner {
    background: linear-gradient(135deg, #1a1510 0%, #0f0a05 100%);
    border: 2px solid rgba(255, 215, 0, 0.3);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 60px rgba(255, 215, 0, 0.2),
        inset 0 0 40px rgba(255, 215, 0, 0.05);
}

.compos-toast.winner .compos-toast-title {
    background: linear-gradient(90deg, #ffd700, #ff8c00, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 18px;
}

.compos-toast.winner .compos-toast-reward {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 101, 14, 0.2));
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    color: #ffd700;
}

/* ============================================================================
   ACHIEVEMENT UNLOCKED TOAST
   ============================================================================ */

.compos-toast.achievement {
    border: 1px solid rgba(255, 101, 14, 0.3);
}

.compos-toast.achievement .compos-toast-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(255, 101, 14, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 101, 14, 0.2);
}

.compos-toast.achievement .compos-toast-badge-icon {
    font-size: 24px;
}

.compos-toast.achievement .compos-toast-badge-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--compos-orange);
}

.compos-toast.achievement .compos-toast-reward {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    font-size: 13px;
    font-weight: 700;
    color: var(--compos-success);
}

/* ============================================================================
   DAILY TASK COMPLETED TOAST
   ============================================================================ */

.compos-toast.task .compos-toast-task-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.compos-toast.task .compos-toast-task-icon {
    font-size: 28px;
}

.compos-toast.task .compos-toast-task-details {
    flex: 1;
}

.compos-toast.task .compos-toast-task-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--compos-text-white);
}

.compos-toast.task .compos-toast-task-reward {
    font-size: 13px;
    color: var(--compos-success);
    font-weight: 700;
}

/* ============================================================================
   COINS EARNED TOAST
   ============================================================================ */

.compos-toast.coins .compos-toast-coins {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.compos-toast.coins .compos-toast-coins-amount {
    font-size: 28px;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 2px 12px rgba(255, 215, 0, 0.4);
}

.compos-toast.coins .compos-toast-coins-label {
    font-size: 14px;
    color: var(--compos-text-gray);
}

/* ============================================================================
   GAMIPRESS OVERRIDE STYLES
   ============================================================================ */

/* Hide original GamiPress popups */
.gamipress-popup,
.gamipress-achievement-unlock-popup,
.gamipress-requirement-popup,
.gamipress-notification-popup,
.gamipress-achievement-popup,
#gamipress-achievement-notification,
.gamipress-achievement-notification,
.gamipress-points-popup,
.gamipress-rank-popup,
.gamipress-award-popup,
[class*="gamipress"][class*="popup"],
[class*="gamipress"][class*="notification"],
.lty-popup,
.lottery-popup,
.lottery-notification {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Override any inline styles GamiPress might add */
body .gamipress-popup,
body .gamipress-achievement-popup,
body .gamipress-notification-popup,
html .gamipress-popup {
    display: none !important;
}

/* ============================================================================
   CONFETTI ANIMATION (for winner toasts)
   ============================================================================ */

.compos-confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999998;
    overflow: hidden;
}

.compos-confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-10px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ============================================================================
   NOTIFICATION BADGE (Bell icon counter)
   ============================================================================ */

.compos-notification-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--compos-orange);
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px var(--compos-orange-glow);
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ============================================================================
   NOTIFICATION CENTER DROPDOWN
   ============================================================================ */

.compos-notification-center {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 380px;
    max-height: 480px;
    background: linear-gradient(135deg, var(--compos-bg-card) 0%, var(--compos-bg-lighter) 100%);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--compos-border);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 999999;
}

.compos-notification-center.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.compos-notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--compos-border);
}

.compos-notification-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--compos-text-white);
    margin: 0;
}

.compos-notification-mark-read {
    font-size: 13px;
    color: var(--compos-orange);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.compos-notification-mark-read:hover {
    background: rgba(255, 101, 14, 0.1);
}

.compos-notification-list {
    max-height: 380px;
    overflow-y: auto;
}

.compos-notification-item {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.2s;
}

.compos-notification-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.compos-notification-item.unread {
    background: rgba(255, 101, 14, 0.05);
}

.compos-notification-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--compos-orange);
}

.compos-notification-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.compos-notification-item-content {
    flex: 1;
    min-width: 0;
}

.compos-notification-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--compos-text-white);
    margin-bottom: 2px;
}

.compos-notification-item-message {
    font-size: 13px;
    color: var(--compos-text-gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compos-notification-item-time {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 4px;
}

.compos-notification-empty {
    padding: 48px 20px;
    text-align: center;
    color: var(--compos-text-gray);
}

.compos-notification-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.compos-toast.loading .compos-toast-icon {
    position: relative;
}

.compos-toast.loading .compos-toast-icon::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--compos-orange);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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

@media (max-width: 480px) {
    .compos-toast-content {
        padding: 16px;
        gap: 12px;
    }
    
    .compos-toast-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .compos-toast-title {
        font-size: 15px;
    }
    
    .compos-toast-message {
        font-size: 13px;
    }
    
    .compos-notification-center {
        width: calc(100vw - 24px);
        right: -12px;
    }
}

/* ============================================================================
   DARK SCROLLBAR
   ============================================================================ */

.compos-notification-list::-webkit-scrollbar {
    width: 6px;
}

.compos-notification-list::-webkit-scrollbar-track {
    background: transparent;
}

.compos-notification-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.compos-notification-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
