/* Purchase Orders Section Styles */
/* Global body styles now in global.css */

/* Table container and common table styles now in admin-sections-shared.css */

#purchase-orders-section {
    position: relative;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 0px);
}

#purchase-orders-section main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#purchase-orders-section .table-container {
    overflow-x: auto;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

#purchase-orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

#purchase-orders-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f1f1f1;
}

#purchase-orders-table th {
    position: sticky;
    top: 0;
    background-color: #f1f1f1;
    z-index: 10;
}

#purchase-orders-table th,
#purchase-orders-table td {
    text-align: left;
    vertical-align: top;
}

#purchase-orders-table tbody tr {
    transition: all 0.2s ease;
    background-color: transparent;
}

#purchase-orders-table tbody tr:nth-child(odd) {
    background-color: transparent;
}

#purchase-orders-table tbody tr td {
    border-bottom: 1px solid #e9ecef;
}

/* Status badge styling */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 500;
    text-transform: capitalize;
}

.status-fulfilled {
    background-color: #d4edda;
    color: #155724;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

/* Actions column */
.actions-cell {
    white-space: nowrap;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 14px;
    margin-right: 4px;
    transition: all 0.2s ease;
}

.action-btn.edit {
    color: #007bff;
}

.action-btn.edit:hover {
    background-color: #e7f3ff;
}

.action-btn.delete {
    color: #dc3545;
}

.action-btn.delete:hover {
    background-color: #fdeaea;
}

/* Modal Styles - using global modal styles from global.css */

.purchase-order-form {
    padding: 0 24px 24px 24px;
}

/* Form row for side-by-side fields */
.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

/* Purchase order items section */
.purchase-order-items-section {
    margin: 20px 0;
}


.purchase-order-item-row {
    margin-bottom: 20px;
    padding: 0;
    background-color: transparent;
    border-radius: 0;
    border: none;
}

.purchase-order-item-content {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease;
    overflow: hidden;
}

.purchase-order-item-content:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.08);
}

/* Collapsed View */
.item-collapsed-view {
    display: none;
    align-items: center;
    padding: 16px 20px;
    gap: 12px;
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.item-collapse-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #6b7280;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.item-collapse-toggle-btn:hover {
    color: #374151;
    background-color: #f3f4f6;
    border-radius: 4px;
}

.item-collapse-toggle-btn i {
    font-size: 16px;
    transition: transform 0.2s ease;
}

.item-collapsed-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.item-collapsed-name {
    flex: 1;
    min-width: 0;
}

.item-name-display {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-collapsed-details {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.item-quantity-display {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    min-width: 30px;
    text-align: right;
}

.item-quantity-label {
    font-size: 12px;
    color: #6b7280;
    min-width: 30px;
}

.item-price-display {
    font-size: 13px;
    color: #6b7280;
    min-width: 60px;
    text-align: right;
}

.item-total-display {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    min-width: 70px;
    text-align: right;
}

.collapsed-remove-btn {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.collapsed-remove-btn:hover {
    background: #fecaca;
    border-color: #fca5a5;
    color: #b91c1c;
}

/* Expanded View */
.item-expanded-view {
    display: block;
    padding: 20px;
}

.item-expanded-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.item-main-fields {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.item-main-fields .form-group {
    margin-bottom: 0;
}

.item-main-fields .item-field {
    display: flex;
    flex-direction: column;
}

.item-main-fields .item-field label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.item-quantity-field {
    position: relative;
}

.item-quantity-field .item-quantity-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background-color: #f9fafb;
    color: #6b7280;
    cursor: not-allowed;
    font-weight: 500;
}

.quantity-help-text {
    font-size: 11px;
    color: #6b7280;
    display: block;
    margin-top: 4px;
    font-style: italic;
}

.item-actions {
    display: flex;
    align-items: flex-start;
    padding-top: 24px;
}

.purchase-order-item-row .remove-item-btn {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.purchase-order-item-row .remove-item-btn:hover {
    background: #fecaca;
    border-color: #fca5a5;
    color: #b91c1c;
}

.purchase-order-item-row select,
.purchase-order-item-row input:not(.item-quantity-input) {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.purchase-order-item-row input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Price Section */
.item-price-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.item-price-options {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.price-option-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: #ffffff;
    transition: all 0.2s ease;
}

.price-option-label:hover {
    background-color: #f9fafb;
    border-color: #9ca3af;
}

.price-option-label input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

.price-option-label input[type="radio"]:checked + span {
    color: #667eea;
    font-weight: 600;
}

.price-option-label:has(input[type="radio"]:checked) {
    background-color: #e7f3ff;
    border-color: #667eea;
}

.item-price-field {
    margin-bottom: 0;
}

.item-price-field label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
    display: block;
}

.item-price-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.item-price-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.price-help-text {
    font-size: 11px;
    color: #6b7280;
    display: block;
    margin-top: 4px;
    font-style: italic;
}

/* Locations Section */
.item-locations-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.item-locations-header {
    margin-bottom: 16px;
}

.item-locations-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.item-locations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.item-location-card {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s ease;
}

.item-location-card:hover {
    border-color: #d1d5db;
    background-color: #ffffff;
}

.item-location-card:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background-color: #ffffff;
}

.item-location-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.item-location-name {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
}

.item-location-available {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #6b7280;
}

.available-label {
    font-weight: 500;
}

.available-value {
    font-weight: 600;
    color: #059669;
    font-size: 12px;
}

.item-location-card input.item-location-quantity {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background-color: #ffffff;
    transition: all 0.2s ease;
    font-weight: 500;
}

.item-location-card input.item-location-quantity:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.item-location-card input.item-location-quantity:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
    color: #9ca3af;
}

/* Inventory Item Dropdown Styles */
.inventory-item-dropdown-wrapper {
    position: relative;
    width: 100%;
}

.inventory-item-dropdown {
    position: relative;
    width: 100%;
}

.inventory-item-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.inventory-item-dropdown-trigger:hover {
    border-color: #667eea;
}

.inventory-item-dropdown.open .inventory-item-dropdown-trigger {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.inventory-item-dropdown-placeholder {
    flex: 1;
    text-align: left;
    color: #333;
}

.inventory-item-dropdown-placeholder.placeholder {
    color: #6c757d;
}

.inventory-item-dropdown-trigger i {
    color: #6c757d;
    transition: transform 0.2s ease;
    font-size: 14px;
    margin-left: 8px;
}

.inventory-item-dropdown.open .inventory-item-dropdown-trigger i {
    transform: rotate(180deg);
}

.inventory-item-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow: hidden;
}

.inventory-item-dropdown-search {
    position: relative;
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.inventory-item-dropdown-search input {
    width: 100%;
    padding: 8px 32px 8px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.inventory-item-dropdown-search input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.inventory-item-dropdown-search i {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    pointer-events: none;
}

.inventory-item-dropdown-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 4px;
}

.inventory-item-dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background-color 0.2s ease;
    border-radius: 4px;
    margin: 2px 0;
}

.inventory-item-dropdown-item:hover {
    background-color: #f0f0f0;
}

.inventory-item-dropdown-item.selected {
    background-color: #e7f3ff;
    color: #007bff;
    font-weight: 500;
}

.add-line-item-btn {
    background: transparent;
    color: #667eea;
    border: 1px solid #667eea;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.add-line-item-btn:hover {
    background: #667eea;
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    main {
        padding: 15px;
    }

    .table-container {
        margin-top: 15px;
    }

    #purchase-orders-table th,
    #purchase-orders-table td {
        padding: 12px 8px;
        font-size: 13px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .item-main-fields {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .item-actions {
        padding-top: 0;
        justify-content: flex-end;
    }

    .item-locations-grid {
        grid-template-columns: 1fr;
    }

    .item-price-options {
        flex-direction: column;
        gap: 8px;
    }

    .price-option-label {
        width: 100%;
    }

    .item-collapsed-view {
        flex-wrap: wrap;
        padding: 12px 16px;
    }

    .item-collapsed-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        width: 100%;
    }

    .item-collapsed-details {
        width: 100%;
        justify-content: space-between;
    }

    .purchase-order-summary {
        padding: 16px;
        margin: 16px 0;
    }

    .summary-item-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .summary-item-details {
        align-items: flex-start;
        width: 100%;
    }

    .total-row {
        font-size: 16px;
    }

    .total-row.grand-total {
        font-size: 14px;
    }

    .total-row.grand-total .total-amount {
        font-size: 14px;
    }
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.empty-state h3 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #495057;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 30px;
}

/* Error state */
.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #f5c6cb;
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #c3e6cb;
}

/* Order Summary */
.purchase-order-summary {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    margin: 24px 0;
}

.purchase-order-summary h3 {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
}

.summary-items {
    margin-bottom: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.summary-empty {
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    font-style: italic;
    padding: 20px;
}

.summary-item-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

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

.summary-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    flex: 1;
    margin-right: 16px;
}

.summary-item-details {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    min-width: 120px;
}

.summary-item-qty {
    font-size: 12px;
    color: #6b7280;
}

.summary-item-price {
    font-size: 12px;
    color: #6b7280;
}

.summary-item-total {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

.summary-total {
    border-top: 2px solid #e5e7eb;
    padding-top: 16px;
    margin-top: 16px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.total-row.grand-total {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    padding-top: 12px;
    border-top: 2px solid #e5e7eb;
    margin-top: 8px;
}

.total-amount {
    font-weight: 600;
    color: #111827;
}

.total-row.grand-total .total-amount {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}


