/* กำหนดตัวแปรสีเพื่อให้แก้ง่าย - THEME: FUTURISTIC DARK */
:root {
    --primary-color: #00c6ff;
    --primary-hover: #00a5d9;
    --holiday-color: #ff4da6;
    --bg-color: #121826;
    --card-bg: #1a2035;
    --text-main: #e0e0e0;
    --text-muted: #8a93a5;
    --border-color: rgba(138, 147, 165, 0.2);
    --glow-shadow: 0 0 15px rgba(0, 198, 255, 0.3);
}

/* ตั้งค่าพื้นฐาน */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    padding: 20px;
}

/* ส่วนหัว */
.header {
    max-width: 920px;
    margin: 0 auto 30px; /* จัดให้อยู่กลางและเพิ่มระยะห่างด้านล่าง */
    text-align: left;
}
.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

/* โครงสร้างหลัก */
.main-container {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 25px;
    max-width: 920px;
    margin: 0 auto;
}

.calendar-area {
    flex: 1;
    min-width: 360px;
}

/* Wrapper ใหม่สำหรับจัดกลางแถบควบคุม */
.calendar-nav-wrapper {
    max-width: 920px;
    margin: 0 auto;
}

/* แถบควบคุมปฏิทิน */
.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px; /* ระยะห่างระหว่างแถบควบคุมกับเนื้อหาหลัก */
}
.nav-btn {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}
.nav-btn:hover {
    background-color: var(--primary-color);
    color: var(--bg-color);
    border-color: var(--primary-color);
    box-shadow: var(--glow-shadow);
}
.month-year-selector {
    display: flex;
    gap: 10px;
}
.month-year-selector select {
    font-size: 1.1rem;
    padding: 5px 10px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    background-color: transparent;
    color: var(--text-main);
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238a93a5' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 35px;
    cursor: pointer;
    transition: color 0.3s;
}
.month-year-selector select:hover {
    color: var(--primary-color);
}

/* ตารางปฏิทิน */
.calendar {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
}
.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}
.days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.days div {
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1 / 1; /* ทำให้เป็นสี่เหลี่ยมจัตุรัส */
    border-radius: 8px;
    transition: all 0.2s ease-in-out;
    cursor: default;
    border: 1px solid transparent;
}
.days div.day:not(:empty) {
    cursor: pointer;
}
.days div.day:not(:empty):hover {
    border-color: var(--primary-color);
    background-color: rgba(0, 198, 255, 0.1);
}
.days div.today {
    background-color: var(--primary-color);
    color: var(--bg-color);
    font-weight: 700;
    box-shadow: var(--glow-shadow);
}
.days div.holiday {
    color: var(--holiday-color);
    font-weight: 700;
    position: relative;
}
/* เพิ่มจุดใต้เลขที่เป็นวันหยุด */
.days div.holiday::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--holiday-color);
    box-shadow: 0 0 5px var(--holiday-color);
}

/* --- ส่วนแสดงรายการวันหยุด (ด้านขวา) --- */
.holidays-list-area {
    width: 280px;
    flex-shrink: 0;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    max-height: 465px; /* เพิ่ม max-height */
    overflow-y: auto; /* เพิ่ม scrollbar เมื่อเนื้อหาล้น */
}
/* Custom scrollbar */
.holidays-list-area::-webkit-scrollbar {
    width: 6px;
}
.holidays-list-area::-webkit-scrollbar-track {
    background: transparent;
}
.holidays-list-area::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}
.holidays-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}
.holidays-header h3 {
    font-size: 1.1rem;
    color: var(--text-main);
    margin: 0;
}
.view-year-btn {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
}
.view-year-btn:hover {
    background: var(--primary-color);
    color: var(--bg-color);
    box-shadow: var(--glow-shadow);
}
.holidays-list-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.event-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: transparent;
    transition: all 0.2s ease;
}
.event-card:hover {
    border-color: var(--primary-color);
    background-color: rgba(0, 198, 255, 0.05);
}
.event-date {
    flex-shrink: 0;
    width: 45px;
    height: 45px;
    text-align: center;
    background-color: var(--bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: all 0.2s ease;
}
.event-card:hover .event-date {
    border-color: var(--primary-color);
}
.event-month {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    line-height: 1;
}
.event-day {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.2;
}
.event-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
}
.holidays-list-content:empty::after {
    content: 'ไม่มีวันหยุดในเดือนนี้';
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 40px 0;
}

/* Responsive Design for Mobile */
@media (max-width: 768px) {
    .calendar-area {
        min-width: 100%;
    }
    .holidays-list-area {
        width: 100%;
    }
}

/* Modal Styles */
.modal {
    display: none; position: fixed; z-index: 1000; left: 0; top: 0;
    width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 30px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    max-height: 85vh; /* จำกัดความสูงไม่ให้ล้นจอ */
    display: flex;
    flex-direction: column;
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-shrink: 0; }
.modal-header h2 { font-size: 1.4rem; color: var(--text-main); margin: 0; }
.close-btn { color: var(--text-muted); font-size: 28px; font-weight: bold; cursor: pointer; transition: color 0.2s; }
.close-btn:hover { color: var(--primary-color); }

.modal-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}
.btn-export {
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: white;
    transition: transform 0.2s;
}
.btn-export:hover { transform: translateY(-2px); }
.btn-export.excel { background-color: #217346; } /* Excel Green */

.year-holidays-list {
    overflow-y: auto;
    padding-right: 5px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
/* Scrollbar for modal list */
.year-holidays-list::-webkit-scrollbar { width: 6px; }
.year-holidays-list::-webkit-scrollbar-track { background: transparent; }
.year-holidays-list::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }