/* ============================================================
   FILE: static/css/vote_style.css
   VERSION: Ultimate Glassmorphism (Full Option)
   DESCRIPTION: ไฟล์ CSS ฉบับเต็ม รองรับโหมดสีสันและมือถือ
   ============================================================ */

/* 1. ตั้งค่าตัวแปรสี (Variables) 
   แก้ตรงนี้ที่เดียว เปลี่ยนสีได้ทั้งเว็บ */
:root {
    --bg-color: #1a1a1a;        /* สีพื้นหลังโหมดปกติ */
    --text-color: #ffffff;      /* สีตัวหนังสือ */
    --card-bg: #2d2d2d;         /* สีพื้นหลังการ์ด */
    --accent-color: #888;       /* สีรอง */
    
    /* การตั้งค่า Glassmorphism (กระจก) สำหรับ Dark Mode */
    --glass-bg: rgba(255, 255, 255, 0.1); 
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --blur-strength: 12px;
}

/* 2. โหมดสีสัน (Colorful Mode) 
   ทำงานเมื่อ Body มี Class "colorful-mode" */
body.colorful-mode {
    --bg-color: #f0f2f5;
    --text-color: #333;
    --card-bg: #fff;
    --accent-color: #ff4757;
    
    /* การตั้งค่า Glassmorphism สำหรับ Colorful Mode */
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.9);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* 3. โครงสร้างหลัก (Main Layout) */
body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Kanit', sans-serif;
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden; /* ป้องกันจอล้นแนวนอน */
    transition: background-color 0.5s ease;
}

/* ปิด Animation มาตรฐานของ Browser (เพื่อให้ JS คำนวณวงกลมแทน) */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

.container {
    text-align: center;
    width: 90%;
    max-width: 600px;
    position: relative;
    padding-bottom: 60px; /* เผื่อพื้นที่ด้านล่างในมือถือ */
    z-index: 1;
}

h1 {
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* 4. พื้นที่โหวต (Voting Area) */
.vote-area {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap; /* ย่อหน้าจอแล้วปัดลงบรรทัดใหม่ */
}

.vote-card {
    background: var(--card-bg);
    padding: 40px 20px;
    border-radius: 25px;
    width: 42%;            /* กำหนดความกว้าง */
    min-width: 140px;      /* ไม่ให้เล็กจนน่าเกลียด */
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}

/* Effect ตอนเอาเมาส์ชี้การ์ด */
.vote-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.3);
    border-color: var(--text-color);
}

.vote-card:active {
    transform: scale(0.95);
}

/* ไอคอนในการ์ด */
.vote-card i {
    font-size: 3.5rem;
    margin-bottom: 15px;
    display: block;
    transition: color 0.3s;
}

/* 5. ปุ่มสลับเพศ (Gender Switch) */
.gender-switch-wrapper {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    background: rgba(0,0,0,0.2);
    padding: 10px 20px;
    border-radius: 50px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.switch-btn {
    background: transparent;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    padding: 8px 25px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.switch-btn:hover {
    background: rgba(255,255,255,0.1);
}

.switch-btn.active {
    background: var(--text-color);
    color: var(--bg-color);
    font-weight: bold;
    box-shadow: 0 0 15px rgba(255,255,255,0.3);
    transform: scale(1.05);
}

/* 6. ส่วนแสดงผลลัพธ์ (Result Area) */
#result-area {
    display: none; /* ซ่อนไว้ก่อน */
    margin-top: 30px;
    background: var(--card-bg);
    padding: 30px;
    border-radius: 25px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-row {
    text-align: left;
    margin-bottom: 20px;
}

.result-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 500;
}

/* หลอดพลัง (Progress Bar) */
.progress-track {
    background: #444;
    height: 16px;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}
body.colorful-mode .progress-track { background: #ddd; }

.progress-bar {
    height: 100%;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
}

/* 7. ปุ่มดูสถิติ (Stats Button) */
#stats-btn-container {
    display: none; /* 🔥 ต้องซ่อนไว้เป็นค่าเริ่มต้น 🔥 */
    margin-top: 25px;
    justify-content: center;
}

.stats-btn {
    background: transparent;
    border: 2px solid var(--text-color);
    color: var(--text-color);
    padding: 12px 35px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stats-btn:hover {
    background: var(--text-color);
    color: var(--bg-color);
    box-shadow: 0 0 20px rgba(255,255,255,0.4);
    transform: scale(1.05);
}

/* 8. 🔥 GLASSPHORISM MODAL (หน้าต่างแก้วกระจกของจริง) 🔥 */
.modal-overlay {
    display: none; /* ซ่อน */
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.6); /* ฉากหลังมืดลง 60% */
    z-index: 9999;
    justify-content: center;
    align-items: center;
    
    /* Effect เบลอฉากหลัง */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-content {
    /* พื้นหลังกระจก */
    background: var(--glass-bg);
    color: var(--text-color);
    
    padding: 35px;
    border-radius: 30px;
    width: 85%;
    max-width: 450px;
    
    /* ขอบกระจกและเงา */
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    
    /* เบลอตัวกระจกเอง */
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    
    text-align: left;
    position: relative;
    
    /* Animation ตอนเด้งขึ้น */
    animation: glassPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes glassPop {
    from { transform: scale(0.7) translateY(30px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

/* จัดระเบียบข้อความใน Modal */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 10px;
}

.close-modal-icon {
    font-size: 2rem;
    cursor: pointer;
    line-height: 0.8;
    transition: 0.3s;
    opacity: 0.7;
}
.close-modal-icon:hover {
    opacity: 1;
    transform: rotate(90deg);
    color: #ff4757;
}

.stat-group {
    margin-bottom: 20px;
    background: rgba(0,0,0,0.1);
    padding: 15px;
    border-radius: 15px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 1rem;
}

/* 9. Mobile Responsive (ปรับแต่งมือถือ) */
@media (max-width: 768px) {
    .container { width: 95%; padding-top: 10px; }
    h1 { font-size: 1.8rem; }
    
    .vote-area { gap: 10px; }
    
    .vote-card { 
        padding: 25px 15px; 
    }
    
    .vote-card h2 { font-size: 1.1rem; }
    .vote-card i { font-size: 2.5rem !important; }
    
    .switch-btn { padding: 8px 15px; font-size: 0.9rem; }
    
    .modal-content { 
        width: 90%; 
        padding: 25px; 
    }
}