/* ===== BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Prompt', sans-serif;
    background: linear-gradient(135deg, #4a8fba 0%, #18548b 50%, #154ada 100%);
    background-attachment: fixed;
    color: #333;
    min-height: 100vh;
    padding: 20px;
}

/* ===== MAIN CONTAINER ===== */
.container {
    max-width: 95%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    margin: 1rem auto;
    padding: 2rem;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

h1 {
    font-size: 1.8rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
    text-align: center;
}

/* ===== LOCATION SELECTOR ===== */
.location-selector {
    background: linear-gradient(135deg, #f8f9ff 0%, #e8ecff 100%);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.15);
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.location-selector h3 {
    margin: 0 0 16px 0;
    color: #4a5568;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.selector-item {
    width: 100%;
}

.selector-item label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px;
    font-weight: 500;
}

.selector-item select {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1.1rem;
    font-family: 'Prompt', sans-serif;
    background: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
}

.selector-item select:hover {
    border-color: #667eea;
}

.selector-item select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
}

.current-location {
    text-align: center;
    padding: 14px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    margin-top: 16px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.current-location span {
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
}

/* ===== AIR QUALITY DISPLAY ===== */
.air-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding: 20px 0;
}

.air-today {
    text-align: center;
    width: 100%;
}

.air-today h2 {
    color: #4a5568;
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.circle-today {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 20px auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.circle-today:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
}

.circle-today .pm-value {
    font-size: 3rem !important;
    font-weight: bold;
    color: #000;
}

.circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
}

.circle:hover {
    transform: scale(1.08);
}

.air-hours {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
}

/* ===== AQI COLORS ===== */
.blue { background: linear-gradient(135deg, #4FC3F7, #29B6F6); }
.green { background: linear-gradient(135deg, #81C784, #66BB6A); }
.yellow { background: linear-gradient(135deg, #FFD54F, #FFCA28); }
.orange { background: linear-gradient(135deg, #FFB74D, #FF9800); }
.red { background: linear-gradient(135deg, #E57373, #EF5350); }





/* ===== AQI SCALE BAR ===== */
.aqi-section {
    margin-top: 30px;
}

.aqi-scale {
    display: flex;
    height: 50px;
    border-radius: 25px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.aqi-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.aqi-bar:hover {
    transform: scaleY(1.1);
}

.aqi-bar-1 { background: linear-gradient(180deg, #4FC3F7, #29B6F6); color: #041175;}
.aqi-bar-2 { background: linear-gradient(180deg, #81C784, #66BB6A); color: #02340b;}
.aqi-bar-3 { background: linear-gradient(180deg, #FFD54F, #FFCA28); color: #604f0a; }
.aqi-bar-4 { background: linear-gradient(180deg, #FFB74D, #FF9800); color: #7b3e05;}
.aqi-bar-5 { background: linear-gradient(180deg, #E57373, #EF5350); color: #3c1717;}

/* ===== MODAL POPUP ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal {
    background: #fff;
    padding: 2.5rem;
    border-radius: 24px;
    width: 90%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.4s ease;
}

.modal.closing {
    animation: slideOut 0.3s ease;
}

.circlepopup {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 1rem;
    font-weight: bold;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
}

.modal h2 {
    margin: 1rem 0;
    color: #333;
    font-size: 1.4rem;
}

.modal p {
    color: #555;
    line-height: 1.7;
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.close-btn {
    padding: 12px 40px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-size: 1.1rem;
    font-family: 'Prompt', sans-serif;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.close-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

/* ===== TOGGLE BUTTON ===== */
.toggle-table-btn {
    display: block;
    margin: 30px auto;
    padding: 14px 35px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    font-family: 'Prompt', sans-serif;
}

.toggle-table-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.5);
}

/* ===== TABLE ===== */
.table-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease;
}

.table-container.active {
    max-height: 2000px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

th {
    background: linear-gradient(135deg, #a9b7f5, #ccabec);
    color: #0b0b0b;
    padding: 15px 10px;
    font-size: 1rem;
    font-weight: 600;
}

td {
    padding: 14px 10px;
    font-size: 0.95rem;
    border-bottom: 1px solid #4d4b4b;
    background: #fff;
    text-align: center;
}

tr:hover td {
    background: #f8f9ff;
}



/* ===== LOADING & ERROR ===== */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: #667eea;
    font-size: 1.1rem;
    
}

.error {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #b91c1c;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    margin: 20px 0;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(30px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.9) translateY(-30px);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 1.5rem;
        border-radius: 20px;
    }

    h1 {
        font-size: 1.4rem;
    }

    .circle-today {
        width: 160px;
        height: 160px;
    }

    .circle-today .pm-value {
        font-size: 2.5rem !important;
    }

    .air-hours {
        gap: 15px;
    }

    .circle {
        width: 100px;
        height: 100px;
        font-size: 0.75rem;
    }

    .modal {
        padding: 1.5rem;
        margin: 15px;
    }

    .aqi-bar {
        font-size: 0.65rem;
    }

    th, td {
        padding: 10px 6px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .selector-item select {
        padding: 12px 14px;
        font-size: 1rem;
    }

    .circle-today {
        width: 140px;
        height: 140px;
    }

    .aqi-scale {
        height: 45px;
    }
}

/* chart*/
 .chart-container {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 20px;
            padding: 25px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
        }
        
        .chart-title {
            font-size: 1.1rem;
            margin-bottom: 20px;
            color: rgba(27, 27, 27, 0.9);
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .chart-title::before {
            content: "📊";
        }


/* chart*/
.button-container {
    display: flex; /* จัดเรียงปุ่มให้อยู่ในแนวนอน */
    gap: 15px; /* กําหนดระยะห่างระหว่างปุ่ม */
    justify-content: center; /* จัดให้อยู่ตรงกลางหน้า (ถ้าต้องการ) */
    padding: 20px;
}


        .main-content {
            display: flex;
            gap: 20px; /* ระยะห่างระหว่าง 2 กล่อง */
            flex-wrap: wrap;
        }

        /* Card Styles */
        .card {
            background-color: white;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
            padding: 10px;
            width: 100%;
            max-width: 1500px; /* กำหนดความกว้างสูงสุดของแต่ละ Card */
            flex: 1; /* ให้ขยายเท่าๆ กัน */
            min-width: 300px;
        }
        
        .card-header {
            font-size: 1.25rem;
            font-weight: 600;
            color: #343a40;
            margin-bottom: 5px;
        }

        .card-location {
            color: #6c757d;
            font-size: 0.9rem;
            margin-bottom: 20px;
        }

        /* PM2.5 Value Area */
        .value-area {
            display: flex;
            justify-content: space-between;
            align-items: flex-end;
            margin-top: 15px;
            border-radius: 8px;
            padding: 20px;
        }
        
        /* สถานีดินแดง (สีฟ้าอ่อน / ปานกลาง) */
        .dindaeng .value-area {
            background-color: #e6f7ff; /* สีฟ้าอ่อนกว่า */
        }
        
        .dindaeng .pm-value {
            color: #007bff; /* สีฟ้า */
        }

        /* สถานีบางนา (สีส้ม / มีผลต่อสุขภาพ) */
        .bangna .value-area {
            background-color: #fff9e6; /* สีเหลือง/ส้มอ่อนกว่า */
        }

        .bangna .pm-value {
            color: #ff9800; /* สีส้ม */
        }

        .pm-value {
            font-size: 3rem;
            font-weight: 700;
            display: flex;
            align-items: flex-start;
        }

        .pm-value span {
            font-size: 1.5rem;
            font-weight: 400;
            align-self: flex-start;
            margin-top: 8px;
            margin-left: 5px;
        }

        .status-text {
            color: #6c757d;
            font-weight: 600;
            font-size: 1rem;
            text-align: right;
            line-height: 1.4;
        }
        
        .bangna .status-text {
            color: #ff9800;
            display: flex;
            align-items: center;
            font-size: 0.95rem;
            font-weight: 700;
        }

        .status-text .arrow-icon {
            margin-right: 5px;
            font-size: 1.2rem;
        }

        /* Forecast Section */
        .forecast-header {
            margin-top: 30px;
            margin-bottom: 15px;
            font-weight: 600;
            color: #343a40;
            font-size: 1rem;
            display: flex;
            align-items: center;
        }

        .forecast-header .info-icon {
            margin-right: 5px;
            color: #007bff; /* ใช้สีเดียวกับสถานีดินแดง เพื่อความเป็นกลาง */
        }

        /* Graph Placeholder */
        .graph-placeholder {
            width: 100%;
            height: 200px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #6c757d;
            font-size: 0.9rem;
            position: relative;
        }
        
        /* จำลองเส้นกราฟด้วยสี */
        .dindaeng .graph-placeholder {
            border: 1px solid #007bff;
            background: repeating-linear-gradient(
                45deg,
                #e6f7ff,
                #e6f7ff 10px,
                #d0eeff 10px,
                #d0eeff 20px
            ); /* จำลองลายของกราฟสีฟ้า */
        }

        .bangna .graph-placeholder {
            border: 1px solid #ff9800;
            background: repeating-linear-gradient(
                45deg,
                #fff9e6,
                #fff9e6 10px,
                #ffecb3 10px,
                #ffecb3 20px
            ); /* จำลองลายของกราฟสีส้ม */
        }
        
        /* สำหรับหน้าจอขนาดเล็ก */
        @media (max-width: 1000px) {
            .main-content {
                flex-direction: column;
                align-items: center;
            }
            .card {
                max-width: 100%;
            }
        }