/* =============================================
   DESIGN SYSTEM — Roleta Tiaraju
   ============================================= */

:root {
    /* Colors */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #22223a;
    --surface-glass: rgba(255, 255, 255, 0.04);
    --surface-glass-hover: rgba(255, 255, 255, 0.08);

    --text-primary: #f0f0f5;
    --text-secondary: #9d9db5;
    --text-muted: #5a5a7a;

    --accent-primary: #6366f1;
    --accent-secondary: #a855f7;
    --accent-tertiary: #ec4899;
    --accent-warm: #f59e0b;
    --accent-green: #10b981;
    --accent-red: #ef4444;

    /* Gradients */
    --gradient-hero: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
    --gradient-button: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    --gradient-card: linear-gradient(145deg, rgba(99, 102, 241, 0.08) 0%, rgba(168, 85, 247, 0.04) 100%);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);
    --shadow-glow-intense: 0 0 60px rgba(99, 102, 241, 0.5);

    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Outfit', 'Inter', sans-serif;
}

/* =============================================
   RESET & BASE
   ============================================= */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* =============================================
   ANIMATED BACKGROUND
   ============================================= */

.bg-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    transition: filter 0.4s ease;
}

.bg-particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat linear infinite;
}

@keyframes particleFloat {
    0% {
        opacity: 0;
        transform: translateY(100vh) scale(0);
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(-10vh) scale(1);
    }
}

/* =============================================
   APP CONTAINER
   ============================================= */

.app-container {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
    min-height: 100vh;
    transition: filter 0.4s ease;
}

.app-container.blurred,
.bg-particles.blurred {
    filter: blur(8px) brightness(0.5);
    pointer-events: none;
}

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

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) 0;
    margin-bottom: var(--space-2xl);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-glass);
    border-radius: var(--radius-md);
    border: 1px solid rgba(99, 102, 241, 0.2);
    backdrop-filter: blur(12px);
}

.logo-text {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.logo-text .accent {
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--surface-glass);
    border-radius: var(--radius-full);
    border: 1px solid rgba(16, 185, 129, 0.2);
    font-size: 0.85rem;
    color: var(--text-secondary);
    backdrop-filter: blur(12px);
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.2); }
}

/* =============================================
   MAIN CONTENT
   ============================================= */

.main-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2xl);
}

/* =============================================
   ROULETTE
   ============================================= */

.roulette-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.roulette-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
}

.roulette-pointer {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    filter: drop-shadow(0 4px 12px rgba(245, 158, 11, 0.5));
    animation: pointerBounce 1.5s ease-in-out infinite;
}

@keyframes pointerBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(4px); }
}

.roulette-container {
    width: 100%;
    height: 120px;
    overflow: hidden;
    position: relative;
    border-radius: var(--radius-lg);
    border: 2px solid rgba(99, 102, 241, 0.3);
    background: var(--bg-card);
    box-shadow: var(--shadow-glow), inset 0 0 30px rgba(0, 0, 0, 0.3);
}

/* Fade edges */
.roulette-container::before,
.roulette-container::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 120px;
    z-index: 5;
    pointer-events: none;
}

.roulette-container::before {
    left: 0;
    background: linear-gradient(to right, var(--bg-card) 0%, transparent 100%);
}

.roulette-container::after {
    right: 0;
    background: linear-gradient(to left, var(--bg-card) 0%, transparent 100%);
}

/* Center highlight line */
.roulette-container .center-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gradient-hero);
    transform: translateX(-50%);
    z-index: 6;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.6);
}

.roulette-strip {
    display: flex;
    align-items: center;
    height: 100%;
    will-change: transform;
    transition: none;
}

.roulette-item {
    flex-shrink: 0;
    width: 200px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    border-right: 1px solid rgba(99, 102, 241, 0.15);
    position: relative;
    user-select: none;
}

.roulette-item:nth-child(even) {
    background: rgba(99, 102, 241, 0.06);
}

.roulette-item:nth-child(odd) {
    background: rgba(168, 85, 247, 0.06);
}

.roulette-item .item-name {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
}

/* =============================================
   SPIN BUTTON
   ============================================= */

.spin-btn {
    position: relative;
    padding: var(--space-lg) var(--space-3xl);
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    background: var(--gradient-button);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-glow);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.spin-btn:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.03);
    box-shadow: var(--shadow-glow-intense);
}

.spin-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

.spin-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.spin-btn-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 60%);
    animation: btnGlow 3s linear infinite;
    pointer-events: none;
}

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

.spin-btn.spinning {
    pointer-events: none;
    animation: btnPulse 0.5s ease-in-out infinite;
}

@keyframes btnPulse {
    0%, 100% { box-shadow: 0 0 40px rgba(99, 102, 241, 0.3); }
    50% { box-shadow: 0 0 60px rgba(99, 102, 241, 0.6); }
}

/* =============================================
   WINNER CARD
   ============================================= */

.winner-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    width: 90%;
    max-width: 480px;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    border: 2px solid rgba(99, 102, 241, 0.4);
    padding: var(--space-3xl) var(--space-2xl);
    text-align: center;
    z-index: 1000;
    box-shadow: var(--shadow-glow-intense), 0 20px 60px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(20px);
    visibility: hidden;
    overflow: hidden;
}

.winner-card.visible {
    visibility: visible;
}

.winner-card.hidden {
    visibility: hidden;
}

.winner-confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

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

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

.winner-label {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--accent-warm);
    margin-bottom: var(--space-md);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.winner-name {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-lg);
    line-height: 1.2;
}

.winner-details {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: var(--space-xl);
}

.winner-details strong {
    color: var(--text-primary);
}

.powered-by {
    margin-top: var(--space-lg);
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    opacity: 0.6;
}

.powered-by a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.powered-by a:hover {
    color: var(--accent-secondary);
}

.winner-close {
    padding: var(--space-md) var(--space-xl);
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    background: var(--gradient-button);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.3s ease;
}

.winner-close:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}


/* =============================================
   STATS SECTION
   ============================================= */

.stats-section {
    width: 100%;
    max-width: 700px;
}

.stats-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--gradient-card);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    text-align: center;
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 800;
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-xs);
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}

/* Clients list */
.clients-list-wrapper {
    max-height: 400px;
    overflow-y: auto;
    border-radius: var(--radius-md);
    border: 1px solid rgba(99, 102, 241, 0.12);
    background: var(--bg-secondary);
}

.clients-list-wrapper::-webkit-scrollbar {
    width: 6px;
}

.clients-list-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.clients-list-wrapper::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-full);
}

.client-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.2s ease;
}

.client-row:last-child {
    border-bottom: none;
}

.client-row:hover {
    background: var(--surface-glass-hover);
}

.client-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.client-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-product {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 350px;
}

.client-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.client-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent-green);
}

.client-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

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

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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

@media (max-width: 640px) {
    .app-container {
        padding: var(--space-md);
    }

    .header {
        flex-direction: column;
        gap: var(--space-md);
        text-align: center;
    }

    .logo-text {
        font-size: 1.3rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .roulette-item {
        width: 160px;
        font-size: 0.85rem;
    }

    .roulette-container {
        height: 100px;
    }

    .spin-btn {
        padding: var(--space-md) var(--space-2xl);
        font-size: 1rem;
    }

    .winner-name {
        font-size: 1.5rem;
    }

    .client-product {
        max-width: 180px;
    }
}
