@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600&display=swap');

:root {
    /* โทนสีเริ่มต้นแบบมินิมอลพาสเทล (ปรับจาก API ได้) */
    --primary-color: #7BA79D; 
    --secondary-color: #F4F1DE; 
    --bg-color: #FAFAFA; 
    --text-color: #333333;
    --card-bg: #FFFFFF;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Sarabun', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease;
}

/* ปุ่มมุมขวาบน */
.admin-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,0.9);
    padding: 10px 18px;
    border-radius: 30px;
    text-decoration: none;
    color: #555;
    font-size: 14px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    transition: 0.3s;
    z-index: 10;
}
.admin-btn:hover {
    background: #fff;
    color: var(--primary-color);
    transform: translateY(-2px);
}

/* ส่วนหัว */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 50px 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

#header-text {
    font-weight: 500;
    font-size: 26px;
    max-width: 900px;
    margin: 0 auto;
    line-height: 1.4;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.1);
}

/* พื้นที่คอนเทนต์ */
.container {
    max-width: 1100px;
    margin: 50px auto;
    padding: 0 20px;
}

.section-title {
    text-align: center;
    margin-bottom: 40px;
    font-weight: 500;
    color: #555;
}

/* ตารางเจ้าหน้าที่ */
.staff-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 30px;
}

.staff-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 30px 20px;
    text-align: center;
    box-shadow: 0 10px 20px rgba(0,0,0,0.03);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #f0f0f0;
}

.staff-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.08);
    border-color: var(--primary-color);
}

.staff-img {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 20px;
    border: 4px solid var(--secondary-color);
}

.staff-name {
    font-size: 19px;
    font-weight: 600;
    margin-bottom: 8px;
}

.staff-position {
    font-size: 15px;
    color: #888;
}

/* Modal / Popup */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #fff;
    padding: 40px;
    border-radius: 24px;
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

.close-btn {
    position: absolute;
    top: 20px; right: 25px;
    font-size: 28px;
    cursor: pointer;
    color: #bbb;
    transition: 0.2s;
}
.close-btn:hover { color: #333; }

.subtitle {
    color: #777;
    font-size: 15px;
    margin-top: 5px;
    margin-bottom: 20px;
    text-align: center;
}

/* ปุ่มเลือกรูปแบบ */
.btn-group {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.btn {
    flex: 1;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    transition: 0.3s;
    font-weight: 600;
}

.btn-quick {
    background: var(--primary-color);
    color: white;
}
.btn-quick:hover { filter: brightness(1.1); }

.btn-detail {
    background: var(--secondary-color);
    color: #444;
}
.btn-detail:hover { background: #e8e5d1; }

/* ปุ่มให้คะแนน (ด่วน) */
.rating-group {
    display: flex;
    justify-content: space-between;
    margin-top: 25px;
    gap: 10px;
}

.rate-btn {
    flex: 1;
    padding: 18px 5px;
    border: 2px solid var(--primary-color);
    background: transparent;
    color: var(--primary-color);
    border-radius: 12px;
    cursor: pointer;
    font-size: 26px;
    font-weight: bold;
    transition: all 0.2s;
}
.rate-btn span {
    font-size: 13px;
    font-weight: normal;
    display: block;
    margin-top: 6px;
}
.rate-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

/* ฟอร์มประเมินละเอียด */
.question {
    margin-bottom: 25px;
    text-align: left;
    background: #fafafa;
    padding: 15px;
    border-radius: 12px;
}
.question label {
    display: block;
    margin-bottom: 15px;
    font-weight: 500;
    color: #444;
}

.rating-radio {
    display: flex;
    gap: 10px;
}
.radio-label {
    flex: 1;
    text-align: center;
    padding: 12px 5px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 16px;
    font-weight: 500;
}
.radio-label input { display: none; }
.radio-label:has(input:checked) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 12px;
    resize: vertical;
    font-size: 15px;
}
textarea:focus { outline: none; border-color: var(--primary-color); }

.btn-submit {
    width: 100%;
    background: var(--primary-color);
    color: white;
    margin-top: 20px;
    padding: 18px;
    font-size: 18px;
}

/* Loading Spinner */
.loader { text-align: center; color: #888; font-size: 16px; grid-column: 1 / -1; }
.spinner {
    border: 4px solid rgba(0,0,0,0.05);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border-left-color: var(--primary-color);
    animation: spin 1s linear infinite;
    margin: 0 auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* =========================================
   ส่วนตกแต่งสำหรับหน้า Admin (ผู้ดูแลระบบ)
   ========================================= */

/* โครงสร้างหลักของ Admin */
.admin-page {
    background-color: #f4f6f9;
    margin: 0;
    height: 100vh;
    overflow: hidden;
}

/* Modal Overlay สำหรับ Login และ ลืมรหัสผ่าน */
.modal-overlay {
    display: none; /* ซ่อนไว้เป็นค่าเริ่มต้น */
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active {
    display: flex; /* แสดงเมื่อมีคลาส active */
}

.login-box, .prompt-box, .form-modal {
    background: #fff;
    padding: 40px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    text-align: center;
    position: relative;
}
.form-modal { max-width: 500px; text-align: left; }
.login-box h3, .prompt-box h4 { margin-bottom: 20px; color: #333; }

/* Input Styles */
.input-group {
    margin-bottom: 20px;
    text-align: left;
}
.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
    font-size: 14px;
}
.input-group input, .input-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    transition: border 0.3s;
}
.input-group input:focus, .input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ลิงก์ลืมรหัสผ่าน */
.forgot-link {
    display: block;
    margin-top: 15px;
    color: #666;
    font-size: 14px;
    text-decoration: none;
}
.forgot-link:hover { color: var(--primary-color); text-decoration: underline; }

/* เค้าโครง Dashboard */
.admin-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar (เมนูด้านข้าง) */
.sidebar {
    width: 260px;
    background: #fff;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    z-index: 100;
}
.sidebar-header {
    padding: 30px 20px;
    border-bottom: 1px solid #f0f0f0;
}
.sidebar-header a {
    text-decoration: none;
    color: #555;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-nav { padding: 20px 0; }
.sidebar-nav ul { list-style: none; }
.sidebar-nav li {
    padding: 15px 25px;
    color: #666;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: 0.2s;
}
.sidebar-nav li:hover, .sidebar-nav li.active {
    background: var(--secondary-color);
    color: var(--primary-color);
    border-right: 4px solid var(--primary-color);
}

/* พื้นที่เนื้อหาหลัก */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    position: relative;
}
.content-header h2 {
    font-size: 22px;
    color: #333;
    margin-bottom: 30px;
}

/* Cards & Stats */
.card {
    background: #fff;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    margin-bottom: 30px;
}
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}
.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 30px;
}
.stat-card i {
    font-size: 40px;
    color: var(--primary-color);
    opacity: 0.8;
}
.stat-card.primary { background: var(--primary-color); color: white; }
.stat-card.primary i { color: white; }
.stat-info h4 { font-size: 32px; margin-bottom: 5px; }
.stat-info p { font-size: 14px; opacity: 0.9; }

/* กรองวันที่ */
.section-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.date-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    padding: 10px 15px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.date-filter input {
    border: 1px solid #ddd;
    padding: 6px 10px;
    border-radius: 6px;
    font-family: inherit;
}

/* ตารางข้อมูล */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th, .data-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}
.data-table th {
    font-weight: 600;
    color: #555;
    background: #fafafa;
}
.data-table tbody tr:hover { background: #f9f9f9; }
.table-staff-img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.status-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.status-open { background: #e6f4ea; color: #1e8e3e; }
.status-closed { background: #fce8e6; color: #d93025; }

/* ปุ่มต่างๆใน Admin */
.btn-primary { background: var(--primary-color); color: white; width: 100%; padding: 12px; }
.btn-primary:hover { filter: brightness(0.9); }
.btn-secondary { background: #eee; color: #444; width: 100%; padding: 12px; }
.btn-small { width: auto; padding: 8px 16px; border-radius: 6px; }
.btn-icon {
    width: 35px; height: 35px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px; margin-right: 5px; background: #f4f4f4; color: #555;
}
.btn-icon.btn-edit:hover { background: #e3f2fd; color: #1976d2; }
.btn-icon.btn-delete:hover { background: #fce8e6; color: #d93025; }
.modal-actions { display: flex; gap: 15px; margin-top: 30px; }

/* หน้าตั้งค่า (Settings) */
.settings-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}
.settings-card h4 { margin-bottom: 20px; border-bottom: 2px solid #f0f0f0; padding-bottom: 15px; }
.color-groups { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 15px; }
.color-picker-input { display: flex; align-items: center; gap: 10px; }
.color-picker-input input[type="color"] {
    width: 40px; height: 40px; padding: 0; border: none; border-radius: 8px; cursor: pointer;
}
.color-picker-input input[type="text"] { flex: 1; text-transform: uppercase; }

/* Chart (คะแนนเฉลี่ยรายข้อ) */
.chart-container { margin-top: 20px; background: #fff; padding: 30px; border-radius: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); }
.chart-bar { display: flex; align-items: center; margin-bottom: 15px; gap: 15px; }
.q-label { width: 60px; font-weight: 500; font-size: 14px; }
.bar-fill {
    flex: 1; height: 12px; background: #eee; border-radius: 10px; position: relative; overflow: hidden;
}
.bar-fill::after {
    content: ''; position: absolute; top: 0; left: 0; height: 100%;
    width: var(--width); background: var(--primary-color); border-radius: 10px; transition: width 1s ease;
}
.q-score { width: 40px; text-align: right; font-weight: bold; color: var(--primary-color); }

/* Loader */
.loader-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,0.8); z-index: 500;
    display: none; flex-direction: column; align-items: center; justify-content: center;
}
.loader-overlay.active { display: flex; }
.error-msg { color: #d93025; background: #fce8e6; padding: 10px; border-radius: 8px; margin-top: 15px; font-size: 14px; }
.info-msg { padding: 10px; border-radius: 8px; margin-top: 15px; font-size: 14px; }
.info-msg.success { color: #1e8e3e; background: #e6f4ea; }