/* =========================================
   1. นำเข้าฟอนต์ Google Fonts (Noto Sans Thai)
========================================= */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@300;400;500;600;700&display=swap');

/* =========================================
   2. กำหนดตัวแปรสี (Color Palette)
========================================= */
:root {
    --color-wine: #930400;      
    --color-milk: #fff7e6;      
    --color-heavenly: #95baeb;  
    --color-white: #ffffff;
    --text-main: #1e293b;       
    --text-muted: #64748b;      
    --border-light: rgba(0, 0, 0, 0.08); 
}

/* =========================================
   3. โครงสร้างหลัก (Layout)
========================================= */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: 'Noto Sans Thai', sans-serif; 
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--color-milk);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

/* =========================================
   4. หน้า Login (เฉพาะหน้า login.php)
========================================= */
.login-body {
    background: #FDFBF7;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.login-box {
    background: #fff;
    width: 100%;
    max-width: 400px;
    padding: 40px 32px;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,.08);
}
.login-logo {
    text-align: center;
    margin-bottom: 28px;
    color: #722F37; /* สีแดงเข้มเฉพาะหน้า Login */
    font-size: 26px;
    font-weight: 700;
}
.btn-login {
    width: 100%;
    padding: 13px;
    margin-top: 8px;
    background: #722F37;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity .2s;
}
.btn-login:hover { opacity: .9; }
.btn-login:disabled { opacity: .6; cursor: not-allowed; }

/* =========================================
   5. เมนูด้านบนและ Sidebar
========================================= */
.sidebar {
    width: 100%;
    background-color: var(--color-white);
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0 40px;
    border-bottom: 1px solid var(--border-light);
    height: 75px;
    z-index: 10;
}
.sidebar-header {
    display: flex;
    align-items: center;
    height: 100%;
    padding-right: 30px;
    margin-right: 10px;
}
.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: row;
    height: 100%;
    flex: 1;
    margin: 0;
    padding: 0;
}
.sidebar-menu li {
    height: 100%;
    position: relative;
    margin-bottom: 0;
}
.sidebar-menu > li > a {
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 100%;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    transition: all 0.2s ease;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
.sidebar-menu > li > a:hover {
    background-color: #f1f5f9;
    color: var(--color-wine);
}
.sidebar-menu > li > a.active {
    background-color: #f8fafc;
    color: var(--color-wine);
    box-shadow: inset 0 -3px 0 var(--color-wine);
}

/* Sidebar Dropdown */
.dropdown-toggle { justify-content: space-between; cursor: pointer; gap: 8px; }
.dropdown-toggle .arrow { display: flex; align-items: center; transition: transform 0.3s ease; color: #94a3b8; }
.dropdown-toggle.open .arrow { transform: rotate(180deg); color: var(--color-wine); }
.dropdown-menu {
    display: none; 
    position: absolute;
    top: 75px;
    left: 0;
    background: var(--color-white);
    min-width: 200px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    border-radius: 0 0 8px 8px;
    border: 1px solid var(--border-light);
    border-top: none;
    padding: 8px 0;
    z-index: 99;
    list-style: none;
    margin: 0;
}
.dropdown-menu li { margin-bottom: 0; height: auto; }
.dropdown-menu li a {
    padding: 10px 20px 10px 30px;
    font-size: 14px;
    color: #64748b;
    background: transparent;
    position: relative;
    display: flex;
    align-items: center;
    border-radius: 0;
    text-decoration: none;
}
.dropdown-menu li a::before {
    content: '';
    position: absolute;
    left: 12px; 
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #cbd5e1;
    transition: all 0.2s ease;
}
.dropdown-menu li a:hover, .dropdown-menu li a.active { background-color: #f8fafc; color: var(--color-wine); font-weight: 600; }
.dropdown-menu li a:hover::before, .dropdown-menu li a.active::before {
    background-color: var(--color-wine);
    width: 8px;
    height: 8px;
    left: 11px;
    box-shadow: 0 0 0 3px rgba(159, 18, 57, 0.1); 
}

/* Admin Profile */
.admin-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    height: 100%;
    padding-left: 20px;
}
.avatar {
    width: 40px;
    height: 40px;
    background-color: var(--color-heavenly);
    color: var(--color-white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
}
.admin-info { display: flex; flex-direction: column; }
.admin-name { font-size: 14px; font-weight: 500; color: var(--text-main); }
.logout-link { font-size: 13px; color: #ef4444; text-decoration: none; font-weight: 400; }
.logout-link:hover { text-decoration: underline; }

/* =========================================
   6. ส่วนเนื้อหา (Content & Cards)
========================================= */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { padding: 30px 40px 20px 40px; }
.topbar h2 { font-size: 24px; font-weight: 500; color: var(--text-main); }
.content {
    padding: 0 40px 40px 40px;
    overflow-y: auto;
    flex: 1;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

.dashboard-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; margin-bottom: 25px; }
.summary-cards-container { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 25px; }
.card-container { display: flex; gap: 20px; margin-bottom: 24px; }

.card, .data-card, .table-container {
    background: var(--color-white);
    padding: 24px;
    border-radius: 12px; 
    border: 1px solid #f1f5f9;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.form-container {
    background: var(--color-white);
    padding: 24px;
    border-radius: 12px; 
    border: 1px solid #f1f5f9;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    margin-bottom: 25px;

    background: var(--color-white);
    padding: 24px;
    border-radius: 12px; 
    border: 1px solid #f1f5f9;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); 
}
.card { display: flex; flex-direction: column; justify-content: center; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08); }
.card h3, .data-card-header h3 { font-size: 14px; color: #64748b; font-weight: 600; margin: 0 0 10px 0; text-transform: uppercase; letter-spacing: 0.5px; }
.data-card-header h3 { font-size: 16px; color: #1e293b; display: flex; align-items: center; gap: 8px; text-transform: none;}
.data-card-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #f1f5f9; padding-bottom: 12px; margin-bottom: 16px; }

.card .value { font-size: 32px; font-weight: 700; color: #1e293b; margin: 0; display: flex; align-items: baseline; gap: 8px; }
.card .unit { font-size: 14px; color: #94a3b8; font-weight: 500; }
.card.warning-card { background: linear-gradient(to bottom right, #fff, #fff5f5); border: 1px solid #fecaca; border-left: 5px solid #ef4444; }
.card.warning-card h3 { color: #ef4444; }
.card.warning-card .value { color: #b91c1c; }

.full-width-widget { grid-column: 1 / -1; margin-bottom: 24px; }
.alert-banner { background: #eff6ff; border: 1px solid #bfdbfe; border-left: 4px solid #3b82f6; padding: 12px 20px; border-radius: 6px; margin-bottom: 25px; display: flex; justify-content: space-between; align-items: center; }

/* =========================================
   7. ฟอร์มและปุ่ม (Forms & Buttons)
========================================= */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 15px; }
.form-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 15px; }
.form-group { margin-bottom: 15px; }
.form-group label, b, strong { font-weight: 500; font-size: 14px; color: var(--text-muted); display: block; margin-bottom: 5px;}
.form-group .desc { font-size: 13px; color: #64748b; margin-bottom: 8px; display: block; }

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background-color: var(--color-white);
    font-size: 14px;
    transition: 0.2s;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
}
.form-control:focus { border-color: var(--color-heavenly); box-shadow: 0 0 0 3px rgba(149,186,235,0.2); }
textarea.form-control { min-height: 150px; resize: vertical; line-height: 1.6; }

.btn-submit, .btn-add, .btn-edit-submit, .btn-export, .btn-test {
    color: var(--color-white);
    border: none;
    padding: 12px 20px;
    border-radius: 6px; 
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    font-family: inherit;
}
.btn-submit { background-color: var(--color-wine); }
.btn-submit:hover { background-color: #7a0300; }
.btn-edit-submit { background-color: #0284c7; }
.btn-edit-submit:hover { background-color: #0369a1; }
.btn-export { background-color: #10b981; display: inline-flex; align-items: center; gap: 8px; }
.btn-export:hover { background-color: #059669; transform: translateY(-1px); box-shadow: 0 4px 6px rgba(16,185,129,0.2); }
.btn-test { background-color: #0f172a; }
.btn-test:hover { background-color: #334155; }

.btn-cancel, .btn-back {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    padding: 11px 20px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}
.btn-cancel:hover, .btn-download-template:hover, .btn-back:hover { 
    background-color: #e2e8f0; 
    color: #1e293b; 
}
/* ปุ่มโหลดไฟล์ตัวอย่าง CSV */
.btn-download-template {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: #e2e8f0;
    color: #475569;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid #cbd5e1;
    white-space: nowrap; /* 🌟 คำสั่งสำคัญ ป้องกันข้อความตกบรรทัด */
}
.btn-download-template:hover { 
    background-color: #cbd5e1; 
    color: #1e293b; 
}

.btn-delete-bulk {
    background-color: #fff;
    color: #ef4444;
    border: 1px solid #fca5a5;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: 0.2s;
    font-size: 13px;
}
.btn-delete-bulk:hover { background-color: #fef2f2; border-color: #ef4444; }

.btn-link { background: none; border: none; color: #0284c7; font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: underline; padding: 0; }
.btn-link:hover { color: #0369a1; }

/* =========================================
   8. โครงสร้างเฉพาะของระบบจัดการ (Recipes & Ingredients)
========================================= */
.section-box { background: #f8fafc; padding: 20px; border: 1px dashed #cbd5e1; border-radius: 8px; margin-bottom: 20px; }
.ingredient-group-wrapper { background: #f1f5f9; padding: 20px; border: 1px solid #cbd5e1; border-radius: 8px; margin-bottom: 20px; box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.02);}
.group-header-row { display: flex; gap: 15px; align-items: center; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px dashed #94a3b8; }
.group-header-row label { margin: 0; font-weight: 600; color: #0284c7; white-space: nowrap; font-size: 14px; }
.group-header-row input { max-width: 400px; background: #fff; border-color: #0284c7; font-weight: 500; }
.btn-remove-group { margin-left: auto; background: #fef2f2; color: #ef4444; border: 1px solid #fca5a5; padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; transition: 0.2s; }
.btn-remove-group:hover { background: #ef4444; color: #fff; }

.ingredient-row { display: grid; grid-template-columns: 1.5fr 2fr 1fr 1.2fr auto auto; gap: 10px; margin-bottom: 12px; align-items: center; }
.step-row { display: flex; gap: 10px; margin-bottom: 12px; align-items: flex-start; }
.step-number { background: var(--color-heavenly); color: #fff; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 600; flex-shrink: 0; margin-top: 5px; font-size: 14px; }

.btn-add-row { background-color: #fff; border: 1px dashed #0284c7; padding: 10px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; color: #0284c7; transition: 0.2s; width: 100%; text-align: center; display: block;}
.btn-add-row:hover { background-color: #f0f9ff; }
.btn-remove { background-color: #fff; color: #ef4444; border: 1px solid #fca5a5; padding: 10px 12px; border-radius: 6px; cursor: pointer; font-weight: 500; height: 42px; transition: 0.2s; }
.btn-remove:hover { background-color: #fef2f2; }

.select2-container .select2-selection--single { height: 42px !important; padding-top: 6px; border: 1px solid #cbd5e1; border-radius: 6px; outline: none; }
.auto-calculated { background-color: #f0fdf4; border-color: #6ee7b7; color: #065f46; font-weight: 600; pointer-events: none; }

.recipe-thumbnail { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; border: 1px solid #e2e8f0; }
.image-preview-container { display: flex; align-items: center; gap: 15px; margin-bottom: 15px; }
.image-preview { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; border: 2px dashed #cbd5e1; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 13px; background: #f8fafc; overflow: hidden; position: relative;}

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; padding: 15px; background: #fff; border: 1px solid #cbd5e1; border-radius: 6px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #334155; cursor: pointer; }
.checkbox-item input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: #0284c7; }

/* =========================================
   9. ตารางและ DataTables
========================================= */
table { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-light); }
th, td { padding: 12px 15px; border-bottom: 1px solid #e2e8f0; text-align: left; vertical-align: middle; }
th { background-color: #f8fafc; color: #475569; font-weight: 600; text-transform: uppercase; font-size: 13px; white-space: nowrap;}
td { font-size: 14px; color: var(--text-main); }
tbody tr:hover { background-color: #f8fafc; }

/* DataTables Overrides */
table.dataTable thead th::before, table.dataTable thead th::after { display: none !important; }
table.dataTable thead th { border-bottom: 1px solid #e2e8f0 !important; }
table.dataTable { border-collapse: collapse !important; margin-top: 15px !important; margin-bottom: 15px !important; }
table.dataTable.no-footer { border-bottom: 1px solid #e2e8f0; }

.table-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; background-color: #fff; padding-bottom: 15px; }
.dataTables_length, .dataTables_filter { margin: 0 !important; float: none !important; }
.dataTables_length select { border: 1px solid #cbd5e1; border-radius: 6px; padding: 6px; outline: none; }
.dataTables_filter input { border: 1px solid #cbd5e1; border-radius: 6px; padding: 8px 14px; outline: none; margin-left: 10px; transition: 0.2s; }
.dataTables_filter input:focus { border-color: var(--color-heavenly); box-shadow: 0 0 0 3px rgba(149,186,235,0.2); }
.dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: 6px !important; padding: 6px 14px !important; margin: 0 2px; font-weight: 500; border: 1px solid transparent !important; }
html body .dataTables_wrapper .dataTables_paginate .paginate_button.current, 
html body .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover { 
    background-color: var(--color-wine) !important; 
    background-image: none !important; /* ปิด Gradient ดั้งเดิมของ DataTables */
    color: #ffffff !important; 
    border: 1px solid var(--color-wine) !important; 
    box-shadow: 0 2px 4px rgba(147,4,0,0.15) !important; 
}

/* บังคับสีตัวอักษรด้านในปุ่ม (ถ้ามี) ให้เป็นสีขาวด้วย */
html body .dataTables_wrapper .dataTables_paginate .paginate_button.current * {
    color: #ffffff !important;
}

.table-header-flex { display: flex; justify-content: space-between; align-items: center; padding-bottom: 15px; }
.custom-filters { display: flex; gap: 10px; flex: 1; justify-content: center; padding: 0 15px; }
.custom-filters select { height: 38px; border: 1px solid #cbd5e1; border-radius: 6px; padding: 0 10px; outline: none; font-family: inherit; font-size: 13px; color: #333; }

/* Action Links ในตาราง */
.action-links { 
    text-align: center; 
    white-space: nowrap; 
}
.action-links a, .btn-action, .btn-delete-action { 
    display: inline-block; 
    text-decoration: none; 
    font-size: 13px; 
    font-weight: 500; 
    padding: 6px 12px; 
    margin: 0 3px; 
    border-radius: 4px; 
    transition: all 0.2s ease; 
    cursor: pointer; 
    border: none;
}
.edit-link { color: #0284c7; background: #e0f2fe; }
.edit-link:hover { background: #bae6fd; }
.delete-link, .btn-delete-action { color: #ef4444; background: #fee2e2; border: 1px solid transparent; }
.delete-link:hover, .btn-delete-action:hover { background: #fecaca; }
.btn-action { background-color: #f59e0b; color: white; }
.btn-action:hover { background-color: #d97706; }

/* =========================================
   10. ป้ายสถานะต่างๆ (Badges & Helpers)
========================================= */
.badge-pending { background-color: #fee2e2; color: #b91c1c; padding: 4px 8px; border-radius: 9999px; font-size: 12px; font-weight: 600; }
.badge, .badge-none, .badge-min, .badge-max, .badge-banned { display: inline-block; padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; margin-bottom: 4px; margin-right: 4px; border: 1px solid transparent; }
.badge { background: #f1f5f9; color: #475569; }
.badge-none { background: #f0fdf4; color: #059669; border-color: #86efac; }
.badge-min { background: #e0f2fe; color: #0284c7; border-color: #bae6fd; font-weight: 600;}
.badge-max { background: #fef08a; color: #a16207; border-color: #fde047; font-weight: 600;}
.badge-banned { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.badge-table-warning { background: #fee2e2; color: #b91c1c; padding: 4px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; display: inline-block; margin-top: 4px; }
.calc-badge { font-size: 11px; background: #dcfce7; color: #059669; padding: 2px 6px; border-radius: 4px; margin-left: 6px; font-weight: 600; }
.view-all-link { display: inline-block; margin-top: 16px; color: #0284c7; font-size: 14px; font-weight: 500; text-decoration: none; transition: 0.2s; }
.view-all-link:hover { color: #0369a1; text-decoration: underline; }

/* CSV Upload Guides */
.csv-guide { font-size: 13px; color: #64748b; background: #fff; padding: 16px; border-radius: 6px; margin-bottom: 16px; line-height: 1.8; }
.import-flex-row { display: flex; gap: 12px; align-items: center; }
.btn-import-green { background-color: #10b981; color: white; border: none; border-radius: 6px; font-weight: 500; padding: 10px 20px; cursor: pointer; transition: 0.2s; white-space: nowrap; }
.btn-import-green:hover { background-color: #059669; box-shadow: 0 4px 6px rgba(16,185,129,0.2); }
.file-input-custom { padding: 7px; background: #fff; cursor: pointer; flex: 1; }

/* =========================================
   11. หน้า AI Configs (Sliders, Loaders)
========================================= */
.range-slider-container { display: flex; align-items: center; gap: 15px; }
.range-slider { flex-grow: 1; accent-color: var(--color-wine); cursor: pointer; }
.range-value { background: #f1f5f9; padding: 6px 12px; border-radius: 6px; font-weight: 600; color: var(--color-wine); border: 1px solid #e2e8f0; min-width: 45px; text-align: center; }
.ai-header-icon { display: flex; align-items: center; gap: 10px; margin-bottom: 25px; padding-bottom: 15px; border-bottom: 1px solid #e2e8f0; }
.ai-header-icon svg { width: 28px; height: 28px; color: var(--color-wine); }
.ai-header-icon h3 { margin: 0; font-size: 20px; color: #1e293b; }
.flex-between { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 8px; }
.char-count { font-size: 12px; color: #64748b; font-weight: 500; }
.char-count.warning { color: #eab308; }
.char-count.danger { color: #ef4444; }
.playground-box { background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 8px; padding: 20px; margin-top: 30px; }
.playground-box h4 { margin-top: 0; margin-bottom: 15px; font-size: 16px; color: #334155; display: flex; align-items: center; gap: 8px; }
.test-result { margin-top: 15px; padding: 15px; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 14px; color: #475569; display: none; line-height: 1.6; }
.loading-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: #fff; animation: spin 1s ease-in-out infinite; margin-right: 8px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================
   12. Modals (กล่อง Popup อัปเดตโภชนาการ)
========================================= */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-content { background: #fff; width: 100%; max-width: 600px; max-height: 90vh; border-radius: 12px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); overflow: hidden; display: flex; flex-direction: column; animation: modalFadeIn 0.3s ease; }
@keyframes modalFadeIn { from { opacity: 0; transform: translateY(-20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-header { padding: 20px 24px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; background-color: #f8fafc; flex-shrink: 0; }
.modal-header h3 { margin: 0; font-size: 18px; color: #1e293b; }
.close-modal { background: none; border: none; font-size: 24px; color: #94a3b8; cursor: pointer; line-height: 1; }
.close-modal:hover { color: #ef4444; }
.modal-content form { display: flex; flex-direction: column; flex-grow: 1; overflow: hidden; }
.modal-body { padding: 24px; overflow-y: auto; flex-grow: 1; }
.form-group-modal label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; color: #475569; }
.form-control-modal { width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; outline: none; transition: 0.2s; box-sizing: border-box;}
.form-control-modal:focus { border-color: #0284c7; box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1); }
.modal-footer { padding: 16px 24px; background-color: #f8fafc; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 12px; flex-shrink: 0; }
.btn-cancel-modal { background: #fff; border: 1px solid #cbd5e1; color: #475569; padding: 10px 16px; border-radius: 6px; cursor: pointer; font-weight: 500; }
.btn-save-modal { background: #0284c7; border: none; color: white; padding: 10px 20px; border-radius: 6px; cursor: pointer; font-weight: 500; }

/* =========================================
   13. Essential Ingredient Toggle (วัตถุดิบหลัก แบบกุญแจล็อก)
========================================= */
.essential-lock-toggle {
    display: inline-block;
    cursor: pointer;
    user-select: none;
}
.essential-lock-toggle input[type="checkbox"] {
    display: none; /* ซ่อน Checkbox เดิม */
}
.essential-lock-toggle .lock-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 12px;
    height: 42px;
    border-radius: 6px;
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}
.essential-lock-toggle input[type="checkbox"]:checked + .lock-btn {
    background-color: #fffbeb;
    border-color: #f59e0b;
    color: #d97706;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}
.essential-lock-toggle .icon-lock { display: none; }
.essential-lock-toggle .icon-unlock { display: flex; align-items: center; gap: 6px; }

.essential-lock-toggle input[type="checkbox"]:checked + .lock-btn .icon-lock { display: flex; align-items: center; gap: 6px; }
.essential-lock-toggle input[type="checkbox"]:checked + .lock-btn .icon-unlock { display: none; }

/* ปรับไอคอนให้ขยับลงมาตรงกับตัวหนังสือนิดหน่อย */
.essential-lock-toggle i { transform: translateY(1px); }
/* ====== Styles for Categories, Units, Users Pages ====== */
.badge {
    background-color: #f1f5f9;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
    color: #475569;
    border: 1px solid #e2e8f0;
}
.badge-none {
    color: #94a3b8;
    background: transparent;
    border: 1px solid #e2e8f0;
}
.badge-female {
    background-color: #fdf2f8;
    color: #db2777;
    border-color: #fbcfe8;
}
.badge-male {
    background-color: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}
.btn-edit-submit {
    background-color: #3b82f6;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
}
.btn-edit-submit:hover {
    background-color: #2563eb;
}
.btn-cancel {
    background-color: #f1f5f9;
    color: #475569;
    padding: 12px 20px;
    border-radius: 8px;
    text-decoration: none;
    margin-left: 10px;
    font-family: inherit;
    font-weight: 500;
}
.btn-cancel:hover {
    background-color: #e2e8f0;
}
