@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600&display=swap');

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-sub: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --sidebar-w: 260px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Kanit', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
}

/* บังคับฟอนต์ */
input,
select,
button,
textarea {
    font-family: 'Kanit', sans-serif;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.logo {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 40px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo span {
    color: var(--primary);
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.menu-item {
    text-decoration: none;
    color: var(--text-sub);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 16px;
    transition: 0.3s;
    display: flex;
    align-items: center;
}

.menu-item {
    background-color: #eff6ff;
    color: rgb(60, 73, 109);
    font-weight: 500;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.menu-item:hover {
    transform: translateY(5px);
    background-color: #ffffff;
    color: #03040c;
}



.menu-item.active {
    background: linear-gradient(135deg, #7d8aff, #244bfa);
    border-bottom: #0000004f 2px solid;
    /* ฟ้าเข้ม gradient */
    color: white;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);

}

.menu-item.active:hover {
    background-color: #d9e3f0;
    color: #171e52;
}

/* Content */
.main-content {
    margin-left: var(--sidebar-w);
    width: 100%;
    padding: 30px;
}

.header-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

/* Inputs & Buttons */
input,
select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    background-color: #fff;
    transition: 0.2s;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

button {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: 0.2s;
}

button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

button.btn-danger {
    background-color: #fee2e2;
    color: var(--danger);
}

button.btn-danger:hover {
    background-color: #fecaca;
    transform: translateY(0);
}

/* 🔥 Custom Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-box {
    background: white;
    padding: 30px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.2s;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-overlay.show .modal-box {
    transform: scale(1);
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 10px;
}

.modal-text {
    color: var(--text-sub);
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-secondary {
    background-color: #e2e8f0;
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: #cbd5e1;
}

/* Mobile */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-direction: row;
        justify-content: space-between;
        padding: 15px 20px;
    }

    .logo {
        margin-bottom: 0;
        font-size: 18px;
    }

    .menu {
        flex-direction: row;
        gap: 5px;
    }

    .menu-item {
        padding: 8px 12px;
        font-size: 14px;
        white-space: nowrap;
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }
}


/* CSS สำหรับ Login ที่เพิ่มเข้ามา */

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f8fafc;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h2 {
    margin-bottom: 25px;
    color: #1e293b;
}

.login-card input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-sizing: border-box;
}

.login-card button {
    width: 100%;
    padding: 12px;
    background-color: #0077ff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.login-card button:hover {
    background-color: #1358c0;
}

.error-message {
    color: #ef4444;
    margin-top: 15px;
    display: none;
    font-size: 0.9rem;
}

/* ซ่อน Sidebar และปรับ Layout หลัก */
.sidebar {
    display: none;
}

.main-content {
    margin-left: 0 !important;
    width: 100% !important;
}

/* ----------------------------------- */
/* CSS สำหรับ Progress Bar (Google Style) */
/* ----------------------------------- */
.progress-bar-container {
    width: 100%;
    height: 4px;
    background-color: #e0e0e0;
    overflow: hidden;
    border-radius: 2px;
    margin-bottom: 20px;
    margin-top: -10px;
    /* 💡 [สำคัญ] ต้องมี position: relative เพื่อให้แถบวิ่งภายในได้ */
    position: relative;
}

.progress-bar-indicator {
    height: 100%;
    background-color: #0063e6;
    animation: indeterminate-bar 1.6s infinite cubic-bezier(0.8, 0.3, 0.2, 0.7);
    /* 💡 [สำคัญ] ต้องมี position: absolute เพื่อให้ใช้ left/right ใน Keyframes ได้ */
    position: absolute;
}

/* ⚙️ Keyframes: กำหนดรูปแบบการวิ่ง */
@keyframes indeterminate-bar {
    0% {
        /* เริ่มต้น: แถบจะอยู่ทางซ้ายสุดและสั้น */
        left: -35%;
        right: 100%;
    }

    60% {
        /* จุดที่แถบยืดออกจนสุดและเคลื่อนที่ไปทางขวา */
        left: -90%;
        right: -20%;
    }

    100% {
        /* สิ้นสุด: แถบหดกลับไปทางซ้ายสุดเพื่อเริ่มใหม่อีกครั้ง */
        left: 100%;
        right: -35%;
    }
}
