/* Purchase Register Standard Styling */

/* Reset and Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f5f5;
    margin: 0;
    padding: 0;
}

/* Container */
.container {
    max-width: 98%;
    margin: 20px auto;
    padding: 0 15px;
}

/* Card styling */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.card-header {
    padding: 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.card-header h1,
.card-header h2,
.card-header h3 {
    margin: 0;
    color: #333;
    font-size: 24px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.card-body {
    padding: 20px;
}

/* Filter and Search Section */
.filters-section {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
}

.search-section {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

.filter-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.main-search {
    margin-bottom: 15px;
}

/* Search Row */
.search-row {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: nowrap;
}

.search-row .form-input,
.search-row .form-control {
    flex: 1;
    min-width: 180px;
}

.search-row .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.search-input-container {
    position: relative;
    flex: 2;
    min-width: 250px;
}

.search-input {
    width: 100%;
    max-width: 400px;
    padding: 8px 0;
    border: none;
    border-bottom: 2px solid #ccc;
    background: transparent;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #333;
}

.search-input:focus {
    border-bottom-color: #8B0000;
}

.search-input:hover {
    border-bottom-color: #888;
}

.search-input::placeholder {
    color: #999;
}

/* Form Styling */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 8px 0;
    border: none;
    border-bottom: 2px solid #ccc;
    background: transparent;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #333;
}

.form-control:focus {
    border-bottom-color: #8B0000;
}

.form-control:hover {
    border-bottom-color: #888;
}

/* Form Input - Underline Style */
.form-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 2px solid #ccc;
    padding: 8px 0;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #333;
    outline: none;
    transition: border-bottom-color 0.3s ease;
}

.form-input:focus {
    border-bottom-color: #8B0000;
}

.form-input:hover {
    border-bottom-color: #888;
}

.form-input::placeholder {
    color: #999;
}

.form-help {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #666;
}

.form-control.is-invalid {
    border-color: #dc3545;
}

.invalid-feedback {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #dc3545;
}

/* Form Row */
.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
    min-width: 150px;
}

.form-row .form-control,
.form-row .form-input {
    flex: 1;
    min-width: 150px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    text-align: center;
    transition: all 0.3s ease;
    font-weight: 500;
    white-space: nowrap;
    display: inline-block;
    line-height: 1.4;
}

.btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 15px 30px;
    font-size: 16px;
}

.btn-primary {
    background-color: #8B0000;
    color: white;
}

.btn-primary:hover {
    background-color: #DAA520;
    color: #000000;
}

.btn-secondary {
    background-color: #DAA520;
    color: #000000;
}

.btn-secondary:hover {
    background-color: #8B0000;
    color: white;
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-info:hover {
    background-color: #138496;
}

.btn-warning {
    background-color: #DAA520;
    color: #212529;
}

.btn-warning:hover {
    background-color: #DAA520;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-mustard {
    background-color: #DAA520;
    color: white;
}

.btn-mustard:hover {
    background-color: #DAA520;
}

.btn-outline {
    background-color: transparent;
    color: #8B0000;
    border: 1px solid #8B0000;
}

.btn-outline:hover {
    background-color: #8B0000;
    color: white;
}

.btn.active {
    background-color: #8B0000;
    color: white;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    margin-bottom: 20px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    font-size: 13px;
    margin-bottom: 0;
}

.table thead {
    background-color: #f8f9fa;
}

.table th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    white-space: nowrap;
}

.table th:last-child {
    border-right: none;
}

.table td {
    padding: 10px 8px;
    border-bottom: 1px solid #eee;
    border-right: 1px solid #eee;
    vertical-align: top;
}

.table td:last-child {
    border-right: none;
}

.table tbody tr:hover {
    background-color: #f5f5f5;
}

.table tbody tr {
    transition: all 0.2s ease;
}

/* Expandable rows */
.expandable {
    cursor: pointer;
}

.expandable:hover {
    background-color: #f8f9fa;
}

/* Status badges */
.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.status-approved {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #b8daff;
}

.status-rejected {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f1b0b7;
}

.status-completed {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* Additional Status Classes */
.status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

.status-valid {
    background-color: #d4edda;
    color: #155724;
}

.status-warning {
    background-color: #fff3cd;
    color: #856404;
}

.status-error {
    background-color: #f8d7da;
    color: #721c24;
}

/* Common UI Elements */
.requirements-list {
    margin: 15px 0;
    padding-left: 25px;
}

.requirements-list li {
    margin: 8px 0;
    color: #555;
}

.sample-download {
    padding: 15px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    margin: 15px 0;
}

/* Search row styling */
.search-row th {
    padding: 8px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    position: sticky;
    top: 48px;
    z-index: 9;
}

/* Column Search Inputs */
.column-search {
    width: 100%;
    padding: 6px 8px;
    border: none;
    border-bottom: 1px solid #ddd;
    background: transparent;
    font-size: 12px;
    outline: none;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
    display: block;
}

/* Table-specific column search */
.report-table .column-search {
    width: calc(100% - 20px);
    padding: 4px 6px;
    font-size: 11px;
    min-height: 24px;
    border: 1px solid #ddd;
    border-radius: 2px;
    background: white;
}

.report-table .column-search:focus {
    border-color: #8B0000;
    background: #fff;
}

.column-search:focus {
    border-bottom-color: #DAA520;
}

.column-search::placeholder {
    color: #999;
}

/* Search Controls */
.search-controls {
    position: relative;
    display: block;
    width: 100%;
    box-sizing: border-box;
}

/* Table-specific search controls */
.report-table .search-controls {
    display: block;
    width: 100%;
    min-height: 32px;
}

.report-table .search-row th {
    padding: 8px 4px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    position: sticky;
    top: 48px;
    z-index: 9;
    vertical-align: top;
}

.report-table .search-row .search-controls {
    display: block;
    width: 100%;
    position: relative;
}

.clear-search {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    width: 16px;
    height: 16px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Table-specific clear search button */
.report-table .clear-search {
    right: 2px;
    width: 14px;
    height: 14px;
    font-size: 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 2px;
}

.clear-search:hover {
    color: #8B0000;
}

.clear-search.show {
    display: flex;
}

/* Clear Search Button - Like Purchase Orders */
.clear-search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-search-btn:hover {
    color: #000;
}

/* Real-time search loading states */
.search-loading {
    position: relative;
}

.search-loading::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #8B0000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: translateY(-50%) rotate(0deg);
    }

    100% {
        transform: translateY(-50%) rotate(360deg);
    }
}

.table-loading {
    opacity: 0.6;
    pointer-events: none;
}

.table-loading td {
    color: #999;
}

/* Search input focus state for real-time search */
.search-input.searching {
    border-bottom-color: #8B0000;
    background: linear-gradient(90deg, transparent 0%, rgba(139, 0, 0, 0.05) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: searchGlow 1.5s ease-in-out infinite;
}

@keyframes searchGlow {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Loading message styling */
.table td.text-center i {
    color: #8B0000;
    font-style: normal;
    font-weight: 500;
}

/* Error message styling */
.table td.text-danger {
    color: #dc3545 !important;
    font-weight: 500;
}

.table td.text-danger small {
    display: block;
    margin-top: 5px;
    font-size: 11px;
    opacity: 0.8;
}

/* Clickable cell styles */
.clickable-cell {
    color: #333;
    cursor: pointer;
    transition: color 0.2s ease;
}

.clickable-cell:hover {
    color: #8B0000;
    font-weight: 500;
}

/* Status and Info */
.status-info {
    margin: 15px 0;
    font-size: 14px;
    color: #666;
}

.total-records {
    font-weight: 600;
    color: #333;
}

/* Alert Styles */
.alert {
    padding: 12px 16px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 14px;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeaa7;
}

.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

/* Generic message boxes (compat with existing markup) */
.message {
    padding: 12px 16px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 14px;
}
.message-success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}
.message-error {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* Amount formatting */
.amount {
    text-align: right;
    font-weight: 500;
}

.amount.negative {
    color: #dc3545;
}

.amount.positive {
    color: #28a745;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    gap: 5px;
}

.pagination a,
.pagination span {
    padding: 8px 12px;
    text-decoration: none;
    border: 1px solid #ddd;
    color: #333;
    background-color: white;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.pagination a:hover {
    background-color: #8B0000;
    color: white;
    border-color: #8B0000;
}

.pagination .current {
    background-color: #8B0000;
    color: white;
    border-color: #8B0000;
}
/* Make sortable table headers clickable without hyperlink styling */
table.table thead th.sortable {
    cursor: pointer;
    color: inherit;
    text-decoration: none;
    font-weight: 600;
}
/* Floating navigation buttons */
.floating-nav {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 999;
}
.floating-nav .btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
/* Secondary floating nav offset (for row-level scroll) */
.floating-nav-offset { right: 70px; }
.floating-nav .mini { font-size: 14px; }
@media (max-width: 600px) { .floating-nav-offset { right: 60px; } }
/* Sticky header helper (already exists: .sticky-header thead th). Ensure payments table uses it */
.payments-table.sticky-header thead th { position: sticky; top: 0; z-index: 6; background:#f8f9fa; }
/* Sort indicators */
th.sortable[data-sort-dir="asc"]:after { content: " \25B2"; }
th.sortable[data-sort-dir="desc"]:after { content: " \25BC"; }
@media (max-width: 600px) {
    .floating-nav { right: 8px; bottom: 8px; }
    .floating-nav .btn { width: 36px; height: 36px; }
}

/* Matrix sticky header inside scroll container */
#matrixContainer thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #fff;
}
/* Generic sticky header helper for any table */
.sticky-header thead th { position: sticky; top: 0; z-index: 5; background: #fff; }
.table-scroll { max-height: 70vh; overflow: auto; position: relative; }
/* Matrix layout refinements */
.matrix-wrapper { margin:16px; }
.matrix-header { position:sticky; top:0; z-index:3; align-items:flex-start; }
.matrix-container { max-height:70vh; overflow:auto; position:relative; }
.matrix-actions-row { display:flex; gap:8px; flex-wrap:nowrap; align-items:center; width:100%; }
.matrix-actions-row .spacer { flex:1 1 auto; }
.matrix-search { max-width:520px; flex:0 0 auto; }
.sticky-col-header-first { position:sticky; left:0; z-index:6; background:#fff; }
.sticky-col-cell-first { position:sticky; left:0; z-index:5; background:#fff; font-weight:600; white-space:nowrap; }
.modal-actions-center { justify-content:center !important; }
.modal-actions-center .btn-equal { min-width:120px; }
.supplier-item input[type=checkbox] { flex:0 0 auto; }
.supplier-item .supplier-name { flex:1 1 auto; }

/* Dispatch summary row inline layout */
.dispatch-summary-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.dispatch-summary-row .dispatch-total { font-size: 12px; color: #555; }
.dispatch-select-all { font-size: 12px; }

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1100; /* above fixed header */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-content.large-modal {
    max-width: 1000px;
}

.modal-header {
    padding: 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}

.modal-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #666;
    cursor: grab;
    margin-right: 10px;
}

.modal-drag-handle:active {
    cursor: grabbing;
}

.modal-header h3 {
    margin: 0;
    color: #333;
    flex: 1;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background-color: #e9ecef;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.search-container {
    position: relative;
    margin-bottom: 20px;
}

.clear-search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
}

.suppliers-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.supplier-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.supplier-item:hover {
    background-color: #f8f9fa;
}

.supplier-item:last-child {
    border-bottom: none;
}

.supplier-name {
    font-weight: 600;
    color: #333;
    word-wrap: break-word;
    white-space: normal;
}

.supplier-details {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

.po-items-table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 20px;
}

/* Invoice supplementary layout and picker */
.invoice-supp-layout { display: grid; grid-template-columns: 40% 1fr; gap: 30px; margin-bottom: 30px; }
@media (max-width: 1024px) { .invoice-supp-layout { grid-template-columns: 1fr; } }
.invoice-picker { max-height: 60vh; overflow-y: auto; border: 1px solid #ddd; border-radius: 4px; background: #fff; }

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.modal-footer {
    padding: 20px;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    text-align: right;
}

.pending-qty {
    color: #666;
    font-size: 11px;
    font-style: italic;
}

.alert {
    padding: 12px 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: #6c757d;
}

.text-primary {
    color: #8B0000;
}

.text-success {
    color: #28a745;
}

.text-danger {
    color: #dc3545;
}

.text-warning {
    color: #ffc107;
}

.text-info {
    color: #17a2b8;
}

.d-none {
    display: none;
}

.d-block {
    display: block;
}

.d-inline {
    display: inline;
}

.d-inline-block {
    display: inline-block;
}

.d-flex {
    display: flex;
}

/* Width utilities for compact inputs */
.w-60 { width: 60px; }
.w-80 { width: 80px; }
.w-110 { width: 110px; }

/* Margin and padding utilities */
.m-0 { margin: 0; }
.pl-3 { padding-left: 20px; }

/* Small utilities for PO/PR pages */
.cursor-pointer { cursor: pointer; }
.fw-600 { font-weight: 600; }
.va-middle td { vertical-align: middle; }

.justify-content-start {
    justify-content: flex-start;
}

.justify-content-center {
    justify-content: center;
}

.justify-content-end {
    justify-content: flex-end;
}

.justify-content-between {
    justify-content: space-between;
}

.align-items-start {
    align-items: flex-start;
}

.align-items-center {
    align-items: center;
}

.align-items-end {
    align-items: flex-end;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: 0.25rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.mb-5 {
    margin-bottom: 3rem;
}

.mt-0 {
    margin-top: 0;
}

.mt-1 {
    margin-top: 0.25rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.mt-5 {
    margin-top: 3rem;
}

.p-0 {
    padding: 0;
}

.p-1 {
    padding: 0.25rem;
}

.p-2 {
    padding: 0.5rem;
}

.p-3 {
    padding: 1rem;
}

.p-4 {
    padding: 1.5rem;
}

.p-5 {
    padding: 3rem;
}

/* Extra utilities for billing-info and common patterns */
.bg-light { background-color: #f8f9fa; }
.pre-wrap { white-space: pre-wrap; }
.maxw-220 { max-width: 220px; }
.boxed { border: 1px solid #dee2e6; border-radius: 4px; padding: 10px; background: #ffffff; }
.scroll-box { padding: 8px; max-height: 200px; overflow: auto; }
.fade-in { transition: opacity .2s ease; }
.relative { position: relative; }
.bi-checkline { display: block; margin-bottom: 6px; }
.gap-8 { gap: 8px; }

/* Search input with inline clear button space */
.search-input.has-clear { padding-right: 26px; }

/* Toggle affordances used in expandable lists */
.toggle-location { font-weight: 600; color: #333; text-decoration: none; cursor: pointer; }
.toggle-location:hover { color: #8B0000; }
.toggle-circle { display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; color: #666; cursor: pointer; }
.toggle-circle:hover { color: #8B0000; }

/* Simple gap utilities */
.gap-1 { gap: 6px; }
.gap-2 { gap: 10px; }
.gap-3 { gap: 16px; }

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .filter-buttons {
        justify-content: center;
    }

    .table {
        font-size: 11px;
    }

    .table th,
    .table td {
        padding: 8px 4px;
    }

    .form-row {
        flex-direction: column;
    }

    .search-row {
        flex-direction: column;
        gap: 10px;
    }

    .search-row .form-input,
    .search-row .form-control,
    .search-input-container {
        min-width: auto;
        width: 100%;
    }

    .btn {
        width: 100%;
        margin-bottom: 10px;
    }

    .modal-dialog {
        margin: 20px;
        width: auto;
    }
}

/* PO Modal enhancements */
.already-added {
    background-color: #f8f9fa !important;
    opacity: 0.7;
}

.already-added input[type="checkbox"]:disabled {
    cursor: not-allowed;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 15px 0;
    border-top: 1px solid #dee2e6;
    margin-top: 15px;
}

.modal-actions>div {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* PO modal group header */
.po-group-header td{
    background:#f1f3f5;
    font-weight:600;
    color:#333;
}

/* When a modal row is marked as already-added */
.modal-table .already-added td {
    background:#f9fdf9;
}

/* File Upload Styles (moved from add_invoice) */
.file-upload-container { position: relative; }
.file-input { border: 2px dashed #dee2e6 !important; border-radius: 8px; padding: 20px; text-align: center; cursor: pointer; transition: border-color 0.3s ease; }
.file-input:hover { border-color: #8B0000 !important; }
.file-input:focus { border-color: #8B0000 !important; outline: none; }
.file-upload-help { margin-top: 8px; }
.file-preview-container { background: #f8f9fa; padding: 15px; border-radius: 6px; border: 1px solid #dee2e6; }
.file-preview-container h4 { margin: 0 0 10px 0; color: #333; font-size: 14px; font-weight: 600; }
.file-list { list-style: none; padding: 0; margin: 0; }
.file-list li { padding: 8px 0; border-bottom: 1px solid #eee; display: flex; align-items: center; font-size: 13px; }
.file-list li:last-child { border-bottom: none; }
.file-list i { color: #8B0000; width: 16px; }

.text-muted {
    color: #6c757d !important;
    font-size: 12px;
}

.btn-success {
    background-color: #28a745;
    border-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
    border-color: #1e7e34;
}

/* Print Styles */
@media print {

    .header-actions,
    .filters-section,
    .btn,
    .search-controls,
    .pagination {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #000;
    }

    .table {
        font-size: 11px;
    }

    .table th,
    .table td {
        padding: 6px 4px;
    }

    body {
        font-size: 12px;
    }
}

/* Filters and Search Layout */
.filters-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 20px;
    align-items: end;
}

.search-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #666;
    padding: 2px;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    top: 50%;
    transform: translateY(-50%);
}

.search-input:not(:placeholder-shown)+.clear-search-btn,
.search-input:focus+.clear-search-btn,
.clear-search-btn.show {
    opacity: 1;
}

.clear-search-btn:hover {
    background-color: #e9ecef;
    color: #dc3545;
}

.search-filter-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    display: none;
    width: 20px;
    height: 20px;
    text-align: center;
    line-height: 1;
    border-radius: 50%;
}

.search-clear-btn:hover {
    background-color: #f0f0f0;
    color: #333;
}

.search-info {
    color: #666;
    font-size: 14px;
}

/* Invoice Form Layout */
.invoice-layout-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

/* Purchase Orders Layout */
.po-main-section,
.po-header-section,
.notes-section {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #8B0000;
}

.po-layout-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.po-details-section { flex: 2; }
.po-details-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }

.items-controls { margin-bottom: 20px; display: flex; gap: 10px; }
.items-table-container { overflow-x: auto; }

.totals-row { background-color: #f8f9fa !important; font-weight: 600; }

@media (max-width: 768px) {
    .po-layout-container { flex-direction: column; gap: 20px; }
    .po-details-grid { grid-template-columns: 1fr; gap: 15px; }
    .po-main-section,
    .po-header-section,
    .notes-section { padding: 15px; margin-bottom: 20px; }
    .items-controls { flex-direction: column; }
}

.supplier-section-left {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #8B0000;
}

.supplier-section-left h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.supplier-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.supplier-selector-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #8B0000;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.supplier-selector-btn:hover {
    background-color: #e9ecef;
}

.invoice-details-section {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #8B0000;
}

.invoice-details-section h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.invoice-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.items-section {
    background-color: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    border-left: 4px solid #8B0000;
    margin-bottom: 20px;
}

.items-section h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.item-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    background-color: white;
}

.items-table th,
.items-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    font-size: 14px;
}

.items-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
}

.items-table input,
.items-table select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.items-table input:focus,
.items-table select:focus {
    outline: none;
    border-color: #8B0000;
    box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.1);
}

.amount-column {
    text-align: right;
    width: 120px;
}

.remove-item {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.remove-item:hover {
    background-color: #c82333;
}

.totals-section {
    background-color: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    border-left: 4px solid #8B0000;
    margin-bottom: 20px;
}

.totals-section h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.totals-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.totals-display {
    background-color: white;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 16px;
}

.total-row.grand-total {
    border-top: 2px solid #dee2e6;
    padding-top: 10px;
    margin-top: 10px;
    font-weight: bold;
    font-size: 18px;
    color: #8B0000;
}

.tax-section {
    background-color: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    border-left: 4px solid #8B0000;
    margin-bottom: 20px;
}

.tax-section h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.tax-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding: 15px;
    background-color: white;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.tax-row label {
    min-width: 150px;
    font-weight: 500;
    color: #333;
}

.tax-row input,
.tax-row select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.tax-row input:focus,
.tax-row select:focus {
    outline: none;
    border-color: #8B0000;
    box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.1);
}

.tax-amount {
    min-width: 120px;
    text-align: right;
    font-weight: bold;
    color: #8B0000;
}

.readonly-field {
    background-color: #f8f9fa;
    border-color: #e9ecef;
    color: #6c757d;
}

.search-section {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
}

.search-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.modal-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.modal-table th,
.modal-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.modal-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
    position: sticky;
    top: 0;
}

.modal-table tr:hover {
    background-color: #f8f9fa;
}

.item-checkbox {
    margin-right: 8px;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

@media (max-width: 768px) {
    .filters-grid {
        grid-template-columns: 1fr;
    }

    .search-filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    /* Invoice Form Responsive */
    .invoice-layout-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .invoice-details-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .totals-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .item-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .items-table {
        font-size: 12px;
    }

    .items-table th,
    .items-table td {
        padding: 8px;
    }

    .modal-content {
        width: 95%;
        margin: 5% auto;
    }

    .search-row {
        flex-direction: column;
        align-items: stretch;
    }

    .search-input {
        min-width: auto;
    }

    .form-actions {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 200px;
        justify-content: center;
    }

    .tax-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .tax-row label {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .card-body {
        padding: 15px;
    }

    .supplier-section-left,
    .invoice-details-section,
    .items-section,
    .totals-section,
    .tax-section {
        padding: 15px;
    }

    .items-table {
        font-size: 11px;
    }

    .items-table th,
    .items-table td {
        padding: 6px;
    }
}

/* Minimal icon buttons (grey, no background) */
.icon-btn {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
    padding: 0;
    margin: 0 0 0 6px;
    color: #777;
    cursor: pointer;
    line-height: 1;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
}
.icon-btn:hover { color: #333; background: transparent !important; }
.icon-btn:focus { outline: none !important; box-shadow: none !important; }
.icon-btn:disabled { color: #bbb; cursor: not-allowed; }
.icon-reload { font-size: 15px; vertical-align: middle; line-height: 1; }
/* Ensure inline SVGs inside icon-btn render at header-like size */
.icon-btn svg { width: 16px; height: 16px; display: inline-block; vertical-align: middle; }

/* Label row to place text and inline icon together */
.label-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 5px;
    flex-wrap: nowrap; /* keep label and icon on the same line */
}
.label-row label {
    margin: 0 !important; /* override default label margin to keep rows neat */
    display: inline-flex !important; /* ensure label doesn't take full width so icon stays inline */
    align-items: center; /* vertically center text within the row */
}

/* Inline label icon (non-button) to avoid underline/box issues */
.label-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    color: #777;
    cursor: pointer;
    vertical-align: middle;
    flex: 0 0 auto; /* prevent flex growth/shrink and keep it next to label */
}
.label-icon:hover { color: #333; }
.label-icon svg { width: 14px; height: 14px; display: inline-block; }