/**
 * ============================================================================
 * FILE: assets/css/main.css
 * DESCRIPTION: สไตล์ชีตหลักสำหรับหน้าเกม Front-end (HUD & UI Overlay)
 * THEME: Dark Sci-Fi / Post-Apocalyptic Survival (Glassmorphism)
 * ============================================================================
 */

/* ==========================================================================
   1. BASE & RESET
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden; /* ป้องกันการเลื่อนหน้าจอ */
    background-color: #050505; /* พื้นหลังสีดำกันขอบขาวตอนโหลด 3D */
    font-family: 'Sarabun', sans-serif;
    color: #ffffff;
    user-select: none; /* ห้ามคลุมดำข้อความ */
    -webkit-user-select: none;
    touch-action: none; /* ป้องกันการ Zoom ด้วยนิ้วบนมือถือ */
}

/* 🚨 คลาสสำหรับซ่อนองค์ประกอบ (สำคัญมาก: แก้บัคจอดำแจ้งเตือนเน็ตหลุดบังแผนที่) 🚨 */
.hidden {
    display: none !important;
}

/* ==========================================================================
   2. 3D GAME CANVAS
   ========================================================================== */
#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1; /* อยู่ชั้นล่างสุด */
}

/* ==========================================================================
   3. HUD OVERLAY SYSTEM (ชั้นวาง UI)
   ========================================================================== */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* ให้คลิกทะลุไปโดน 3D ได้ */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* คลาสช่วยให้ปุ่มต่างๆ ใน UI สามารถถูกคลิกได้ (ไม่ทะลุ) */
.ui-element {
    pointer-events: auto;
    cursor: pointer;
}

/* ==========================================================================
   4. TOP HUD (ข้อมูลผู้เล่น & ทรัพยากร)
   ========================================================================== */
.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 15px;
    width: 100%;
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
}

/* โปรไฟล์ผู้เล่นมุมซ้ายบน */
.top-left-profile {
    display: flex;
    align-items: center;
    background: rgba(20, 25, 30, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 40px;
    padding: 5px 15px 5px 5px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
    transition: transform 0.2s, background 0.2s;
    position: relative;
}
.top-left-profile:hover {
    background: rgba(30, 40, 50, 0.8);
    transform: scale(1.02);
}
.profile-img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid #f1c40f;
    margin-right: 10px;
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.5);
}
.vip-tag {
    background: #f39c12; color: #fff; font-size: 10px; padding: 1px 5px; 
    font-weight: bold; position: absolute; top: -5px; left: -5px; 
    z-index: 11; border: 1px solid #fff; border-radius: 4px;
}

/* แถบทรัพยากรด้านบน */
.top-right-res {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 60%;
}
.stat-badge {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 15px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: bold;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}
.stat-badge i {
    margin-right: 6px;
    font-size: 14px;
}
.res-gem { border-color: #3498db; background: rgba(41, 128, 185, 0.2); }
.res-gem:hover { background: rgba(41, 128, 185, 0.4); }

/* ==========================================================================
   5. MIDDLE HUD (เมนูซ้าย-ขวา)
   ========================================================================== */
.hud-col-left {
    position: absolute; top: 80px; left: 10px; 
    display: flex; flex-direction: column; gap: 20px;
    pointer-events: none; z-index: 15;
}
.left-group { display: flex; flex-direction: column; gap: 15px; pointer-events: auto; }

.hud-col-right {
    position: absolute; top: 70px; right: 10px; 
    display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
    pointer-events: none; z-index: 15;
}
.right-group { display: flex; flex-direction: column; gap: 12px; align-items: flex-end; pointer-events: auto; }

.float-icon-only {
    background: transparent !important; border: none !important; border-radius: 0 !important; box-shadow: none !important;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-size: 32px; position: relative; transition: transform 0.1s; filter: none !important; 
    cursor: pointer;
}
.float-icon-only:active { transform: scale(0.9); }
.float-icon-only i, .btn-vs, .icon-text {
    text-shadow: -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000 !important;
}

.float-label {
    background-color: #ffffff; color: #000000 !important; border: 1px solid #ffffff; border-radius: 4px;
    padding: 2px 6px; font-size: 11px; font-weight: 900; white-space: nowrap; margin-top: 4px;
    text-shadow: none !important; box-shadow: none !important; line-height: 1;
}

.red-dot {
    position: absolute; top: -5px; right: -5px; background: #e74c3c; border: 1px solid #fff; 
    border-radius: 50%; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center;
    color: white; font-size: 9px; font-weight: bold; box-shadow: none;
}
.text-badge {
    position: absolute; top: -10px; right: -15px; background: #3498db; color: #fff; 
    font-size: 9px; padding: 2px 5px; border-radius: 3px; font-weight: bold; border: 1px solid #fff; box-shadow: none;
}
.btn-vs { color: #e74c3c !important; font-weight: 900; font-size: 24px; }

/* ==========================================================================
   6. BOTTOM HUD (เมนูหลักล่าง)
   ========================================================================== */
.fixed-bottom-left {
    position: absolute; bottom: 25px; left: 15px; z-index: 50; pointer-events: auto;
    background: transparent !important; border: none !important; box-shadow: none !important;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #d81b60; font-size: 45px; transition: transform 0.1s; cursor: pointer;
}
.fixed-bottom-left:active { transform: scale(0.95); }
.fixed-bottom-left i { text-shadow: -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000; }
.fixed-bottom-left span {
    background-color: #ffffff; color: #000000 !important; border: 1px solid #ffffff; border-radius: 4px;
    padding: 2px 6px; font-size: 11px; font-weight: 900; white-space: nowrap; margin-top: 4px; line-height: 1;
}

.fixed-bottom-right {
    position: absolute; bottom: 25px; right: 15px; z-index: 50; pointer-events: auto;
    background: transparent !important; border: none !important; box-shadow: none !important;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #f1c40f; font-size: 45px; transition: transform 0.1s; cursor: pointer;
}
.fixed-bottom-right:active { transform: scale(0.95); }
.fixed-bottom-right i { text-shadow: -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000; }
.fixed-bottom-right span {
    background-color: #ffffff; color: #000000 !important; border: 1px solid #ffffff; border-radius: 4px;
    padding: 2px 6px; font-size: 11px; font-weight: 900; white-space: nowrap; margin-top: 4px; line-height: 1;
}

.fixed-bottom-center {
    position: absolute; bottom: 35px; left: 90px; right: 90px; z-index: 45; pointer-events: auto;
}
.chat-bar {
    background: rgba(0,0,0,0.7); border-radius: 4px; padding: 8px 15px;
    color: #fff; font-size: 13px; border: 1px solid #3498db;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}

/* ==========================================================================
   7. MODAL WINDOW SYSTEM (หน้าต่าง Iframe)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    width: 100%;
    height: 100%;
    max-width: 480px;
    background: #1a1a1a;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0,0,0,0.8);
}
.modal-overlay.show .modal-content {
    transform: scale(1);
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 24px;
    cursor: pointer;
    z-index: 1010;
    transition: color 0.2s;
}
.modal-close-btn:hover { color: #e74c3c; }

.modal-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
}

/* ==========================================================================
   8. MISCELLANEOUS (ส่วนตกแต่งเสริม / แจ้งเตือน)
   ========================================================================== */
#zoom-indicator {
    position: absolute;
    bottom: 100px;
    left: 15px;
    background: rgba(0,0,0,0.5);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    color: #aaa;
    pointer-events: none;
    z-index: 5;
    border: 1px solid rgba(255,255,255,0.1);
}

#hover-info {
    position: absolute;
    background: rgba(20, 25, 30, 0.9);
    border: 1px solid #f1c40f;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    display: none;
    z-index: 20;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    transform: translate(-50%, -100%);
    margin-top: -10px;
    white-space: nowrap;
}

.system-msg-alert {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid #2ecc71;
    color: #fff;
    padding: 10px 25px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    z-index: 9999;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.3s, top 0.3s;
    pointer-events: none;
}
.system-msg-alert.show {
    top: 15%;
    opacity: 1;
}

/* ==========================================================================
   9. RESPONSIVE (สำหรับจอมือถือแนวนอน)
   ========================================================================== */
@media (max-width: 900px) and (orientation: landscape) {
    .hud-col-left { top: 60px; flex-direction: row; gap: 15px; }
    .hud-col-right { top: 60px; flex-direction: row; gap: 15px; }
    .float-icon-only { font-size: 24px; }
    .float-label { display: none; }
    .fixed-bottom-left, .fixed-bottom-right { font-size: 35px; bottom: 10px; }
    .fixed-bottom-left span, .fixed-bottom-right span { display: none; }
    .fixed-bottom-center { left: 60px; right: 60px; bottom: 15px; }
    .chat-bar { font-size: 11px; padding: 5px 10px; }
}

/* Squad Widget กลางจอ */
.squad-widget {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 90%; max-width: 320px; background: rgba(236, 240, 241, 0.95); border-radius: 8px;
    padding: 25px 15px 15px 15px; border: 2px solid #bdc3c7;
    display: flex; flex-direction: column; gap: 12px; z-index: 20; pointer-events: auto;
}
.btn-close-widget {
    position: absolute; top: 5px; right: 8px; background: transparent; border: none; color: #888;
    font-size: 18px; cursor: pointer; transition: color 0.2s; padding: 0; outline: none;
}
.btn-close-widget:hover { color: #e74c3c; }
.squad-heroes { display: flex; justify-content: space-between; }
.hero-head { width: 45px; height: 45px; background: #d35400; border-radius: 4px; font-size: 8px; text-align: center; color: #fff; display: flex; flex-direction: column; justify-content: center; border: 2px solid #f1c40f; }
.squad-info-row { display: flex; justify-content: space-between; background: #ccc; padding: 8px; border-radius: 4px; font-size: 12px; color: #333; font-weight: bold; }
.btn-deploy-action { background: #3498db; color: #fff; padding: 10px; border-radius: 4px; font-weight: bold; text-align: center; font-size: 16px; border: 1px solid #2980b9; cursor: pointer; transition: background 0.2s; }
.btn-deploy-action:hover { background: #2980b9; }