/* ==========================================================================
   Spin Wheel SPA - Global Styles & Dark Gaming Theme System
   ภาษาคอมเม้นท์: ภาษาไทย
   ========================================================================== */

/* นำเข้าฟอนต์ Kanit และ Prompt สำหรับภาษาไทยสมัยใหม่ทางการ */
@import url('https://fonts.googleapis.com/css2?family=Kanit:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=Prompt:wght@300;400;500;600;700&display=swap');

/* --------------------------------------------------------------------------
   1. ตัวแปรสีและดีไซน์โทเค็น (Design Tokens & Variables)
   -------------------------------------------------------------------------- */
:root {
    /* โทนสีหลัก (Color Palette) */
    --bg-primary: #0b0e14;
    --bg-secondary: #121824;
    --bg-card: rgba(18, 24, 36, 0.85);
    --bg-card-hover: rgba(26, 35, 52, 0.9);
    
    /* สี Accent & Glow */
    --accent-cyan: #00f0ff;
    --accent-gold: #ffd700;
    --accent-purple: #9d4edd;
    --accent-pink: #ff0055;
    --accent-green: #00ff88;
    
    /* ข้อความ (Typography Colors) */
    --text-main: #f0f4f8;
    --text-muted: #8a99ad;
    --text-dark: #0b0e14;
    
    /* การ์ดและขอบ (Borders & Glassmorphism) */
    --border-color: rgba(0, 240, 255, 0.2);
    --border-glow: 0 0 15px rgba(0, 240, 255, 0.3);
    --glass-backdrop: blur(12px);
    
    /* ฟอนต์หลัก ภาษาไทยใช้ Kanit & Prompt สมัยใหม่ทางการ */
    --font-family: 'Kanit', 'Prompt', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --------------------------------------------------------------------------
   2. การตั้งค่าพื้นฐาน (Reset & Global Base)
   -------------------------------------------------------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 50% 0%, rgba(0, 240, 255, 0.15) 0%, transparent 60%),
        radial-gradient(circle at 80% 100%, rgba(157, 78, 221, 0.12) 0%, transparent 50%);
    background-attachment: fixed;
}

/* Container สัดส่วน Mobile First */
#app {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 16px;
}

/* บนจอขนาดใหญ่ (Tablet/PC) ขยาย Admin Dashboard ได้ */
@media (min-width: 768px) {
    #app.admin-mode {
        max-width: 1024px;
    }
}

/* --------------------------------------------------------------------------
   3. UI Components คอมโพเนนต์พื้นฐาน
   -------------------------------------------------------------------------- */

/* การ์ด Glassmorphism */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-backdrop);
    -webkit-backdrop-filter: var(--glass-backdrop);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    margin-bottom: 16px;
}

/* ปุ่มสไตล์ Cyber Gaming */
.btn-cyber {
    background: linear-gradient(135deg, var(--accent-cyan), #0088ff);
    color: var(--text-dark);
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 16px;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
}

.btn-cyber:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.7);
}

.btn-cyber:active {
    transform: translateY(1px);
}

.btn-cyber:disabled {
    background: #2a3446;
    color: #5a697d;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-gold {
    background: linear-gradient(135deg, var(--accent-gold), #ff8800);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

.btn-gold:hover {
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.7);
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-pink), #cc0044);
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.4);
}

/* --------------------------------------------------------------------------
   7. Responsive Table & Cyber Card System แบบ 2 คอลัมน์สมดุลบนจอมือถือ
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .responsive-history-table thead {
        display: none;
    }
    .responsive-history-table, 
    .responsive-history-table tbody {
        display: block;
        width: 100%;
    }
    .responsive-history-table tr {
        display: grid !important;
        grid-template-columns: 1fr auto !important;
        gap: 6px 12px !important;
        align-items: center !important;
        margin-bottom: 10px !important;
        background: rgba(18, 24, 36, 0.92) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 12px !important;
        padding: 12px 14px !important;
        box-shadow: 0 4px 15px rgba(0,0,0,0.5) !important;
    }
    .responsive-history-table td {
        padding: 0 !important;
        border: none !important;
        text-align: left !important;
    }
    .responsive-history-table .col-token {
        grid-column: 1;
        font-size: 13.5px !important;
        font-weight: 700 !important;
    }
    .responsive-history-table .col-status {
        grid-column: 2;
        text-align: right !important;
    }
    .responsive-history-table .col-uid {
        grid-column: 1;
        font-size: 12px !important;
    }
    .responsive-history-table .col-spins {
        display: none !important;
    }
    .responsive-history-table .col-time {
        grid-column: 1;
        font-size: 10.5px !important;
        color: var(--text-muted) !important;
    }
    .responsive-history-table .col-action {
        grid-column: 2;
        text-align: right !important;
    }
}

/* Input Fields */
.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 600;
}

.input-cyber, .select-cyber {
    width: 100%;
    padding: 12px 16px;
    background: rgba(11, 14, 20, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-main);
    font-family: var(--font-family);
    font-size: 15px;
    outline: none;
    transition: border-color 0.3s;
}

.input-cyber:focus, .select-cyber:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

/* --------------------------------------------------------------------------
   4. Header & Profile Badge ฝั่งผู้เล่น
   -------------------------------------------------------------------------- */
.player-header {
    text-align: center;
    margin-bottom: 16px;
}

.game-logo {
    max-height: 70px;
    object-fit: contain;
    filter: drop-shadow(0 0 12px rgba(0, 240, 255, 0.5));
    margin-bottom: 10px;
}

.badge-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.info-badge {
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid var(--accent-cyan);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-cyan);
}

.spin-badge {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
}

/* --------------------------------------------------------------------------
   5. วงล้อ 14 ช่อง (Spin Wheel Container ตามแบบรูปภาพอ้างอิง)
   -------------------------------------------------------------------------- */
.wheel-wrapper {
    position: relative;
    width: 330px;
    height: 330px;
    margin: 16px auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

@media (max-width: 360px) {
    .wheel-wrapper {
        width: 290px;
        height: 290px;
    }
}

/* เข็มชี้วงล้อ สีแดงสดอยู่เลเยอร์ด้านหลังดุมวงกลม ปรับความสูงให้เห็นเข็มชี้เด่นชัดโผล่ขึ้นด้านบน 12 นาฬิกา */
.wheel-pointer {
    position: absolute;
    top: calc(50% - 56px);
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 13px solid transparent;
    border-right: 13px solid transparent;
    border-bottom: 34px solid #ff1a1a;
    filter: drop-shadow(0 -3px 8px rgba(255, 26, 26, 0.95));
    z-index: 8;
    pointer-events: none;
}

/* Element วงล้อ Canvas มีไฟกะพริบเรืองแสงสลับสีวนรอบวงล้อ */
#wheelCanvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

/* ปุ่มหมุนตรงกลางแบบวงกลมส้มมีขอบสีขาวเส้นประ และใส่อิโมจิ 🔄 (ปรับเล็กลง 10% ตามคำขอ) */
.spin-center-btn {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff9900 0%, #ff5500 100%);
    border: 3.5px solid #ffffff;
    box-shadow: 0 0 0 3px #ff9900, 0 0 20px rgba(255, 153, 0, 0.9);
    color: #ffffff;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
    outline: none;
}

.spin-center-btn:active {
    transform: scale(0.92);
}

/* --------------------------------------------------------------------------
   6. Winner Popup Modal สไตล์สีเขียวชัยชนะ (Victory Neon Green Theme)
   -------------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(11, 14, 20, 0.88);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* การ์ด Popup สไตล์สีเขียวเนออนชัยชนะ */
.modal-card {
    background: var(--bg-card);
    border: 2px solid #00ff88;
    border-radius: 20px;
    padding: 24px;
    width: 90%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 0 35px rgba(0, 255, 136, 0.45);
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.reward-img-container {
    width: 110px;
    height: 110px;
    margin: 16px auto;
    border-radius: 16px;
    background: rgba(0, 255, 136, 0.1);
    border: 1.5px solid #00ff88;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

.reward-img-container img {
    max-width: 85px;
    max-height: 85px;
    object-fit: contain;
}

.reward-title {
    font-size: 20px;
    color: #00ff88;
    margin-bottom: 8px;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

/* ปุ่มตกลงสีเขียวชัยชนะ */
.btn-green-victory {
    background: linear-gradient(135deg, #00ff88 0%, #00b359 100%);
    color: #0b0e14;
    font-weight: 700;
    font-size: 18px;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.6);
    transition: all 0.3s ease;
}

.btn-green-victory:hover {
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.9);
    transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
   7. Navigation & Tabs ฝั่ง Admin
   -------------------------------------------------------------------------- */
.admin-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.tab-btn {
    padding: 10px 16px;
    background: rgba(18, 24, 36, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
}

.tab-btn.active {
    background: var(--accent-cyan);
    color: var(--text-dark);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

/* ตารางข้อมูล Admin */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 14px;
}

.admin-table th, .admin-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-table th {
    color: var(--accent-cyan);
    font-weight: 600;
}
