/* --- 1. Base Setup --- */
:root {
    --primary-color: #00d2ff;
    --secondary-color: #007aff;
    --danger-color: #ff4757;
    --text-color-light: #e0e0e0;
    --text-color-dark: #1a1a1a;
    --sidebar-width: 300px;
    --glass-blur: 20px;
}

body {
    font-family: 'Kanit', sans-serif;
    margin: 0; padding: 0;
    overflow-x: hidden;
    min-height: 100vh;
    background-color: #050505; 
    color: var(--text-color-light);
    display: flex; flex-direction: column;
}

/* ป้องกันการคัดลอก (ตามคำขอ) */
.glass-card {
    user-select: none;
    -webkit-user-select: none;
}

/* --- 2. Background (Layer ล่างสุด) --- */
#bg-container {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -999; /* ดันไปหลังสุด */
    pointer-events: none; /* ห้ามให้เมาส์ไปโดน */
}

#star-canvas, #image-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    transition: opacity 0.8s ease;
}

#image-bg {
    background-image: url('/static/images/background.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    opacity: 0;
}

/* Theme State */
html.dark #star-canvas { opacity: 1; }
html.dark #image-bg { opacity: 0; }
html.light #image-bg { opacity: 1; }
html.light #star-canvas { opacity: 0; }
html.light body { color: var(--text-color-dark); }

/* --- 3. Interactive Elements (Layer บน) --- */
.top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    padding: 15px 25px;
    display: flex; justify-content: space-between;
    z-index: 100; /* อยู่เหนือเนื้อหา */
    pointer-events: auto; /* รับการคลิก */
}

.content-wrapper {
    position: relative;
    z-index: 10; /* อยู่เหนือพื้นหลัง */
    padding: 90px 20px 40px;
    display: flex; justify-content: center;
    min-height: 100vh;
    box-sizing: border-box;
}

/* --- 4. Glassmorphism UI --- */
.to-be-glass, .glass-card, .glass-sidebar {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: all 0.3s ease;
}

html.light .to-be-glass, 
html.light .glass-card, 
html.light .glass-sidebar {
    background: rgba(255, 255, 255, 0.65);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
    color: #000;
}

/* --- 5. Buttons --- */
.icon-btn, .lang-btn {
    border: none;
    color: inherit;
    font-family: inherit;
    cursor: pointer; /* ต้องเป็นรูปมือ */
    display: flex; align-items: center; justify-content: center;
}
.icon-btn { width: 45px; height: 45px; border-radius: 50%; font-size: 1.2rem; }
.lang-btn { padding: 8px 20px; border-radius: 30px; font-weight: 600; }
.icon-btn:hover, .lang-btn:hover { background: rgba(255,255,255,0.2); transform: translateY(-2px); }

/* --- 6. Content Card --- */
.glass-card {
    width: 100%; max-width: 900px;
    padding: 40px; border-radius: 25px;
    min-height: 400px;
    position: relative;
}

/* Loading */
.loading-state {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center; color: var(--primary-color);
    display: none;
}
.loading-state.active { display: block; }

/* Content Styles */
.policy-content h2, .policy-content h3 { color: var(--primary-color); }
html.light .policy-content h2, html.light .policy-content h3 { color: var(--secondary-color); }
.policy-content p, .policy-content li { line-height: 1.7; opacity: 0.9; }

/* --- 7. Sidebar & Overlay --- */
.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 199;
    opacity: 0; 
    visibility: hidden; /* สำคัญ! ป้องกันไม่ให้บังปุ่มตอนปิด */
    transition: all 0.3s ease;
}
.overlay.active { opacity: 1; visibility: visible; }

.glass-sidebar {
    position: fixed; top: 0; left: -320px;
    width: var(--sidebar-width); height: 100%;
    z-index: 200;
    display: flex; flex-direction: column;
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.glass-sidebar.active { left: 0; }

.sidebar-header { padding: 20px; display: flex; justify-content: space-between; align-items: center; }
.nav-list { list-style: none; padding: 20px 10px; margin: 0; flex: 1; overflow-y: auto; }

.nav-item {
    padding: 12px 15px; margin-bottom: 8px; border-radius: 15px;
    cursor: pointer; display: flex; align-items: center;
    transition: all 0.2s ease;
}
.nav-item:hover { background: rgba(255,255,255,0.1); transform: translateX(5px); }
.nav-item.active { background: var(--primary-color); color: #000; box-shadow: 0 4px 15px rgba(0,210,255,0.3); }

/* --- 8. Footer Items --- */
.sidebar-footer { padding: 20px; display: flex; flex-direction: column; gap: 15px; }

.theme-switch {
    width: 100%; padding: 12px; border-radius: 20px;
    border: none; color: inherit; cursor: pointer;
    display: flex; justify-content: center; gap: 10px; font-weight: 600;
}

.contact-hub { display: flex; justify-content: center; gap: 15px; }
.c-item {
    width: 50px; height: 50px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; color: inherit; background: rgba(255,255,255,0.1);
    transition: 0.3s; text-decoration: none;
}
.c-item:hover { transform: translateY(-5px); }
.c-item.discord:hover { background: #5865F2; color: #fff; }
.c-item.facebook:hover { background: #1877F2; color: #fff; }
.c-item.instagram:hover { background: #d6249f; color: #fff; }

.report-link {
    display: flex; justify-content: center; align-items: center; gap: 10px;
    padding: 12px; border-radius: 20px; background: var(--danger-color);
    color: white; text-decoration: none; font-weight: 600;
    transition: 0.3s;
}
.report-link:hover { background: #ff2e40; transform: translateY(-2px); }