/* ===================================================================
   STYLE.CSS - Hotel Procurement Tracking System
   Version: Consolidated Final (Includes all optimizations)
   =================================================================== */

/* ===================================================================
   1. Global & Base Styles
   =================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    background-color: #f8f9fa; /* Light overall background */
    color: #495057; /* Slightly softer text color */
    margin: 0;
    padding: 20px;
    font-size: 15px; /* Base font size */
    line-height: 1.6;
}

.container {
    width: 95%; /* Use percentage width for better scaling */
    min-width: 320px;
    max-width: none; /* Allow container to grow wide */
    margin: 20px auto;
    background-color: #ffffff;
    padding: 30px 40px;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
    border: 1px solid #dee2e6;
}
/* Optional wider container if needed */
.container-wide {
    width: 96%;
    max-width: none;
    margin-left: 2%;
    margin-right: 2%;
}

h1 { color: #343a40; border-bottom: 1px solid #dee2e6; padding-bottom: 15px; margin-top: 0; margin-bottom: 25px; font-size: 1.9em; font-weight: 600; }
h2 { color: #343a40; font-size: 1.6em; font-weight: 600; margin-bottom: 1em; }
h3 { color: #495057; font-size: 1.3em; margin-top: 1.8em; margin-bottom: 1em; font-weight: 600; border-bottom: 1px dashed #e0e0e0; padding-bottom: 8px; }

a { color: #007bff; text-decoration: none; transition: color 0.2s; }
a:hover { color: #0056b3; text-decoration: none; }

hr { border: none; border-top: 1px solid #e9ecef; margin: 40px 0; }
.full-width { grid-column: 1 / -1; } /* Specific to grid layouts */
small { font-size: 0.8em; color: #6c757d; display: inline-block; margin-top: 4px; }

/* Status messages */
.error-message { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; padding: 12px 15px; border-radius: 4px; margin-bottom: 20px; }
.success-message { background-color: #d4edda; color: #155724; padding: 12px 15px; border: 1px solid #c3e6cb; border-radius: 4px; margin-bottom: 20px; }
.highlight { background-color: #fffbeb; padding: 15px; border-radius: 4px; margin-bottom: 20px; border: 1px solid #fde68a; color: #ca8a04; }


/* ===================================================================
   2. Buttons
   =================================================================== */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; font-size: 14px; font-weight: 600; text-decoration: none !important; color: white !important; border-radius: 6px; cursor: pointer; border: none; margin: 5px 5px 5px 0; transition: all 0.2s ease-in-out; text-align: center; vertical-align: middle; }
.btn:hover { text-decoration: none !important; box-shadow: 0 4px 8px rgba(0,0,0,0.1); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

.btn-add { background-color: #28a745; border-bottom: 2px solid #218838; } .btn-add:hover { background-color: #218838; }
.btn-cancel { background-color: #6c757d; border-bottom: 2px solid #5a6268; } .btn-cancel:hover { background-color: #5a6268; }
.btn-info { background-color: #17a2b8; border-bottom: 2px solid #138496; } .btn-info:hover { background-color: #138496; }

/* Small buttons */
.btn-sm { display: inline-flex; align-items: center; justify-content: center; padding: 5px 10px; font-size: 12px; font-weight: 600; text-decoration: none !important; color: white !important; border-radius: 4px; cursor: pointer; border: none; margin: 2px; transition: all 0.15s ease-in-out; vertical-align: middle; }
.btn-sm:hover { box-shadow: 0 2px 4px rgba(0,0,0,0.1); transform: translateY(-1px); }
.btn-sm:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.btn-edit { background-color: #007bff; border-bottom: 1px solid #0069d9;} .btn-edit:hover { background-color: #0069d9; }
.btn-delete { background-color: #dc3545; border-bottom: 1px solid #c82333;} .btn-delete:hover { background-color: #c82333; }
.btn-replace { background-color: #ffc107; color: #212529 !important; border-bottom: 1px solid #e0a800;} .btn-replace:hover { background-color: #e0a800; }

/* Clear Filter Button */
.btn-clear-filter { display: inline-flex; align-items: center; text-decoration: none; color: #6c757d; font-weight: 500; font-size: 13px; margin-left: 8px; padding: 4px 8px; border: 1px solid #ced4da; border-radius: 4px; line-height: 1; background-color: #f8f9fa; white-space: nowrap; vertical-align: middle; transition: all 0.2s; }
.btn-clear-filter:hover { background-color: #e2e6ea; color: #dc3545; text-decoration: none; border-color: #adb5bd; }
.filter-input-wrapper .btn-clear-filter { color: #adb5bd; font-size: 18px; margin: 0 8px 0 5px; padding: 0; background: none; border: none; }
.filter-input-wrapper .btn-clear-filter:hover { color: #dc3545; }


/* ===================================================================
   3. Forms (General Styles)
   =================================================================== */
.form-layout { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 25px 20px; margin-top: 25px; }
.form-group { display: flex; flex-direction: column; }
.form-group label { font-weight: 600; margin-bottom: 6px; font-size: 14px; color: #495057; }
.form-group .required { color: #dc3545; margin-left: 3px; }

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="password"],
.form-group input[type="search"], /* Add search type */
.form-group select,
.form-group textarea { width: 100%; padding: 10px 14px; font-size: 14px; border: 1px solid #ced4da; border-radius: 4px; box-sizing: border-box; background-color: #fff; transition: border-color 0.2s, box-shadow 0.2s; }
.form-group input:focus,
.form-group input[type="search"]:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: #80bdff; box-shadow: 0 0 0 3px rgba(0,123,255,0.2); }
.form-group textarea { min-height: 100px; resize: vertical; }

fieldset.form-group { border: 1px solid #e9ecef; border-radius: 4px; padding: 15px 20px 20px 20px; margin-bottom: 0; }
fieldset.form-group legend { font-size: 14px; font-weight: 600; padding: 0 8px; margin-left: 5px; color: #495057; }
.spec-group { display: grid; grid-template-columns: 1fr 1fr 1fr 100px; gap: 10px; align-items: flex-end; }
.spec-group label { font-size: 12px; margin-bottom: 3px; color: #6c757d; }
.spec-group input { padding: 8px 10px; font-size: 13px; }


/* ===================================================================
   4. Page Header & Top Navigation (Unified Style)
   =================================================================== */
/* Used on manage_items.php, manage_areas.php, manage_standards.php etc. */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 15px;
}
/* Allow H1 or H2 */
.page-header h1, .page-header h2 { margin: 0; padding: 0; border: none; flex-shrink: 0; line-height: 1.3; font-weight: 600;}
.page-header h1 { font-size: 1.9em; }
.page-header h2 { font-size: 1.6em; } /* Slightly smaller for consistency */
.page-header h2 span { font-weight: normal; color: #007bff; }

.page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    font-size: 13px;
    color: #6c757d;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex-grow: 1;
}
.page-actions strong { color: #495057; }
.page-actions a { color: #007bff; text-decoration: none; font-weight: 500; margin: 0; }
.page-actions a:hover { color: #0056b3; }
.page-actions .btn { padding: 7px 14px; font-size: 13px; margin: 0; } /* Consistent button size in header */
.page-actions .btn-cancel { order: -1; } /* Keep return button visually first */
.page-actions span.separator { margin: 0 8px; color: #adb5bd; }
/* Area Select Form in Header */
.page-actions .area-select-form { display: flex; align-items: center; gap: 8px; margin: 0; }
.page-actions .area-select-form label { font-weight: 600; font-size: 13px; color: #495057; margin: 0; }
.page-actions .area-select-form select { padding: 6px 10px; font-size: 13px; border: 1px solid #ced4da; border-radius: 4px; background-color: #fff; max-width: 200px; }
.page-actions .area-select-form .change-link { font-size: 12px; margin-left: 5px; color: #6c757d; }
.page-actions .area-select-form .change-link:hover { color: #007bff; }
/* Save Action in Header (BOM) */
.page-actions .save-bom-action-header { display: flex; align-items: center; gap: 8px; }
.page-actions .save-indicator { display: none; font-style: italic; color: #6c757d; font-size: 0.9em; }
.page-actions #header-save-btn { /* Style save button using existing classes */ }
/* Save Result Message Area (Below Header) */
#header-save-result { margin-top: -10px; margin-bottom: 15px; text-align: right; min-height: 1.5em; font-weight: bold; font-size: 0.9em; }


/* ===================================================================
   5. Index Page Specific Layout (index.php)
   =================================================================== */
/* Header row */
.index-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 15px; }
.index-header h1 { margin: 0; border: none; padding: 0; flex-shrink: 0; }
.index-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.index-actions.admin-links a { font-size: 13px; font-weight: 500; color: #6c757d; }
.index-actions.admin-links a:hover { color: #007bff; }

/* Toolbar row */
.index-toolbar { display: flex; justify-content: space-between; align-items: center; background-color: #f8f9fa; padding: 15px; border: 1px solid #dee2e6; border-radius: 4px; margin-bottom: 25px; flex-wrap: wrap; gap: 20px; }
.index-toolbar .filter-nav { margin-bottom: 0; }
.index-toolbar .filter-form { margin: 0; }
/* Filter Nav (Tabs) */
.filter-nav { margin: 0; padding: 0; border: none; display: flex; flex-wrap: wrap;}
.filter-nav a { text-decoration: none; padding: 8px 16px; margin: 0 8px 10px 0; border-radius: 20px; background-color: #e9ecef; color: #495057; font-size: 13px; font-weight: 500; transition: all 0.2s; }
.filter-nav a:hover { background-color: #ced4da; }
.filter-nav a.active { background-color: #007bff; color: white; font-weight: 600;}
.filter-nav a[href*="filter=replaced"].active { background-color: #ffc107; color: #212529;}
/* Filter Dropdowns/Forms */
.filter-form { display: flex; align-items: center; margin: 0; }
.filter-form form { margin: 0; display: flex; align-items: center; }
.filter-form label { font-size: 14px; font-weight: 600; margin-right: 10px; white-space: nowrap; color: #495057;}
.filter-input-wrapper { display: flex; align-items: center; border: 1px solid #ced4da; border-radius: 4px; background-color: #fff; transition: border-color 0.2s, box-shadow 0.2s; }
.filter-input-wrapper:focus-within { border-color: #80bdff; box-shadow: 0 0 0 3px rgba(0,123,255,0.2); }
.filter-input-wrapper select { padding: 8px 12px; font-size: 14px; border: none; background-color: transparent; appearance: none; -webkit-appearance: none; -moz-appearance: none; flex-grow: 1; min-width: 180px; cursor: pointer; color: #495057;}
.filter-input-wrapper select:focus { outline: none; }

/* Index Page Table Styles */
.table-wrapper { overflow-x: auto; width: 100%; margin-top: 0; border: 1px solid #dee2e6; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,0.04); background-color: #fff; }
#procurement-table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: auto; }
#procurement-table th, #procurement-table td { border-bottom: 1px solid #e9ecef; padding: 12px 15px; text-align: left; white-space: nowrap; background-color: #fff; vertical-align: middle;}
#procurement-table th { background-color: #f8f9fa; font-weight: 600; position: sticky; top: 0; z-index: 10; border-bottom: 2px solid #dee2e6; color: #495057; text-transform: uppercase; font-size: 12px; letter-spacing: 0.5px;}
#procurement-table th.sticky-col, #procurement-table td.sticky-col { position: sticky; z-index: 11; background-color: #fff; }
#procurement-table .toggle-col { width: 50px; min-width: 50px; left: 0; z-index: 12 !important; text-align: center; border-right: 1px solid #dee2e6; }
#procurement-table .id-col { width: 65px; min-width: 65px; left: 50px; border-right: 1px solid #dee2e6;}
#procurement-table .name-col { min-width: 280px; left: 115px; border-right: 2px solid #ced4da; }
#procurement-table th.name-col { z-index: 12 !important; }
#procurement-table tbody tr:hover td { background-color: #f1f8ff !important; }
#procurement-table tbody tr.main-row:hover td.sticky-col { background-color: #eaf4ff !important; }
#procurement-table .notes-cell { white-space: normal; min-width: 180px; max-width: 300px; word-break: break-word; font-size: 13px; color: #6c757d;}
#procurement-table .price-cell { text-align: right; min-width: 130px; font-family: Consolas, "Courier New", monospace; font-weight: 500;}
#procurement-table .actions-cell { text-align: center; white-space: nowrap; }
#procurement-table tfoot tr { background-color: #e9ecef; border-top: 2px solid #adb5bd; }
#procurement-table tfoot td { padding: 12px 15px; font-weight: bold; font-size: 15px; }
#procurement-table tfoot td[colspan="3"] { color: #dc3545; font-size: 17px; } /* Adjust colspan */
#procurement-table .btn-toggle { font-family: monospace; font-weight: bold; font-size: 18px; padding: 0; width: 26px; height: 26px; line-height: 26px; text-align: center; border-radius: 50%; border: 1px solid #adb5bd; background-color: #fff; color: #6c757d; cursor: pointer; transition: all 0.2s;}
#procurement-table .btn-toggle:hover { background-color: #e9ecef; color: #007bff; border-color: #007bff;}
#procurement-table .details-row td { background-color: #fdfdfe; box-shadow: inset 0 3px 4px -2px rgba(0,0,0,0.06); border-bottom: 2px solid #007bff; padding: 0; }
#procurement-table .details-content { padding: 20px 25px 20px 130px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px 25px; }
#procurement-table .details-content .detail-item { font-size: 14px; line-height: 1.5; }
#procurement-table .details-content .detail-item strong { color: #6c757d; display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; margin-bottom: 4px; letter-spacing: 0.5px;}
#procurement-table .details-content .detail-item span { color: #343a40; white-space: pre-wrap; word-break: break-word; }
#procurement-table .row-obsolete td { background-color: #fffbeb !important; }
#procurement-table .row-replaced td { color: #adb5bd !important; text-decoration: line-through; background-color: #f8f9fa !important; }
#procurement-table .row-replaced .name-col .badge-secondary, #procurement-table .row-replaced .status-cell .badge-secondary { display: inline-block; padding: 3px 7px; font-size: 11px; font-weight: 600; color: #495057; background-color: #e9ecef; border: 1px solid #dee2e6; border-radius: 4px; margin-left: 8px; vertical-align: middle; text-decoration: none; }
#procurement-table .row-replaced .status-cell .badge-secondary { margin-left: 0; }
#procurement-table .name-col .badge { display: inline-block; padding: 3px 7px; font-size: 11px; font-weight: 600; border-radius: 4px; margin-left: 8px; vertical-align: middle; }
#procurement-table .badge-warning { color: #856404; background-color: #fff3cd; border: 1px solid #ffeeba; }
/* Quick Update Select in Index Table */
#procurement-table .quick-update-select { width: 130px; padding: 6px 8px; font-size: 13px; font-weight: 600; border-radius: 4px; color: inherit; border: 1px solid transparent; background-color: rgba(255,255,255,0.1); transition: all 0.2s; cursor: pointer;}
#procurement-table .quick-update-select:focus { border-color: #007bff; }
#procurement-table .status-cell select { background-color: #f8f9fa; border: 1px solid #dee2e6; }
#procurement-table .status-1 select { border-color: #f5c6cb; } #procurement-table .status-2 select, #procurement-table .status-3 select { border-color: #ffeeba; } #procurement-table .status-4 select, #procurement-table .status-5 select { border-color: #b8daff; } #procurement-table .status-6 select { border-color: #ffe8d1; } #procurement-table .status-7 select { border-color: #c3e6cb; } #procurement-table .status-0 select { border-color: #d6d8db; } #procurement-table .status-99 select { border-color: #d6d8db; text-decoration: line-through;}
/* Status text colors */
.status-1 { color: #dc3545; } .status-2, .status-3 { color: #ffc107; } .status-4, .status-5 { color: #007bff; } .status-6 { color: #fd7e14; } .status-7 { color: #28a745; } .status-0 { color: #6c757d; text-decoration: line-through; } .status-99 { color: #6c757d; text-decoration: line-through; }
/* Saving Indicator */
.saving-indicator { font-style: italic; color: #6c757d; font-size: 0.9em; margin-left: 5px; display: none; }


/* ===================================================================
   6. Management Pages (manage_items.php, manage_areas.php)
   =================================================================== */
.management-page { display: block; } /* Vertical layout */

.list-container { margin-top: 0; width: 100%; }
.list-container table { width: 100%; font-size: 14px; border-collapse: collapse; }
.list-container th { background-color: #f8f9fa; text-align: left;}
.list-container th, .list-container td { border: 1px solid #e9ecef; padding: 10px 12px; vertical-align: middle;}
.list-container th:last-child, .list-container td:last-child { width: 80px; text-align: center; white-space: nowrap; }

/* Filter container for manage_items.php */
.manage-items-filter-container { display: block; padding: 15px 20px; margin-bottom: 25px; background-color: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px; position: relative; z-index: 1; }
.category-filter-container { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 15px; }
.category-filter-container label { font-weight: 600; font-size: 14px; white-space: nowrap; margin-top: 5px; color: #495057; flex-shrink: 0; }
.category-filter-buttons { display: flex; flex-wrap: wrap; gap: 8px; flex-grow: 1; }
.filter-btn { display: inline-block; padding: 6px 14px; font-size: 13px; font-weight: 500; color: #495057; background-color: #e9ecef; border: 1px solid #ced4da; border-radius: 15px; text-decoration: none; transition: all 0.2s ease-in-out; white-space: nowrap; cursor: pointer; }
.filter-btn:hover { background-color: #ced4da; border-color: #adb5bd; color: #343a40; }
.filter-btn.active { background-color: #007bff; color: white; border-color: #007bff; font-weight: 600; }
.status-filter-container { display: flex; align-items: center; gap: 10px; margin-top: 15px; }
.status-filter-container label { font-weight: 600; font-size: 14px; white-space: nowrap; color: #495057; flex-shrink: 0; }
.status-filter-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

/* List Header (Title + Add Button) */
.list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; flex-wrap: wrap; gap: 10px; }
.list-header h3 { margin: 0; border: none; padding: 0; flex-grow: 1; }
.list-header h3 small { margin-left: 8px; font-weight: normal; color: #6c757d; }
.list-header .btn-add { margin: 0; flex-shrink: 0; }

/* Inline Edit Styles */
.list-container td.editable-cell { cursor: text; transition: background-color 0.2s ease-in-out; }
.list-container td.editable-cell:hover { background-color: #e6f7ff; }
input.inline-edit-input, select.inline-edit-input { width: 95%; padding: 2px; margin: 0; box-sizing: border-box; border: 1px solid #007bff; border-radius: 3px; box-shadow: 0 0 3px rgba(0, 123, 255, 0.5); outline: none;}
td.editable-cell select.inline-edit-input { padding: 3px 5px; }
td.saving { color: #adb5bd; font-style: italic; background-color: #f8f9fa; }

/* Column widths for manage_items list */
.list-container th.col-category { min-width: 160px; }
.list-container th.col-item-name { min-width: 220px; width: 28%;}
.list-container th.col-spec-lwh { min-width: 130px; }
.list-container th.col-spec-unit { width: 80px; }
.list-container th.col-spec-other { min-width: 220px; width: 28%; }
.list-container th.col-status { width: 85px; text-align: center;}
.list-container th.col-actions { width: 80px; }

/* Action link styles */
.action-link { font-size: 13px; text-decoration: none; margin: 0 5px; font-weight: 600; }
.edit-link { color: #007bff; } .edit-link:hover { color: #0056b3; }
.delete-link { color: #dc3545; } .delete-link:hover { color: #a71d2a; }


/* ===================================================================
   7. Modal Dialog Styles (for Add Forms)
   =================================================================== */
.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.5); animation: fadeIn 0.3s ease-out; }
.modal-content { background-color: #fefefe; margin: 8% auto; padding: 0; border: 1px solid #ccc; width: 90%; max-width: 700px; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.2); animation: slideIn 0.3s ease-out; display: flex; flex-direction: column; }
.modal-header { padding: 15px 25px; background-color: #e9ecef; border-bottom: 1px solid #dee2e6; border-radius: 7px 7px 0 0; display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { margin: 0; font-size: 1.5em; color: #343a40; }
.close-button { color: #6c757d; font-size: 28px; font-weight: bold; background: none; border: none; cursor: pointer; padding: 0 5px; line-height: 1; transition: color 0.2s; }
.close-button:hover, .close-button:focus { color: #dc3545; text-decoration: none; outline: none; }
.modal-body { padding: 25px 30px; overflow-y: auto; flex-grow: 1; }
.modal-body .form-layout { margin-top: 0; }
.modal-body .btn-cancel { margin-left: 10px; }
@keyframes fadeIn { from {opacity: 0;} to {opacity: 1;} }
@keyframes slideIn { from {transform: translateY(-30px); opacity: 0;} to {transform: translateY(0); opacity: 1;} }


/* ===================================================================
   8. BOM Editor Styles (manage_standards.php - Final)
   =================================================================== */
/* BOM Page Header */
.bom-page-header { gap: 10px 25px; } /* Adjust gap */
.bom-header-title { font-size: 1.6em; }
.bom-header-title span { font-weight: normal; color: #007bff; }
/* BOM Editor Layout */
.bom-editor-layout { display: grid; grid-template-columns: minmax(400px, 1.5fr) 2fr; gap: 30px; margin-top: 0; align-items: start; }
.panel { border: 1px solid #dee2e6; border-radius: 6px; background-color: #fff; padding: 20px; display: flex; flex-direction: column; box-shadow: 0 2px 4px rgba(0,0,0,0.04); max-height: 70vh; overflow-y: auto; }
.panel .panel-header { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid #e9ecef; flex-shrink: 0; }
.panel .panel-header h3 { margin: 0; border: none; padding: 0; font-size: 1.2em; color: #343a40; flex-grow: 1; }
.panel .panel-header .search-filter { flex-grow: 1; min-width: 180px; max-width: 300px; flex-shrink: 1;}
.panel-content { display: flex; flex-direction: column; flex-grow: 1; overflow: hidden; }

/* Left Panel: Available Items */
.available-filters { margin-bottom: 15px; flex-shrink: 0; border-bottom: 1px solid #e9ecef; padding-bottom: 15px; }
.category-filter-buttons-bom { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 5px; max-height: 115px; /* ~4 rows */ overflow-y: auto; padding-right: 5px; scrollbar-width: thin; scrollbar-color: #ced4da #f8f9fa; }
.category-filter-buttons-bom::-webkit-scrollbar { width: 6px; } .category-filter-buttons-bom::-webkit-scrollbar-track { background: #f8f9fa; border-radius: 3px;} .category-filter-buttons-bom::-webkit-scrollbar-thumb { background-color: #ced4da; border-radius: 3px; border: 1px solid #f8f9fa;}
.filter-btn-sm { display: inline-block; padding: 4px 10px; font-size: 12px; font-weight: 500; color: #495057; background-color: #e9ecef; border: 1px solid #ced4da; border-radius: 12px; text-decoration: none; transition: all 0.2s; white-space: nowrap; cursor: pointer; flex-shrink: 0; }
.filter-btn-sm:hover { background-color: #ced4da; border-color: #adb5bd; color: #343a40; }
.filter-btn-sm.active { background-color: #007bff; color: white; border-color: #007bff; font-weight: 600; }
.filter-btn-sm.dimmed { opacity: 0.6; background-color: #f8f9fa; border-color: #e9ecef; }
.filter-btn-sm.dimmed:hover { opacity: 1; background-color: #ced4da; border-color: #adb5bd; }
.available-items-panel .item-list { overflow-y: auto; flex-grow: 1; list-style: none; padding: 5px; margin: 10px -5px -5px -5px; border: none; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }
.available-items-panel .item-list li { display: block; padding: 8px 12px; background-color: #f8f9fa; border: 1px solid #e9ecef; border-radius: 4px; cursor: pointer; transition: all 0.2s ease-in-out; flex-basis: auto; width: auto; border-bottom: none; }
.available-items-panel .item-list li:hover { background-color: #e2e6ea; border-color: #adb5bd; transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.available-items-panel .item-list li .item-info { margin: 0; pointer-events: none;} .available-items-panel .item-list li .item-info .name { font-weight: 500; font-size: 13px; white-space: normal; } .available-items-panel .item-list li .item-info .specs { font-size: 11px; color: #6c757d; margin-top: 3px; line-height: 1.2; white-space: normal; } .available-items-panel .item-list li .item-actions { display: none; } .available-items-panel .item-list li:last-child { border-bottom: none; } .available-items-panel .item-list li[style*="text-align: center"] { width: 100%; background: none; border: none; box-shadow: none; cursor: default; }

/* Right Panel: Selected Items */
.selected-items-panel h3 { justify-content: flex-start; } /* Title on left */
.selected-items-panel .item-list { overflow-y: auto; flex-grow: 1; list-style: none; padding: 10px; margin: 0 -10px -10px -10px; border: none; display: grid; grid-template-columns: repeat(3, 1fr); /* Force 3 columns */ gap: 15px; align-content: flex-start; }
.selected-items-panel .item-list li.clickable-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; background-color: #fff; border: 1px solid #dee2e6; border-radius: 5px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); cursor: pointer; transition: all 0.2s ease-in-out; border-bottom: none; }
.selected-items-panel .item-list li.clickable-item:hover { border-color: #adb5bd; transform: translateY(-1px); box-shadow: 0 3px 6px rgba(0,0,0,0.06); }
.selected-items-panel .item-list li .item-info { margin: 0; pointer-events: none; overflow: hidden; flex-grow: 1; padding-right: 10px; }
.selected-items-panel .item-list li .item-info .name { font-weight: 600; font-size: 14px; white-space: normal; color: #343a40; line-height: 1.3; margin-bottom: 4px; }
.selected-items-panel .item-list li .item-info .specs { font-size: 12px; color: #6c757d; line-height: 1.3; white-space: normal; }
.selected-items-panel .item-list li .item-actions { display: block; margin: 0; padding: 0; border: none; flex-shrink: 0; }
.selected-items-panel .item-list li .item-actions .quantity-input { width: 75px; padding: 6px 8px; font-size: 15px; font-weight: bold; text-align: center; border: 1px solid #ced4da; border-radius: 4px; margin: 0; cursor: text; }
.selected-items-panel .item-list li .item-actions .quantity-input:focus { border-color: #80bdff; box-shadow: 0 0 0 3px rgba(0,123,255,0.2); outline: none; }
.selected-items-panel .item-list li[style*="text-align: center"] { display: block; grid-column: 1 / -1; background: none; border: none; box-shadow: none; cursor: default; }

/* Removed Bottom Save Button Container */
.save-button-container { display: none; }


/* ===================================================================
   9. Responsive Layout (@media Queries)
   =================================================================== */
@media (max-width: 1200px) {
     /* Switch BOM selected cards to 2 columns earlier */
    .selected-items-panel .item-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 992px) {
    .container { padding: 20px; }
    .page-header { padding-bottom: 10px; margin-bottom: 15px; }
    .page-actions { gap: 8px; }
    /* Stack BOM editor */
    .bom-editor-layout { grid-template-columns: 1fr; }
    .panel { max-height: none; overflow-y: visible; }
    /* Keep 2 columns for selected cards on medium screens */
    .selected-items-panel .item-list { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (max-width: 768px) {
    body { padding: 10px; font-size: 14px; }
    .container { padding: 15px; width: 100%; min-width: 100%; max-width: 100%; margin: 10px auto; }
    h1 { font-size: 1.6em; margin-bottom: 20px;}

    /* Stack Page Header */
    .page-header { flex-direction: column; align-items: stretch; text-align: center; }
    .page-actions { justify-content: center; }
    .page-actions .area-select-form { flex-direction: column; align-items: stretch; gap: 5px; width: 100%; margin-top: 10px;}
    .page-actions .area-select-form select { max-width: none; }

    /* Management page layout */
    .management-page { gap: 20px;}
    .list-container { max-height: none; min-width: 100%;}
    .form-container { min-width: 100%; }
    .list-header { flex-direction: column; align-items: stretch; text-align: center; }
    .list-header h3 { margin-bottom: 10px; }

    /* Filter adjustments for mobile */
    .manage-items-filter-container { padding: 10px 15px; }
    .category-filter-container { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 10px; }
    .category-filter-container label { margin-top: 0; margin-bottom: 5px; }
    .status-filter-container { flex-direction: column; align-items: stretch; gap: 8px; margin-top: 10px; }
    .status-filter-container label { margin-top: 0; margin-bottom: 5px; }
    .filter-btn { padding: 5px 12px; font-size: 12px; }

    /* index.php layout on mobile */
    .index-header { flex-direction: column; align-items: stretch; text-align: center; }
    .index-actions { justify-content: center; }
    .index-toolbar { flex-direction: column; align-items: stretch; gap: 15px; }
    .index-toolbar .filter-nav { justify-content: center; }
    .index-toolbar .filter-form form { flex-direction: column; align-items: stretch; }
    .index-toolbar .filter-form label { margin-bottom: 5px; }
    .index-toolbar .filter-input-wrapper { width: 100%; }
    .index-toolbar .btn-clear-filter { align-self: flex-end; margin-top: -38px; margin-right: 5px; z-index: 5;}

    /* Table adjustments for mobile */
    #procurement-table th, #procurement-table td { padding: 8px 10px; font-size: 13px; white-space: normal; }
    #procurement-table th { font-size: 11px; white-space: nowrap; }
    #procurement-table th.sticky-col, #procurement-table td.sticky-col { position: static; left: auto; border-right: none; }
    #procurement-table .name-col { min-width: 120px; border-right: none; }
    #procurement-table .details-content { padding-left: 20px; grid-template-columns: 1fr; gap: 10px; }
    #procurement-table .btn-toggle { display: none; }
    #procurement-table .details-row { display: none !important; }
    #procurement-table .actions-cell { white-space: normal; }
    #procurement-table .actions-cell .btn-sm { padding: 5px 8px; font-size: 11px; margin-bottom: 3px; }
    #procurement-table .price-cell { min-width: 80px; }
    #procurement-table tfoot td { font-size: 14px; }
    #procurement-table tfoot td[colspan="3"] { font-size: 15px; }

    /* BOM Editor on mobile */
    .panel .panel-header { flex-direction: column; align-items: stretch; } /* Stack title/search */
    .panel .panel-header .search-filter { max-width: none; margin-top: 10px; }
    .available-filters { flex-direction: column; align-items: stretch; }
    .category-filter-buttons-bom { justify-content: flex-start; max-height: 100px; /* Allow slightly more height */ }
    .selected-items-panel .item-list { grid-template-columns: 1fr; } /* Single column cards */

    /* Modal on mobile */
    .modal-content { margin: 5% auto; width: 95%; }
    .modal-header h2 { font-size: 1.3em; }
    .modal-body { padding: 20px; }
}
/* --- 样式修复：将用户信息栏移动到右上角 --- */
body {
    position: relative; /* 关键：使其成为 .user-info-bar 的定位父级 */
    padding-top: 10px;  /* 给顶部留一点空间 */
}

.user-info-bar {
    position: absolute; /* 绝对定位 */
    top: 15px;          /* 距离顶部15px */
    right: 20px;         /* 距离右侧20px */
    
    /* 覆盖原有样式 */
    padding: 0;
    margin-bottom: 0;
    border: none;
    background: none;
    text-align: right;
    font-size: 14px;
    z-index: 99; /* 确保它在最上层 */
}

/* 调整主要内容容器的上边距，避免和用户信息栏离得太近 */
.container {
    padding-top: 30px; 
}
/* --- 修复结束 --- */