:root {
    --sidebar-width: 220px; --border-color: #dee2e6; --background-color: #f8f9fa;
    --text-color: #212529; --primary-color: #0d6efd; --hover-color: #e9ecef;
    --danger-color: #dc3545; --danger-hover-color: #bb2d3b;
    --success-color: #198754; --success-hover-color: #157347;
    --warning-color: #fd7e14; --error-color: #dc3545;
    --card-bg: #ffffff;
    --card-shadow: 0 2px 4px rgba(0,0,0,0.05);
    --input-bg: #fff;
    --btn-secondary-bg: #6c757d;
}
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif; margin: 0; display: flex; height: 100vh; background-color: var(--background-color); color: var(--text-color); }
.sidebar { 
    width: var(--sidebar-width); 
    background-color: var(--card-bg); 
    border-right: 1px solid var(--border-color); 
    padding: 20px; 
    box-sizing: border-box; 
    flex-shrink: 0; 
    display: flex;
    flex-direction: column;
}
.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}
#user-info {
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: #6c757d;
    word-break: break-all;
}
#logout-btn {
    width: 100%;
}
.sidebar h2 { font-size: 1.5rem; margin-top: 0; }
.sidebar nav ul { list-style-type: none; padding: 0; margin: 0; }
.sidebar nav li {
    margin: 5px 0;
    border-radius: 6px;
    font-weight: 500;
}

.sidebar nav li[data-view] {
    padding: 12px 15px;
    cursor: pointer;
}

.sidebar nav li[data-view]:hover, .sidebar nav li[data-view].active {
    background-color: var(--hover-color);
}


.main-content { flex-grow: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; }
.view-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }
.view-header h1 { border-bottom: none; padding-bottom: 0; }
.header-actions { display: flex; gap: 10px; }

button { background-color: var(--primary-color); color: white; border: none; padding: 8px 16px; font-size: 1rem; border-radius: 6px; cursor: pointer; transition: background-color 0.15s ease-in-out; }
button:hover { background-color: #0b5ed7; }
button:disabled { background-color: #6c757d; cursor: not-allowed; }
.btn-secondary { background-color: var(--btn-secondary-bg); }
.btn-secondary:hover { background-color: #5c636a; }
.btn-danger { background-color: var(--danger-color); }
.btn-danger:hover { background-color: var(--danger-hover-color); }
.btn-primary { background-color: var(--primary-color); }
.btn-primary:hover { background-color: #0b5ed7; }

.tabulator-cell .btn-small {
    padding: 4px 10px;
    font-size: 0.8rem;
    background-color: var(--btn-secondary-bg);
}
.tabulator-cell .btn-small:hover {
    background-color: #5c636a;
}


.icon-btn { background: none; border: none; cursor: pointer; padding: 4px; border-radius: 50%; line-height: 0; }
.icon-btn svg { 
    width: 18px; 
    height: 18px; 
    vertical-align: middle;
    stroke: var(--primary-color);
}
.icon-btn:hover { background-color: var(--hover-color); }
.icon-btn:hover svg { stroke: var(--text-color); }

.icon-btn:disabled {
    background: none !important;
    cursor: not-allowed;
}
.icon-btn:disabled svg {
    stroke: #adb5bd;
}


dialog { border: 1px solid #ccc; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); padding: 0; max-width: 90vw; width: 800px; }
dialog.modal-large { width: 1200px; }
dialog::backdrop { background-color: rgba(0, 0, 0, 0.5); }
.modal-header { padding: 15px 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto;}
.modal-footer { padding: 15px 20px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }
.modal-section { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border-color); }
.modal-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.subtle-text { font-size: 0.9rem; color: #6c757d; margin-top: -10px; }


.table-container {
    overflow-x: auto;
    width: 100%;
}
.details-table { 
    width: 100%; 
    min-width: 1200px; 
    border-collapse: collapse; 
    margin-top: 10px; 
    margin-bottom: 20px; 
}
.details-table th, .details-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border-color); vertical-align: middle; white-space: nowrap; }
.details-table th { font-weight: 600; }

.details-table th:nth-child(1), .details-table td:nth-child(1) { width: 60px;  min-width: 60px; }
.details-table th:nth-child(2), .details-table td:nth-child(2) { width: 90px;  min-width: 90px; }
.details-table th:nth-child(3), .details-table td:nth-child(3) { width: 100px; min-width: 100px; }
.details-table th:nth-child(4), .details-table td:nth-child(4) { width: 110px; min-width: 110px; }
.details-table th:nth-child(5), .details-table td:nth-child(5) { width: 350px; min-width: 350px; }
.details-table th:nth-child(6), .details-table td:nth-child(6) { width: 150px; min-width: 150px; }
.details-table th:nth-child(7), .details-table td:nth-child(7) { width: 100px; min-width: 100px; }
.details-table th:nth-child(8), .details-table td:nth-child(8) { width: 120px; min-width: 120px; }
.details-table th:nth-child(9), .details-table td:nth-child(9) { width: 150px; min-width: 150px; }


.modal-section-divider { border-top: 2px solid var(--hover-color); margin: 20px 0; }

.items-header { display: flex; justify-content: space-between; align-items: center; }
.items-header h3 { margin: 0; }

.summary-form .summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px 25px;
    align-items: start;
}
.summary-form .notes-group { grid-column: 1 / 2; }
.summary-form .cost-group { grid-column: 2 / 3; }
.summary-form .notes-group textarea { height: 120px; resize: vertical; }

.cost-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px 10px;
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
}
.cost-grid label { font-weight: 500; text-align: right; }
.cost-grid .total-label { font-weight: bold; border-top: 1px solid #ccc; padding-top: 8px; margin-top: 5px; grid-column: 1 / 2; }
.cost-grid .total-value { font-weight: bold; border-top: 1px solid #ccc; padding-top: 8px; margin-top: 5px; grid-column: 2 / 3; background-color: #e9ecef !important; }

.inline-edit-input, .inline-edit-select { width: 100%; box-sizing: border-box; }


.form-group { margin-bottom: 15px; } .form-group label { display: block; margin-bottom: 5px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 8px; box-sizing: border-box; border: 1px solid #ccc; border-radius: 4px; background-color: var(--input-bg); }
.form-group-checkbox { display: flex; align-items: center; gap: 10px; } .form-group-checkbox input { width: auto; } .form-group-checkbox label { margin-bottom: 0; font-weight: normal; }
.details-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 20px; margin-bottom: 15px;}
.grid-col-span-2 { grid-column: span 2; }
.grid-col-span-3 { grid-column: span 3; }
.color-selector-container { display: flex; align-items: center; gap: 10px; }
select { -webkit-appearance: none; -moz-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right .75rem center; background-size: 16px 12px; padding-right: 2.5rem; }
.color-swatch { width: 36px; height: 36px; border: 1px solid #ccc; border-radius: 4px; flex-shrink: 0; }
input[list] {
    padding-right: 35px !important;
}
#modal-item-color {
    text-overflow: ellipsis;
}

#purchases-table, #item-catalog-table { margin-top: 20px; background-color: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; }
.tabulator { border: none; }
.tabulator .tabulator-header { background-color: transparent; border-bottom: 1px solid var(--border-color); }
.tabulator .tabulator-header .tabulator-col { background-color: transparent; font-weight: 600; border-right: 1px solid var(--border-color); }
.tabulator .tabulator-header .tabulator-col:last-of-type { border-right: none; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-header-filter { margin-top: 5px; width: 100%; box-sizing: border-box; }
.tabulator .tabulator-row { border-bottom: 1px solid var(--border-color); }
.tabulator .tabulator-row:hover { background-color: var(--hover-color); }
.tabulator-row {
    position: relative;
    z-index: 10;
}

.tabulator-cell a.table-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}
.tabulator-cell a.table-link:hover {
    text-decoration: underline;
}

.pagination-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 8px 0;
    gap: 8px;
}
/* General style for pagination buttons and custom controls */
.pagination-btn, .tabulator-paginator button {
    background-color: transparent;
    color: var(--primary-color);
    border: none;
    padding: 5px 12px;
    font-size: 0.9rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

/* Hover effect for clickable buttons */
.pagination-btn:not(:disabled):hover, 
.tabulator-paginator button:not(:disabled):not(.active):hover {
    background-color: var(--hover-color);
}

/* Disabled state for buttons */
.pagination-btn:disabled, .tabulator-paginator button:disabled {
    color: #adb5bd; /* Muted color for disabled state */
    cursor: not-allowed;
    background-color: transparent;
}

/* Style for the active page number button */
.tabulator .tabulator-paginator .tabulator-page.active {
    font-weight: bold;
    cursor: default;
}

/* Style for the "Page X of Y" text display */
.page-counter, .tabulator-paginator .tabulator-page-counter {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--primary-color);
    padding: 0 10px;
}

.identification-page-container { display: flex; gap: 20px; flex-grow: 1;  min-height: 0; }
.identify-part-section, .manual-review-section { background-color: var(--card-bg); padding: 20px; border-radius: 8px; box-shadow: var(--card-shadow); display: flex; flex-direction: column; }
.identify-part-section { flex: 2; }
.manual-review-section { flex: 3; }
.mode-selection { display: flex; gap: 10px; margin-bottom: 20px; border-bottom: 1px solid var(--border-color); padding-bottom: 20px; }
.mode-selection button { flex-grow: 1; background-color: var(--btn-secondary-bg); }
.mode-selection button.active { background-color: var(--primary-color); }

.run-configuration { border: 1px solid var(--border-color); border-radius: 6px; padding: 15px; margin-bottom: 20px; }
.run-configuration h3 { margin-top: 0; font-size: 1.1rem; border-bottom: 1px solid #ccc; padding-bottom: 10px; margin-bottom: 15px; }
.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }

.mode-ui-placeholder { flex-grow: 1; border: 2px dashed var(--border-color); border-radius: 6px; display: flex; flex-direction: column; justify-content: center; align-items: center; color: #6c757d; font-size: 1.2rem; text-align: center; padding: 20px; }
#start-identification-btn { padding: 12px; font-size: 1.2rem; font-weight: bold; background-color: var(--success-color); }
#start-identification-btn:hover { background-color: var(--success-hover-color); }

.live-capture-container { display: flex; flex-direction: column; align-items: center; gap: 15px; width: 100%; height: 100%; }
#camera-feed { width: 100%; max-width: 500px; height: auto; background-color: #000; border: 1px solid var(--border-color); border-radius: 6px; }
#capture-btn { padding: 10px 20px; font-size: 1rem; font-weight: bold; }

.manual-review-section { display: flex; flex-direction: column; gap: 20px; }
#review-top-pane { flex-shrink: 0; display: flex; gap: 20px; justify-content: space-around; padding-bottom: 20px; border-bottom: 1px solid var(--border-color); }
.review-image-holder { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px; border: 1px solid var(--border-color); border-radius: 6px; background-color: var(--background-color); }
.review-image-holder h4 { margin: 0; font-size: 0.9rem; color: #555; }
.image-box { width: 150px; height: 150px; display: flex; justify-content: center; align-items: center; cursor: pointer; }
.image-box img { max-width: 100%; max-height: 100%; object-fit: contain; }

#review-bottom-pane {
    flex-grow: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.review-scroll-wrapper {
    height: 100%;
    overflow-y: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

#review-table {
    border: none;
    margin-bottom: 15px;
}

.match-buttons-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap; 
}
.match-button {
    flex-grow: 1;
    background-color: var(--btn-secondary-bg);
    color: white;
    border: none;
    padding: 8px 12px;
    font-size: 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}
.match-button:hover {
    background-color: #5c636a;
}
.match-button.active {
    background-color: var(--primary-color);
}
#review-edit-form {
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}
#review-edit-form h4 { margin-top: 0; margin-bottom: 15px; }

#large-image-modal .modal-body {
    display: flex;
    justify-content: center;
    align-items: center;
}
#large-image-modal .image-box-large {
    width: auto;
    height: auto;
    max-width: 90vw;
    max-height: 80vh;
    border: none;
}
#large-image-modal .image-box-large img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}


.collapsible-header {
    padding: 12px 15px;
    cursor: pointer;
    border-radius: 6px;
}

.collapsible-header:hover {
    background-color: var(--hover-color);
}

.collapsible-content {
    list-style-type: none;
    padding: 5px;
    margin-top: 2px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease-out;
    background-color: #f0f2f5;
    border-radius: 6px;
}

.collapsible-content li {
    font-size: 0.9rem;
    font-weight: 400; 
    cursor: pointer;
    padding: 8px 15px 8px 25px; 
    margin: 0;
    border-radius: 4px;
}

.collapsible-content li:hover, .collapsible-content li.active {
    background-color: var(--hover-color);
}

.data-management-container {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
}

.template-section, .upload-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.form-group-inline {
    display: flex;
    align-items: center;
    gap: 15px;
}

#table-select-dropdown {
    min-width: 250px;
}

.collapsible-section {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 15px;
}
.collapsible-section summary {
    cursor: pointer;
    padding: 10px 15px;
    font-weight: 600;
    background-color: var(--hover-color);
}
.collapsible-section .section-content {
    padding: 15px;
}
.item-summary-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 20px;
    align-items: start;
}
.image-box-large {
    width: 200px;
    height: 200px;
    border: 1px solid var(--border-color);
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}
.image-box-large img {
    max-width: 100%;
    max-height: 100%;
}
.item-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
}
.info-item label {
    font-weight: 600;
    margin-right: 8px;
}
.item-relations-grid {
    grid-column: 2 / 3;
    display: flex;
    gap: 30px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}
.relation-item label {
    font-weight: 600;
    margin-right: 8px;
}
#modal-purchases-table, #modal-sales-table {
    height: 200px;
}

.breadcrumb-container {
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: #6c757d;
}

.breadcrumb-container a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.breadcrumb-container a:hover {
    text-decoration: underline;
}

/* --- Tab Navigation Styles --- */
.tab-navigation {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}
.tab-link {
    padding: 10px 20px;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
    background-color: #f8f9fa; 
    color: #495057; 
    margin-bottom: -1px; 
    font-size: 1rem;
    font-weight: 500;
    border-radius: 6px 6px 0 0;
}

.tab-link:hover {
    background-color: #e9ecef;
    color: #212529;
}

.tab-link.active {
    color: var(--primary-color);
    background-color: var(--card-bg);
    border-color: var(--border-color) var(--border-color) var(--card-bg) var(--border-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* --- Dashboard Styles --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    padding-top: 10px;
}

.dashboard-widget {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--card-shadow);
}

.dashboard-widget h4 {
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    font-size: 1.1rem;
}

.metric-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f3f5;
}

.metric-item:last-child {
    border-bottom: none;
}

.metric-value {
    font-weight: 600;
    font-size: 1.1rem;
    background-color: var(--hover-color);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--primary-color);
}

/* NEW: Styles for the "Add Item" modals */
.add-item-summary-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 20px;
}
.add-item-fields {
    display: flex;
    flex-direction: column;
}
#add-staged-item-name, #add-listed-item-name {
    font-weight: bold;
    min-height: 1.2em;
}

/* (add to the end of style.css) */
.image-uploader {
    flex-direction: column;
    gap: 10px;
    background-color: #f8f9fa;
    color: #6c757d;
    border-style: dashed;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.image-uploader:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}
.image-uploader svg {
    stroke: #6c757d;
}

/* --- Add these styles to the end of public/css/style.css --- */

.inline-table-select, .inline-table-input {
    width: 100%;
    box-sizing: border-box;
    padding: 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem; /* Match general table font size */
    background-color: var(--input-bg);
}

/* Specific adjustments for number inputs */
.inline-table-input[type="number"] {
    max-width: 100px; /* Keep number inputs from becoming excessively wide */
}

/* Ensure select dropdowns in tables work with standard appearance */
.tabulator .inline-table-select {
    appearance: auto;
    background-image: none;
    padding-right: 4px;
}