/* --- Core & Common Styles --- */
:root {
    --primary-navy: #001f3f; /* Navy Blue - สีหลัก */
    --accent-teal: #39cccc;   /* Teal - สีเน้น/ปุ่ม */
    --dark-teal: #258585;     /* Teal เข้มสำหรับ Hover */
    --white: #ffffff;         /* สีพื้นหลัง/ตัวอักษร */
    --light-gray: #f4f4f4;    /* สีพื้นหลังรอง */
    --text-color: #333333;
    --danger-red: #ff4136;
    --warning-orange: #ff851b;
    --success-green: #2ecc40;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

body {
    font-family: 'Sarabun', sans-serif;
    background-color: var(--light-gray);
    color: var(--text-color);
    line-height: 1.7;
    animation: fadeIn 0.8s ease-in-out;
    font-size: 17px; /* เพิ่มขนาดฟอนต์พื้นฐานเพื่อให้อ่านง่ายขึ้น */
}

/* --- Header & Navigation --- */
header {
    background-color: var(--primary-navy);
    color: var(--white);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: none;
    transition: box-shadow 0.3s ease;
}

header.scrolled {
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.top-bar {
    background-color: #001226; /* Darker Navy */
    padding: 5px 5%;
    font-size: 0.85rem;
    text-align: right;
    color: var(--accent-teal);
}

.nav-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 10px 5%;
    position: relative;
    min-height: 90px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--white);
    font-weight: 600;
    font-size: 1.5rem;
    position: absolute;
    top: 0;
    left: 5%;
    z-index: 1002;
}

.logo img {
    height: 150px;
    width: 150px;
    object-fit: contain;
    transition: transform 0.3s;
}

.logo img:hover {
    transform: scale(1.1);
}

/* เมนูหลัก */
.main-menu {
    display: flex;
    list-style: none;
    gap: 20px;
}

.main-menu li a {
    color: var(--white);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.3s;
    padding-bottom: 5px;
}

.main-menu li {
    position: relative; /* Needed for submenu positioning */
}

.submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--primary-navy);
    list-style: none;
    padding: 10px 0;
    border-radius: 0 0 5px 5px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    min-width: 200px; /* Set a minimum width */
    z-index: 1001;
}

.main-menu li:hover > .submenu {
    display: block;
}

.submenu li {
    width: 100%;
}

.submenu li a {
    padding: 10px 20px;
    display: block;
    white-space: nowrap; /* Prevent text wrapping */
}

.submenu li a:hover {
    background-color: var(--dark-teal);
    border-bottom: none !important; /* Override main menu hover effect */
}

.main-menu li a:hover {
    color: var(--accent-teal);
    border-bottom: 2px solid var(--accent-teal);
}

.main-menu li a.active {
    color: var(--accent-teal);
    border-bottom: 2px solid var(--accent-teal);
}

/* ปุ่มแจ้งเหตุฉุกเฉิน (เด่นพิเศษ) */
.btn-emergency {
    background-color: #ff4136; /* สีแดงสำหรับเหตุฉุกเฉิน */
    color: white !important;
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: bold;
    border: none;
}

.btn-emergency:hover {
    background-color: #d63025;
    border-bottom: none !important;
}

/* Add dropdown arrow */
.has-submenu > a::after {
    content: ' ▾';
    font-size: 0.8em;
}

/* Hamburger menu button (hidden on desktop) */
.hamburger-menu {
    display: none;
}

/* --- Footer --- */
footer {
    background-color: var(--primary-navy);
    color: var(--white);
    padding: 40px 5%;
    text-align: center;
    border-top: 5px solid var(--accent-teal);
}

footer p {
    opacity: 0.8;
    font-size: 0.9rem;
}

/* --- Common Page Styles --- */
.container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.page-header h1 {
    color: var(--primary-navy);
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.page-header p {
    color: #666;
    font-size: 1.1rem;
}

/* --- Modal Styles --- */
.modal {
    display: none; 
    position: fixed; 
    z-index: 2000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.5); 
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: var(--white);
    margin: 10% auto; 
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    animation: slideIn 0.3s;
}

@keyframes slideIn { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: var(--primary-navy);
}

/* Responsive Menu for Mobile */
@media (max-width: 1024px) {
    .nav-container {
        justify-content: space-between;
        min-height: 90px;
        padding: 5px 5%;
    }

    .logo {
        position: static;
    }

    .logo img {
        height: 80px;
        width: 80px;
    }

    .hamburger-menu {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 30px;
        height: 22px;
        background: none;
        border: none;
        cursor: pointer;
        z-index: 1002;
        padding: 0;
    }

    .hamburger-menu .bar {
        width: 100%;
        height: 3px;
        background-color: var(--white);
        border-radius: 3px;
        transition: all 0.3s ease-in-out;
        transform-origin: center;
    }

    .hamburger-menu.active .bar:nth-child(1) {
        transform: translateY(9.5px) rotate(45deg);
    }

    .hamburger-menu.active .bar:nth-child(2) {
        opacity: 0;
        transform: translateX(20px);
    }

    .hamburger-menu.active .bar:nth-child(3) {
        transform: translateY(-9.5px) rotate(-45deg);
    }

    .main-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        max-width: 320px;
        height: 100vh;
        background-color: var(--primary-navy);
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        padding: 80px 30px 30px;
        gap: 15px;
        transition: right 0.3s ease-in-out;
        box-shadow: -5px 0 15px rgba(0,0,0,0.2);
        overflow-y: auto;
    }

    .main-menu.show-menu {
        right: 0;
    }

    .main-menu li {
        width: 100%;
    }

    .main-menu li a {
        font-size: 1.1rem;
        padding: 10px 5px;
        width: 100%;
        display: block;
    }

    .main-menu li:hover > .submenu {
        display: none; /* Disable hover on mobile */
    }

    .main-menu li.submenu-open > .submenu {
        display: block; /* Show on click/tap */
    }

    /* Rotate arrow when submenu is open */
    .main-menu li.submenu-open > a::after {
        display: inline-block;
        transform: rotate(180deg);
    }

    .submenu {
        position: static;
        background-color: transparent;
        box-shadow: none;
        padding: 10px 0 0 20px;
        border-radius: 0;
        min-width: auto;
    }
}

/* Scroll to Top Button */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 10px;
    background-color: var(--accent-teal);
    color: var(--primary-navy);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: transform 0.3s, background-color 0.3s;
}

.scroll-to-top.show {
    display: flex;
    animation: fadeIn 0.3s;
}

.scroll-to-top:hover {
    transform: translateY(-5px);
    background-color: var(--warning-orange);
}