/* ============================================================
   spin/css/wheel.css
   Giao diện gaming hiện đại cho module Vòng Quay May Mắn.
   Đồng bộ tông màu với css/style.css của site (nền tối, gradient
   tím/hồng #a78bfa -> #ec4899, glassmorphism card).
   ============================================================ */

.sw-header {
    text-align: center;
    padding: 110px 20px 30px;
}

.sw-header h1 {
    font-size: 2.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fbbf24 0%, #ec4899 50%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}

.sw-header p {
    color: #94a3b8;
    font-size: 15px;
}

.sw-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px 60px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .sw-container {
        grid-template-columns: 1fr;
    }
}

.sw-card {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(71, 85, 105, 0.4);
    border-radius: 24px;
    padding: 28px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ===== TICKET BAR ===== */
.sw-ticket-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 16px;
    padding: 14px 18px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.sw-ticket-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sw-ticket-icon {
    font-size: 30px;
    filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.5));
}

.sw-ticket-label {
    font-size: 12px;
    color: #94a3b8;
}

.sw-ticket-count {
    font-size: 22px;
    font-weight: 800;
    color: #fbbf24;
}

.sw-btn-secondary {
    background: rgba(167, 139, 250, 0.15);
    border: 1px solid rgba(167, 139, 250, 0.5);
    color: #c4b5fd;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.25s;
    white-space: nowrap;
}

.sw-btn-secondary:hover {
    background: rgba(167, 139, 250, 0.3);
    transform: translateY(-1px);
}

/* ===== WHEEL ===== */
.sw-wheel-wrapper {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
}

#wheelCanvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow:
        0 0 0 8px rgba(15, 23, 42, 0.9),
        0 0 0 12px rgba(251, 191, 36, 0.4),
        0 20px 50px rgba(0, 0, 0, 0.5);
    transition: transform 4.5s cubic-bezier(0.17, 0.84, 0.36, 1);
}

.sw-wheel-pointer {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 38px;
    color: #fbbf24;
    z-index: 5;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
    animation: sw-bounce 1.6s infinite;
}

@keyframes sw-bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(5px); }
}

.sw-wheel-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fde68a, #fbbf24 55%, #d97706);
    border: 4px solid #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #1e293b;
    font-size: 16px;
    cursor: pointer;
    z-index: 6;
    box-shadow: 0 6px 18px rgba(251, 191, 36, 0.6), inset 0 -4px 8px rgba(0,0,0,0.15);
    transition: transform 0.15s ease;
    user-select: none;
}

.sw-wheel-center:hover {
    transform: translate(-50%, -50%) scale(1.05);
}

.sw-wheel-center.disabled {
    cursor: not-allowed;
    opacity: 0.6;
    filter: grayscale(0.4);
}

.sw-wheel-center.disabled:hover {
    transform: translate(-50%, -50%);
}

/* ===== MAIN SPIN BUTTON ===== */
.sw-btn-primary {
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #fbbf24 0%, #ec4899 100%);
    color: #1e1b4b;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(251, 191, 36, 0.4);
    letter-spacing: 0.3px;
}

.sw-btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(236, 72, 153, 0.5);
}

.sw-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(71, 85, 105, 0.5);
    color: #94a3b8;
    box-shadow: none;
}

.sw-notice {
    margin-top: 16px;
    text-align: center;
    padding: 12px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    color: #fca5a5;
    font-size: 14px;
}

.sw-notice a {
    color: #fbbf24;
    font-weight: 600;
}

/* ===== TABS ===== */
.sw-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(71, 85, 105, 0.4);
    padding-bottom: 2px;
}

.sw-tab {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 10px 10px 0 0;
    transition: 0.2s;
    position: relative;
}

.sw-tab:hover {
    color: #e2e8f0;
    background: rgba(167, 139, 250, 0.1);
}

.sw-tab.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.25), rgba(236, 72, 153, 0.25));
}

.sw-tab.active::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 10%;
    right: 10%;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(135deg, #a78bfa, #ec4899);
}

.sw-tab-panel {
    display: none;
}

.sw-tab-panel.active {
    display: block;
    animation: sw-fade-in 0.25s ease;
}

@keyframes sw-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== LIST ITEMS (history / rewards / tasks) ===== */
.sw-list {
    max-height: 480px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

.sw-list::-webkit-scrollbar { width: 6px; }
.sw-list::-webkit-scrollbar-thumb { background: rgba(167, 139, 250, 0.4); border-radius: 6px; }

.sw-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(71, 85, 105, 0.4);
    border-radius: 14px;
    padding: 12px 16px;
    transition: 0.2s;
}

.sw-item:hover {
    border-color: rgba(167, 139, 250, 0.5);
}

.sw-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sw-item-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.sw-item-name {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sw-item-sub {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

.sw-item-right {
    text-align: right;
    flex-shrink: 0;
}

.sw-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
}

.sw-badge-win {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.sw-badge-lose {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}

.sw-badge-pending {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.sw-empty {
    text-align: center;
    color: #64748b;
    padding: 40px 10px;
    font-size: 14px;
}

/* ===== TASKS ===== */
.sw-task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(71, 85, 105, 0.4);
    border-radius: 14px;
    padding: 14px 16px;
}

.sw-task-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.sw-task-icon {
    font-size: 26px;
    flex-shrink: 0;
}

.sw-task-title {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 14px;
}

.sw-task-desc {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 3px;
}

.sw-task-reward {
    font-size: 11px;
    color: #fbbf24;
    font-weight: 700;
    margin-top: 4px;
}

.sw-btn-task {
    flex-shrink: 0;
    padding: 9px 16px;
    border-radius: 10px;
    border: none;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(135deg, #a78bfa, #ec4899);
    color: white;
    transition: 0.2s;
    white-space: nowrap;
}

.sw-btn-task:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(167, 139, 250, 0.4);
}

.sw-btn-task:disabled {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    cursor: default;
}

/* ===== RULES ===== */
.sw-rules {
    color: #cbd5e1;
    font-size: 14px;
    line-height: 1.8;
}

.sw-rules p {
    margin-bottom: 10px;
    padding-left: 4px;
}

/* ===== RESULT MODAL ===== */
.sw-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
}

.sw-modal.show {
    display: flex;
}

.sw-modal-box {
    position: relative;
    background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(251, 191, 36, 0.4);
    border-radius: 24px;
    padding: 40px 30px;
    width: 90%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    animation: sw-modal-pop 0.35s ease-out;
    overflow: hidden;
}

@keyframes sw-modal-pop {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

.sw-result-icon {
    font-size: 64px;
    margin-bottom: 12px;
    filter: drop-shadow(0 4px 12px rgba(251, 191, 36, 0.5));
}

.sw-modal-box h3 {
    font-size: 22px;
    color: #fff;
    margin-bottom: 14px;
}

.sw-result-prize {
    font-size: 19px;
    font-weight: 800;
    background: linear-gradient(135deg, #fbbf24, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    word-break: break-word;
}

.sw-result-detail {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 22px;
    word-break: break-word;
}

.sw-result-confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.sw-confetti-piece {
    position: absolute;
    top: -10px;
    width: 8px;
    height: 14px;
    opacity: 0.9;
    animation: sw-confetti-fall linear forwards;
}

@keyframes sw-confetti-fall {
    to {
        transform: translateY(420px) rotate(540deg);
        opacity: 0;
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .sw-header { padding: 95px 16px 20px; }
    .sw-header h1 { font-size: 1.7rem; }
    .sw-card { padding: 18px; border-radius: 18px; }
    .sw-wheel-wrapper { max-width: 320px; }
    .sw-wheel-center { width: 70px; height: 70px; font-size: 13px; }
    .sw-ticket-count { font-size: 18px; }
    .sw-task-item { flex-direction: column; align-items: stretch; }
    .sw-btn-task { width: 100%; }
}
