/* =======================================================
   บังคับใช้เฉพาะจอ Tablet / iPad / Nest Hub (768px - 1199px)
   ======================================================= */

@media only screen and (min-width: 768px) and (max-width: 1199px) {

    /* 1. ปลดล็อคการเลื่อนหน้าจอสำหรับ Nest Hub และ iPad */
    html, body {
        overflow-y: auto !important;
        height: auto !important;
        min-height: 100dvh !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body {
        /* พื้นที่ว่างด้านล่างกันบาร์ทับเนื้อหา */
        padding-bottom: 120px !important; 
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important; /* 🔥 บังคับให้เนื้อหาทุกอย่างอยู่กึ่งกลางหน้าจอ */
    }

    /* 2. 🔥 แก้ปัญหาการ์ดเอียงซ้าย: จัดกลุ่มสถานีให้อยู่กึ่งกลาง */
    .dashboard-container {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important; /* จัดกึ่งกลางการ์ดในแนวตั้ง */
        width: 100% !important;
        max-width: 900px !important; /* คุมความกว้างไม่ให้แผ่จนเกินไปบน iPad Pro */
        margin: 0 auto !important;
        gap: 30px !important;
    }

    .station-group {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important; /* จัดหัวข้อสถานีให้อยู่กลาง */
    }

    /* จัดระเบียบการ์ด PM ภายในให้เรียงสวยและอยู่กลาง */
    .station-card-container {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important; /* 🔥 บังคับให้การ์ด PM1, PM2.5, PM10 อยู่กลางจอ */
        gap: 15px !important;
        width: 100% !important;
    }

    /* 3. แก้ไข Tab Bar ให้กึ่งกลางเป๊ะ (Capsule Style) */
    .tab-bar {
        position: fixed !important;
        bottom: 25px !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important; /* จัดกลางเป๊ะด้วยสูตรมาตรฐาน */
        
        width: auto !important;
        min-width: 450px !important; /* ป้องกันปุ่มเบียดกันจนตัวหนังสือขาด */
        max-width: 95% !important;
        height: 70px !important;
        
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 10px !important;
        padding: 0 20px !important;

        /* สีโหมดปกติ */
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(15px);
        border-radius: 100px !important;
        box-shadow: 0 10px 40px rgba(0,0,0,0.15) !important;
        border: 1px solid rgba(0,0,0,0.05) !important;
        z-index: 999999 !important;
    }

    .tab-btn {
        flex: 0 0 auto !important;
        min-width: 130px !important;
        height: 50px !important;
        font-size: 1.1rem !important;
        white-space: nowrap !important;
        border-radius: 50px !important;
    }

    /* =======================================================
       🌑 4. DARK MODE สำหรับ Tab Bar
       ======================================================= */
    [data-theme="dark"] .tab-bar {
        background: rgba(30, 41, 59, 0.92) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
    }

    [data-theme="dark"] .tab-btn {
        color: #f1f5f9 !important;
    }

    [data-theme="dark"] .tab-btn.active {
        background: rgba(255, 255, 255, 0.15) !important;
    }
}