/**
 * Harvest Table Styles
 */

/* Utility classes */
.hidden {
    display: none;
}

.cutplanner-harvest-table {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Table Controls */
.cutplanner-harvest-table .table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.cutplanner-harvest-table .filter-form {
    display: flex;
    gap: 8px;
}

.cutplanner-harvest-table .filter-form input[type="text"] {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    min-width: 200px;
}

.cutplanner-harvest-table .record-count {
    color: #666;
    font-size: 13px;
}

/* Table */
.cutplanner-harvest-table table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.cutplanner-harvest-table th {
    background: #f5f5f5;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 2px solid #ddd;
}

.cutplanner-harvest-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
    vertical-align: middle;
}

.cutplanner-harvest-table tr:hover {
    background: #fafafa;
}

/* Editable cells */
.cutplanner-harvest-table .editable {
    cursor: pointer;
    position: relative;
}

.cutplanner-harvest-table .editable:hover .display-value {
    text-decoration: underline;
    color: #0073aa;
}

.cutplanner-harvest-table .edit-input {
    width: 100%;
    max-width: 100px;
    padding: 4px 6px;
    border: 1px solid #0073aa;
    border-radius: 3px;
    font-size: 13px;
}

.cutplanner-harvest-table .edit-input.date-input {
    max-width: 80px;
}

.cutplanner-harvest-table .edit-input:focus {
    outline: none;
    box-shadow: 0 0 0 1px #0073aa;
}

/* Tag number link */
.cutplanner-harvest-table .edit-record-link {
    color: #0073aa;
    text-decoration: none;
    font-weight: 600;
}

.cutplanner-harvest-table .edit-record-link:hover {
    text-decoration: underline;
}

/* Status badges */
.cutplanner-harvest-table .status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.cutplanner-harvest-table .status-dropped_off {
    background: #f0f0f0;
    color: #666;
}

.cutplanner-harvest-table .status-harvested {
    background: #fff3cd;
    color: #856404;
}

.cutplanner-harvest-table .status-allocated {
    background: #cce5ff;
    color: #004085;
}

.cutplanner-harvest-table .status-completed {
    background: #d4edda;
    color: #155724;
}

/* Allocation badges */
.cutplanner-harvest-table .allocation-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
}

.cutplanner-harvest-table .allocation-badge.complete {
    background: #d4edda;
    color: #155724;
}

.cutplanner-harvest-table .allocation-badge.incomplete {
    background: #fff3cd;
    color: #856404;
}

.cutplanner-harvest-table .allocation-badge.has-farmer {
    border: 2px solid #f8b4b4;
    cursor: help;
}

/* Farmer tag (secondary identifier) */
.cutplanner-harvest-table .farmer-tag {
    color: #666;
    font-size: 11px;
}

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

.cutplanner-harvest-table .actions-cell .button {
    margin-right: 3px;
    padding: 2px 8px;
    font-size: 12px;
}

.cutplanner-harvest-table .delete-record {
    color: #a00;
    background: #fff;
    border-color: #a00;
}

.cutplanner-harvest-table .delete-record:hover {
    background: #a00;
    color: #fff;
    border-color: #a00;
}

/* Pagination */
.cutplanner-harvest-table .pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.cutplanner-harvest-table .pagination .page-info {
    color: #666;
    font-size: 13px;
}

/* Modal Styles */
.harvest-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100000;
    overflow-y: auto;
    padding: 40px 20px;
}

.harvest-modal-overlay.open {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.harvest-modal {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 5px 30px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 900px;
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
}

.harvest-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #ddd;
    background: #f9f9f9;
    border-radius: 6px 6px 0 0;
}

.harvest-modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.harvest-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    line-height: 1;
}

.harvest-modal-close:hover {
    color: #000;
}

.harvest-modal-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.harvest-modal-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.harvest-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #ddd;
    background: #f9f9f9;
    border-radius: 0 0 6px 6px;
}

/* Modal form sections */
.modal-section {
    margin-bottom: 25px;
}

.modal-section h3 {
    margin: 0 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
    font-size: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.modal-field {
    display: flex;
    flex-direction: column;
}

.modal-field label {
    font-size: 12px;
    font-weight: 500;
    color: #555;
    margin-bottom: 4px;
}

.modal-field input,
.modal-field select {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
}

.modal-field input:focus,
.modal-field select:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 1px #0073aa;
}

.modal-field input[readonly] {
    background: #f5f5f5;
    color: #666;
}

/* Allocation rows in modal */
.modal-allocation-row {
    background: #f9f9f9;
    border: 1px solid #e5e5e5;
    border-radius: 3px;
    padding: 10px;
    margin-bottom: 8px;
}

.modal-allocation-row .alloc-fields {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.modal-allocation-row input[type="text"],
.modal-allocation-row input[type="email"],
.modal-allocation-row input[type="tel"] {
    flex: 1;
    min-width: 120px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
}

.modal-allocation-row select {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
}

.modal-allocation-row .remove-allocation-btn {
    color: #a00;
    font-size: 18px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 5px;
}

.modal-allocation-row .remove-allocation-btn:hover {
    color: #d00;
}

.no-allocations {
    color: #666;
    font-style: italic;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 3px;
}

/* Error state */
.harvest-modal-content .error {
    color: #d00;
    padding: 20px;
    background: #fef7f7;
    border-radius: 3px;
}

/* HCW Validation Styles */
.hcw-validation-message {
    padding: 12px 15px;
    margin: 10px 0;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.4;
}

.hcw-validation-message.error {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.hcw-validation-message.success {
    background-color: #d4edda;
    border: 1px solid #28a745;
    color: #155724;
}

input.hcw-mismatch {
    border-color: #ffc107 !important;
    background-color: #fffbf0 !important;
}

input.hcw-mismatch:focus {
    border-color: #ff9800 !important;
    box-shadow: 0 0 0 1px #ff9800 !important;
}
