:root {
    --header-height: 60px;
    --primary-color: #004d40;
    --secondary-color: #00796b;
}

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden; /* For desktop */
    font-family: 'Kanit', sans-serif;
    background-color: #f0f2f5;
}

header {
    height: var(--header-height);
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 25px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 500;
}

.main-container {
    display: flex;
    height: calc(100vh - var(--header-height) - 40px);
    width: calc(100% - 40px);
    background-color: #ffffff;
    margin: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

#content-area {
    width: 70%;
    position: relative;

    overflow: hidden;
}

#sidebar {
    width: 30%;
    min-width: 300px;
    background-color: #f8f9fa;
    border-left: 1px solid #e9ecef;
    padding: 25px;
    box-sizing: border-box;
    overflow-y: auto;
}

#map-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;  /* กำหนดขนาดให้เต็มเหมือนเดิม */
    height: 100%;

    /* สองบรรทัดนี้ยังต้องมีอยู่ เพื่อจัดตัว SVG ข้างในอีกที */
    display: flex;
    justify-content: center;
    align-items: center;
}
#thailand-map {
    width: 80%;
    height: 80%;
    max-height: 95%;
    max-width: 95%;
    cursor: grab;

    /* --- เพิ่มบรรทัดนี้เพื่อสร้างเงา 3 มิติ --- */
    filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 1));
}

#thailand-map:active {
    cursor: grabbing;
}

#info-panel.hidden {
    display: none;
}

#thailand-map path { fill: #d4d4d4; stroke: #ffffff; stroke-width: 0.8; transition: fill 0.3s ease; }
#thailand-map path:hover { fill: #b0bec5; }
.province-clickable { fill: #a5d6a7 !important; }
.province-clickable:hover { fill: #66bb6a !important; }
.province-selected { fill: #2e7d32 !important; }
#sidebar h2 { margin-top: 0; color: var(--primary-color); border-bottom: 2px solid var(--primary-color); padding-bottom: 10px; }
.image-downloads .image-container { margin-bottom: 20px; text-align: center; border: 1px solid #ddd; border-radius: 8px; padding: 10px; background-color: #ffffff; }
.image-downloads img { max-width: 100%; border-radius: 4px; margin-bottom: 10px; }
.download-btn { display: inline-block; width: calc(100% - 20px); padding: 10px; background-color: var(--secondary-color); color: white; text-decoration: none; border-radius: 5px; text-align: center; font-weight: 500; transition: background-color 0.3s; }
.download-btn:hover { background-color: var(--primary-color); }
#report-wrapper { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(255, 255, 255, 0.98); display: flex; flex-direction: column; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: opacity 0.5s, visibility 0.5s; padding: 20px; box-sizing: border-box; border-radius: 12px; z-index: 20; }
#report-wrapper.visible { opacity: 1; visibility: visible; }
#report-wrapper img { max-width: 90%; max-height: 80%; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); border-radius: 8px; }
.back-to-map-btn { margin-top: 20px; padding: 12px 25px; background-color: #d32f2f; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 1rem; font-family: 'Kanit', sans-serif; transition: background-color 0.3s; }
.back-to-map-btn:hover { background-color: #b71c1c; }


/* ===== RESPONSIVE STYLES FOR MOBILE ===== */
/* This whole section makes the mobile view work correctly */
@media (max-width: 768px) {
    body {
        overflow-y: auto; /* Allow vertical scrolling on mobile */
    }

    .main-container {
        flex-direction: column; /* This is the KEY: stacks items vertically */
        height: auto; 
        margin: 10px;
        width: calc(100% - 20px);
    }

    #content-area {
        width: 100%; /* Make map area full width */
        height: 60vh; /* Give map area a fixed height (60% of screen height) */
    }

    #sidebar {
        width: 100%; /* Make sidebar full width */
        min-width: unset; /* Remove minimum width constraint */
        border-left: none; 
        border-top: 1px solid #e9ecef; /* Add a separator line on top */
    }

    header h1 {
        font-size: 1.2rem;
    }
}

/* ===== Tooltip Styles (กล่องชื่อจังหวัด) ===== */
#map-tooltip {
    position: absolute; /* ทำให้ลอยตามเมาส์ได้ */
    display: none;      /* ซ่อนไว้ในตอนแรก */
    padding: 10px 20px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    pointer-events: none; /* ทำให้เมาส์คลิกทะลุกล่องนี้ไปได้ */
    z-index: 1000;
    overflow: hidden; /* สำคัญสำหรับเอฟเฟกต์ */
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* --- เอฟเฟกต์สายน้ำ (Water Ripple Effect) --- */
#map-tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%, -50%);
    transform-origin: 50% 50%;
    
    /* เรียกใช้ animation ชื่อ 'ripple' */
    animation: ripple 1.5s ease-out infinite;
}

/* สร้าง Keyframes สำหรับ Animation */
@keyframes ripple {
    0% {
        transform: scale(0, 0) translate(-50%, -50%);
        opacity: 1;
    }
    100% {
        transform: scale(20, 20) translate(-50%, -50%);
        opacity: 0;
    }
}
