/* =========================================================
   ១. ការកំណត់ពណ៌ និងស្តង់ដារទូទៅ (CSS Variables)
   ========================================================= */
:root {
    /* ពណ៌គោលសម្រាប់គ្លីនិក (ពណ៌ខៀវសុខាភិបាល) */
    --primary-color: #0284c7; 
    --primary-hover: #0369a1;
    
     /* ពណ៌សម្រាប់ Sidebar (ម៉ឺនុយខាងឆ្វេង) */
    --sidebar-bg: #0a1628;
    --sidebar-text: #94a3b8;
    --sidebar-hover-bg: rgba(255,255,255,0.05);
    --sidebar-active-bg: rgba(2,132,199,0.15);
    --sidebar-active-text: #38bdf8;
    
    /* ពណ៌សម្រាប់ផ្ទៃបង្ហាញទិន្នន័យ (Main Content) */
    --main-bg: #f8fafc; 
    --text-main: #334155;
    --border-color: #e2e8f0;
    
    /* ពណ៌សម្រាប់ប៊ូតុងចាកចេញ (Logout) */
    --danger-color: #ef4444;
}

/* លុបគម្លាតដើមចោល និងកំណត់ Font ជាភាសាខ្មែរ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Battambang', sans-serif;
}

body {
    background-color: var(--main-bg);
    color: var(--text-main);
    overflow: hidden; /* បង្ការការអូសពេញអេក្រង់ (Scroll) ផ្តេសផ្តាស */
}

/* =========================================================
   ២. រចនាសម្ព័ន្ធគោល (Layout Core)
   ========================================================= */
.app-container {
    display: flex;
    height: 100vh; /* កម្ពស់ពេញអេក្រង់ជានិច្ច */
    width: 100%;
}

/* =========================================================
   ៣. ម៉ឺនុយបញ្ឈរខាងឆ្វេង (Vertical Sidebar)
   ========================================================= */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 100;
}

/* នៅពេល Sidebar ត្រូវបង្រួមតូច */
.sidebar.collapsed {
    width: 80px;
}

/* ផ្នែកក្បាលនៃ Sidebar (Logo & Title) */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header .logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0284c7, #0ea5e9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 17px;
    flex-shrink: 0;
}

.sidebar-header .logo-text {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    line-height: 1.2;
}

.sidebar-header .logo-sub {
    font-size: 10px;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    margin-top: 2px;
}

#toggle-btn {
    background: none;
    border: none;
    color: #475569;
    font-size: 18px;
    cursor: pointer;
    transition: 0.2s;
}

#toggle-btn:hover {
    color: #ffffff;
}

/* បញ្ជីម៉ឺនុយ (Menu List) */
.menu-list {
    list-style: none;
    padding: 8px 8px;
    flex-grow: 1;
    overflow-y: auto;
}

/* លាក់ Scrollbar សម្រាប់ភាពស្រស់ស្អាត */
.menu-list::-webkit-scrollbar {
    width: 4px;
}
.menu-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

/* Section Labels */
.menu-section-label {
    list-style: none;
    padding: 10px 12px 4px;
    font-size: 10px;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
}

/* Divider */
.menu-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 6px 10px;
    list-style: none;
}

/* Badge dot ថ្នាំជិតអស់ */
.menu-badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
    margin-left: auto;
    flex-shrink: 0;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 9px 10px;
    margin-bottom: 2px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.menu-item i {
    font-size: 16px;
    width: 28px;
    flex-shrink: 0;
}

.menu-item span {
    font-size: 14px;
    white-space: nowrap;
}

/* Hover */
.menu-item:hover {
    background-color: var(--sidebar-hover-bg);
    color: #ffffff;
}

/* Active — left border indicator */
.menu-item.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}
.menu-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    background: #0284c7;
    border-radius: 0 3px 3px 0;
}

/* Logout */
.menu-item.logout {
    margin-top: auto;
    border-radius: 8px;
    padding: 9px 10px;
    border-top: none;
}

.menu-item.logout:hover {
    background-color: rgba(239,68,68,0.1);
    color: #f87171;
}

/* =========================================================
   ៤. ផ្នែកប្តូរភាសា (Language Switcher)
   ========================================================= */
.language-switcher {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 12px 10px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.language-switcher button {
    background-color: rgba(255,255,255,0.06);
    color: var(--sidebar-text);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: 0.2s;
    font-family: 'Battambang', sans-serif;
}

.language-switcher button:hover {
    background-color: var(--primary-color);
    color: #ffffff;
}

.language-switcher button.lang-active {
    background-color: rgba(2,132,199,0.2);
    color: #38bdf8;
    border-color: rgba(2,132,199,0.35);
}

/* =========================================================
   ៥. ផ្ទៃបង្ហាញទិន្នន័យចម្បង (Main Content)
   ========================================================= */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--main-bg);
    overflow-y: auto;
}

/* =========================================================
   ៦. ម៉ឺនុយរងផ្តេកខាងលើ (Horizontal Submenu)
   ========================================================= */
.horizontal-submenu {
    background-color: #ffffff;
    padding: 0 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border-bottom: 1px solid var(--border-color);
}

.horizontal-submenu ul {
    list-style: none;
    display: flex;
    gap: 20px;
}

.horizontal-submenu li {
    padding: 15px 10px;
    cursor: pointer;
    font-size: 15px;
    color: #64748b;
    border-bottom: 3px solid transparent;
    transition: 0.2s;
}

.horizontal-submenu li:hover {
    color: var(--primary-color);
}

.horizontal-submenu li.active-sub {
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
    font-weight: 700;
}

/* =========================================================
   ៧. កន្លែងផ្ទុកទិន្នន័យ (Content Container)
   ========================================================= */
#content-container {
    padding: 25px;
    flex-grow: 1;
}

/* កូដជំនួយពេល Sidebar បង្រួមតូច លាក់អក្សរទុកតែ Icon */
.sidebar.collapsed .logo-text,
.sidebar.collapsed .logo-sub,
.sidebar.collapsed .menu-item span,
.sidebar.collapsed .language-switcher,
.sidebar.collapsed .menu-section-label,
.sidebar.collapsed .menu-divider {
    display: none;
}
.sidebar.collapsed .sidebar-header {
    justify-content: center;
}
.sidebar.collapsed .menu-item i {
    width: auto;
    margin: 0 auto;
}
.sidebar.collapsed .menu-badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    margin-left: 0;
}
/* =========================================================
   ៩. រចនាប័ទ្មសម្រាប់ទម្រង់បញ្ចូលទិន្នន័យ (Modern Forms & Cards)
   ========================================================= */

/* កាតពណ៌ស (Cards) */
.card {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

/* ចំណងជើងកាត */
.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

/* ការរៀបចំទម្រង់ជាក្រឡា (CSS Grid) */
.form-grid {
    display: grid;
    /* បង្កើតជួរឈរស្វ័យប្រវត្តិ៖ យ៉ាងហោចណាស់ទំហំ 220px បើធំជាងហ្នឹងវាពង្រីកខ្លួន */
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* សម្រាប់ទម្រង់ណាដែលចង់ឲ្យលាតពេញបន្ទាត់ (ដូចជា Address ឬ Textarea) */
.full-width {
    grid-column: 1 / -1;
}

/* ចំណងជើងពីលើប្រអប់ (Labels) */
.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
}

/* ប្រអប់វាយបញ្ចូលទិន្នន័យ (Inputs & Selects) */
.input-field {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    background-color: #ffffff;
    color: #334155;
}

/* ពណ៌ពេលយក Mouse ចុចវាយអក្សរ */
.input-field:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* ប្រអប់អក្សរធំ (Textarea) */
.textarea-field {
    resize: vertical;
    min-height: 80px;
}

/* ប្រអប់ដែលគ្រាន់តែមើល មិនអាចវាយអក្សរបាន (Readonly) */
.readonly-input {
    background-color: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}

/* ប្រអប់ដែលចុចបាន (ដូចជា Date/Time) */
.clickable-input {
    cursor: pointer;
}
.clickable-input:hover {
    border-color: var(--primary-color);
}

/* ការរៀបចំប្រអប់សម្ពាធឈាម (Blood Pressure Group) */
.bp-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.bp-divider {
    font-size: 20px;
    color: #94a3b8;
    font-weight: bold;
}

.action-footer {
    display: flex;
    justify-content: space-between; /* ធ្វើឱ្យប៊ូតុងមួយនៅឆ្វេង មួយនៅស្តាំ */
    align-items: center;
    padding: 20px 0;
    margin-top: 20px;
    border-top: 1px solid #e2e8f0;
}
/* ក្នុងករណីអ្នកចង់ឱ្យវាទាំង ២ នៅស្តាំតែម្តង */
.action-footer.align-right {
    justify-content: flex-end;
    gap: 15px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #ffffff;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
    box-shadow: 0 2px 4px rgba(2, 132, 199, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}
/* =========================================================
   ៨. រចនាប័ទ្មសម្រាប់ទូរសព្ទដៃ (Responsive Media Queries)
   ========================================================= */

/* អនុវត្តនៅពេលអេក្រង់មានទំហំចាប់ពី 768px ចុះក្រោម */
@media screen and (max-width: 768px) {
    
    /* 1. បង្រួមម៉ឺនុយបញ្ឈរ (Sidebar) ឲ្យតូចស្វ័យប្រវត្តិ */
    .sidebar {
        width: 70px; /* បង្រួមទំហំមកត្រឹម 70px */
    }

    /* 2. លាក់អក្សរ រក្សាទុកតែ Icon ដើម្បីកុំឲ្យចង្អៀតអេក្រង់ */
    .sidebar .logo-text,
    .sidebar .menu-item span,
    .sidebar .language-switcher {
        display: none; 
    }

    /* 3. តម្រឹម Icon ឲ្យនៅចំកណ្តាលស្អាត */
    .sidebar .sidebar-header {
        justify-content: center;
        padding: 15px 0;
    }

    .sidebar .menu-item i {
        width: auto;
        margin: 0 auto;
        font-size: 20px; /* ដំឡើងទំហំ Icon បន្តិចឲ្យងាយស្រួលចុចលើទូរសព្ទ */
    }

    .sidebar .menu-item {
        padding: 15px 0;
        justify-content: center;
    }

    /* 4. លាក់ប៊ូតុង Toggle (ព្រោះនៅលើទូរសព្ទវាតូចស្រាប់ហើយ មិនបាច់បង្រួមទៀតទេ) */
    #toggle-btn {
        display: none;
    }

    /* 5. កែសម្រួលម៉ឺនុយរងផ្តេកខាងលើ (Submenu) ឲ្យអាចអូសបាន (Scroll) */
    .horizontal-submenu ul {
        overflow-x: auto; /* អនុញ្ញាតឲ្យអូសទៅឆ្វេងស្តាំបាន ពេលម៉ឺនុយវែងពេក */
        white-space: nowrap; /* មិនឲ្យអក្សរធ្លាក់ចុះបន្ទាត់ */
        padding-bottom: 5px; /* ទុកចន្លោះបន្តិចសម្រាប់ Scrollbar */
    }
    
    /* លាក់ Scrollbar លើទូរសព្ទឲ្យមើលទៅស្អាត (សម្រាប់ Submenu) */
    .horizontal-submenu ul::-webkit-scrollbar {
        height: 3px;
    }
    .horizontal-submenu ul::-webkit-scrollbar-thumb {
        background-color: var(--primary-color);
        border-radius: 5px;
    }

    /* 6. បង្រួមទំហំផ្ទៃខាងក្នុង (Padding) នៃកន្លែងបង្ហាញទិន្នន័យ */
    #content-container {
        padding: 15px; 
    }
}
/* លាក់គ្រប់ Section ទាំងអស់ជាមុនសិន */
.content-section {
    display: none;
}

/* បង្ហាញតែ Section ណាដែលយើងឱ្យ class active ប៉ុណ្ណោះ */
.content-section.active-section {
    display: block;
}
/* =========================================================
   ១០. រចនាប័ទ្មសម្រាប់ Dashboard និង Tables
   ========================================================= */

/* ផ្នែក Header របស់ទំព័រនីមួយៗ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.page-header h1 {
    font-size: 24px;
    color: var(--text-main);
}

.text-muted {
    color: #64748b;
    font-size: 14px;
    margin-top: 5px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* ប៊ូតុងរង (Secondary Button) */
.btn-secondary {
    background-color: #ffffff;
    color: #475569;
    padding: 12px 20px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: #f8fafc;
    border-color: #94a3b8;
}

/* ការរៀបចំប្រអប់ Stats (4 ជួរឈរ) */
.dashboard-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    margin-bottom: 0;
}

.stat-title {
    font-size: 14px;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
}

/* ពណ៌ជំនួយសម្រាប់ Stats */
.text-dark { color: #1e293b; }
.text-green { color: #10b981; }
.text-red { color: #ef4444; }

.border-blue { border-left: 5px solid #3b82f6; }
.border-green { border-left: 5px solid #10b981; }
.border-orange { border-left: 5px solid #f59e0b; }
.border-red { border-left: 5px solid #ef4444; }

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.icon-blue { background: #eff6ff; color: #3b82f6; }
.icon-green { background: #dcfce7; color: #10b981; }
.icon-orange { background: #fef3c7; color: #f59e0b; }
.icon-red { background: #fef2f2; color: #ef4444; }

/* ការរៀបចំតារាង (2 ជួរឈរ) */
.dashboard-tables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.data-table th, .data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
}

.data-table th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
}

.data-table tbody tr:hover {
    background-color: #f1f5f9;
}
/* =========================================================
   ១១. រចនាប័ទ្មសម្រាប់ Checkbox Buttons (ស្ថានភាពអ្នកជំងឺ)
   ========================================================= */
.custom-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.custom-check-btn {
    position: relative;
    cursor: pointer;
}

/* លាក់ប្រអប់ Checkbox ដើមចោល */
.custom-check-btn input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* រចនាប៊ូតុងជំនួស */
.custom-check-btn span {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    background-color: #f8fafc;
    color: #475569;
    font-size: 14px;
    transition: all 0.2s;
    user-select: none;
}

/* ពេលយក Mouse ទៅដាក់ពីលើ */
.custom-check-btn:hover span {
    background-color: #e2e8f0;
}

/* ពណ៌ពេលចុចជ្រើសរើស (Checked State) */
.custom-check-btn.status-good input:checked ~ span {
    background-color: #dcfce7;
    border-color: #10b981;
    color: #047857;
}

.custom-check-btn.status-bad input:checked ~ span {
    background-color: #fef3c7;
    border-color: #f59e0b;
    color: #b45309;
}

.custom-check-btn.status-severe input:checked ~ span,
.custom-check-btn.status-cyanosis input:checked ~ span,
.custom-check-btn.status-jaundice input:checked ~ span {
    background-color: #fef2f2;
    border-color: #ef4444;
    color: #b91c1c;
}
/* =========================================================
   ១២. រចនាប័ទ្មសម្រាប់ File Upload (Dropzone) និងគម្លាត
   ========================================================= */

/* បន្ថែមគម្លាតពីលើបន្តិច (Margin Top) សម្រាប់ធាតុផ្សេងៗ */
.mt-20 {
    margin-top: 20px;
}

.upload-container {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed var(--border-color);
}

/* ប្រអប់សម្រាប់ទម្លាក់រូបភាព */
.dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    background-color: #f8fafc;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dropzone:hover, .dropzone.dragover {
    background-color: #f0f9ff;
    border-color: var(--primary-color);
}

/* កន្លែងបង្ហាញរូបភាពដែលបានរើសរួច */
.preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
}

.preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ប៊ូតុងលុបរូបភាពចោលវិញ (សញ្ញាខ្វែង) */
.delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
@media print {
    /* លាក់អ្វីដែលមិនចាំបាច់ */
    .hide-print-col, .btn-secondary, button, .card-header-toggle, .mobile-card-container {
        display: none !important;
    }

    /* រចនាប័ទ្មតារាងស្តង់ដារ */
    .data-table {
        width: 100%;
        border-collapse: collapse;
        margin-top: 10px;
    }
    .data-table th, .data-table td {
        border: 1px solid #000 !important;
        padding: 6px !important;
        text-align: left;
        color: #000 !important;
    }

    /* បំប្លែង Input ឱ្យទៅជា Text ធម្មតាពេលព្រីន */
    input, select, textarea {
        border: none !important;
        background: transparent !important;
        appearance: none !important;
        -webkit-appearance: none !important;
        color: #000 !important;
        font-family: 'Battambang', sans-serif !important;
        font-size: 13px !important;
        width: 100%;
        display: block;
    }
}
.preview-logo { border: 1px solid #e2e8f0; border-radius: 4px; padding: 5px; }
.card-title { font-size: 1.1rem; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 15px; }
/* រៀបចំ Input ក្នុង Vitals ឱ្យស្អាត */
#evolution-table .input-field {
    width: 100%;
    box-sizing: border-box;
}

/* ប៊ូតុងលុប */
.delete-btn i {
    font-size: 1.1rem;
    transition: color 0.2s;
}
.delete-btn:hover i {
    color: #b91c1c;
}

/* ធានាថាជួរឈរ Action មិនព្រីនចេញ */
@media print {
    .hide-print-col { display: none !important; }
}
/* កំណត់ទំហំ Column តាមតម្រូវការ */
#evolution-table th:nth-child(3) { width: 25%; } /* Vitals តូចជាងមុន */
#evolution-table th:nth-child(4) { width: 35%; } /* Note ធំជាងមុន */

/* បង្ខំឱ្យ Icon ស្ថិតនៅក្នុង TD ជានិច្ច */
#evolution-tbody td {
    position: relative !important;
}
.delete-btn {
    display: inline-block !important;
    position: static !important;
}
/* បង្ហាញតារាងលើកុំព្យូទ័រ លាក់នៅលើទូរស័ព្ទ */
.mobile-card-container { display: none; }

@media (max-width: 768px) {
    .data-table { display: none !important; } /* លាក់តារាង */
    .mobile-card-container { display: block; } /* បង្ហាញ Card */
    
    .evolution-card {
        background: #fff;
        padding: 15px;
        margin-bottom: 12px;
        border-radius: 10px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        border-left: 5px solid #10b981;
    }
    .evolution-card p { margin: 5px 0; font-size: 14px; }
}
#opd-table {
    min-width: 900px; /* បង្ខំឱ្យតារាងមានទំហំធំល្មមជានិច្ច បើអេក្រង់តូចគឺអូសឆ្វេងស្តាំបាន */
}
#opd-table {
    min-width: 900px; /* បង្ខំឱ្យតារាងមានទំហំធំល្មមជានិច្ច បើអេក្រង់តូចគឺអូសឆ្វេងស្តាំបាន */
}
/* =========================================================
   រចនាតារាង Invoice (ពណ៌ និង ហ្វុង)
   ========================================================= */
#invoice-items-table th {
    background-color: #2563eb !important; /* ពណ៌ខៀវច្បាស់លាស់ */
    color: #ffffff !important;
    font-size: 14px;
    padding: 12px;
    border: 1px solid #1d4ed8;
}

#invoice-items-table input.inv-desc,
#invoice-items-table input.inv-qty,
#invoice-items-table input.inv-price {
    font-size: 14px;
    color: #1e293b;
}

/* ពេល Hover លើប្រអប់ឱ្យលោតពណ៌តិចៗដើម្បីដឹងថាអាចកែបាន */
#invoice-items-table input:hover, #invoice-items-table input:focus {
    background-color: #f1f5f9 !important;
    outline: none;
    border-radius: 4px;
}

/* =========================================================
   រចនាពេល Print (Print Layout)
   ========================================================= */
@media print {
    /* លាក់ម៉ឺនុយ និងប៊ូតុងទាំងអស់ */
    body * {
        visibility: hidden;
    }
    
    /* បង្ហាញតែក្រដាសវិក្កយបត្រប៉ុណ្ណោះ */
    #invoice-print-area, #invoice-print-area * {
        visibility: visible;
    }
    
    #invoice-print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }

    /* លាក់ប៊ូតុងនៅក្នុងវិក្កយបត្រ (ដូចជាប៊ូតុង +Add) */
    #invoice-print-area button, 
    .action-footer {
        display: none !important;
    }

    /* កែទម្រង់ Input ឱ្យក្លាយជាអក្សរធម្មតាពេលព្រីន */
    #invoice-print-area input {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        pointer-events: none; /* មិនឱ្យចុចកើតពេលកំពុងព្រីន */
    }

    /* រក្សាពណ៌ក្បាលតារាងពេលព្រីន */
    #invoice-items-table th {
        background-color: #e2e8f0 !important; /* ដាក់ពណ៌ប្រផេះខ្ចីពេលព្រីនសន្សំទឹកថ្នាំ */
        color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
/* =========================================================
   Responsive សម្រាប់ Smart Invoice លើទូរសព្ទ (Mobile View)
   ========================================================= */
.invoice-summary-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.invoice-summary-left {
    flex: 1;
    min-width: 250px;
}

.invoice-summary-right {
    width: 350px; /* ទំហំអតិបរមាលើកុំព្យូទ័រ */
    background: #f8fafc; 
    padding: 20px; 
    border-radius: 8px;
}

/* ច្បាប់សម្រាប់អេក្រង់ទូរសព្ទ និង Tablet តូចៗ (ក្រោម 768px) */
@media screen and (max-width: 768px) {
    .invoice-header-info, .invoice-patient-info {
        flex-direction: column;
        text-align: left !important;
    }
    
    .text-right-mobile {
        text-align: left !important;
    }

    .invoice-summary-wrapper {
        flex-direction: column-reverse; /* លើទូរសព្ទ យកប្រអប់សរុបលុយមកដាក់ខាងលើគេ */
    }

    .invoice-summary-right {
        width: 100%; /* ឱ្យប្រអប់លុយលាតពេញអេក្រង់ទូរសព្ទ */
    }
    
    #invoice-print-area {
        padding: 15px; /* បង្រួមចន្លោះគែមលើទូរសព្ទ */
    }
}
@media screen and (max-width: 768px) {
    /* បង្រួម Input ក្នុងតារាងវិក្កយបត្រ ឱ្យសមនឹងអេក្រង់ទូរសព្ទ */
    #invoice-items-table input.inv-desc { min-width: 120px; }
    #invoice-items-table input.inv-qty { min-width: 40px; }
    #invoice-items-table input.inv-price { min-width: 60px; }
}
/* =========================================================
   រចនា Pharmacy Grid Card (របៀបទី ២)
   ========================================================= */
.medicine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.med-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.med-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
    border-color: #cbd5e1;
}

.med-card-img {
    width: 100px;
    height: 100px;
    object-fit: cover; /* ការពារកុំឱ្យរូបព្រាល ឬខូចទ្រង់ទ្រាយ */
    border-radius: 12px;
    margin: 0 auto 15px auto;
    border: 1px solid #f1f5f9;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.med-card-title { font-weight: bold; font-size: 16px; margin-bottom: 5px; color: #0f172a; line-height: 1.3;}
.med-card-category { font-size: 12px; color: #64748b; margin-bottom: 15px; }
.med-card-info { background: #f8fafc; border-radius: 8px; padding: 10px; margin-bottom: 15px; }
.med-card-stock { font-size: 14px; margin-bottom: 5px; }
.med-card-price { font-weight: bold; color: #0284c7; font-size: 15px; }
.med-card-actions { display: flex; justify-content: center; gap: 8px; margin-top: auto; }
.med-card-actions button { flex: 1; padding: 8px; border-radius: 6px; }

/* សម្រាប់អេក្រង់ទូរសព្ទ៖ លាក់ប៊ូតុងប្តូរ View ហើយបង្ខំឱ្យប្រើ Grid Card ជា Default */
@media screen and (max-width: 768px) {
    .view-toggle-box { display: none !important; }
    .medicine-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
/* =========================================================
   តែមលោតជូនដំណឹង (Alert Badges) សម្រាប់ថ្នាំជិតអស់ និងជិតផុតកំណត់
   ========================================================= */
.badge-low-stock {
    background-color: #fee2e2;
    color: #ef4444;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #fca5a5;
    margin-left: 5px;
    display: inline-block;
    vertical-align: middle;
}

.badge-expire {
    background-color: #fef08a;
    color: #b45309;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #fde047;
    margin-left: 5px;
    display: inline-block;
    vertical-align: middle;
}
/* ── Toast Animations ── */
@keyframes toastIn {
    from { opacity:0; transform:translateX(100%); }
    to   { opacity:1; transform:translateX(0);    }
}
@keyframes toastOut {
    from { opacity:1; transform:translateX(0);    }
    to   { opacity:0; transform:translateX(100%); }
}

/* ── Paraclinic Tabs ── */
.para-tab-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: #f1f5f9;
    padding: 6px;
    border-radius: 14px;
    flex-wrap: wrap;
}
.para-tab-btn {
    flex: 1;
    min-width: 80px;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #64748b;
    font-family: 'Battambang', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.para-tab-btn.active {
    background: #fff;
    color: #1e3a5f;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.para-sub-tab-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.para-sub-tab-btn {
    padding: 7px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    color: #475569;
    font-family: 'Battambang', sans-serif;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.para-sub-tab-btn.active {
    border-color: #3b82f6;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: bold;
}
.para-content { display: none; }
.para-content.active { display: block; }