/* Handsontable Custom Styling for Order Requirement Form */

/* Container styling */
#admin-handsontable-container,
#customer-handsontable-container,
#frontend-handsontable-container {
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    background: white;
    margin-top: 10px;
}

/* Toggle button styling */
.orf-handsontable-toggle {
    background: #0073aa;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 10px;
    transition: background-color 0.3s ease;
}

.orf-handsontable-toggle:hover {
    background: #005a87;
}

.orf-handsontable-toggle.active {
    background: #46b450;
}

.orf-handsontable-toggle.active:hover {
    background: #3d9e45;
}

/* Handsontable cell customizations */
.handsontable td {
    vertical-align: top !important;
    word-wrap: break-word !important;
    white-space: pre-wrap !important;
    line-height: 1.4 !important;
    padding: 8px !important;
    color: #000 !important; /* Ensure text is black */
}

/* Header styling - Make headers clearly visible */
.handsontable thead th {
    background: #0073aa !important;
    color: #fff !important;
    font-weight: 600 !important;
    text-align: center !important;
    border-bottom: 2px solid #005a87 !important;
    border-right: 1px solid #005a87 !important;
    padding: 10px 8px !important;
}


/* Row header styling */
.handsontable tbody th {
    background: #f8f9fa !important;
    font-weight: 500 !important;
    text-align: center !important;
    border-right: 1px solid #dee2e6 !important;
}

/* Readonly cell styling */
.handsontable td.readonly {
    background-color: #f5f5f5 !important;
    color: #666 !important;
}

/* Selected cell styling */
.handsontable td.area {
    background-color: #cce5ff !important;
}

.handsontable td.current {
    border: 2px solid #0073aa !important;
}

/* Text area for long content */
.handsontable td textarea {
    resize: none !important;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    font-family: inherit !important;
    font-size: inherit !important;
    line-height: 1.4 !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* Improve scrollbar appearance */
.handsontable .wtHolder {
    scrollbar-width: thin;
    scrollbar-color: #ccc #f1f1f1;
}

.handsontable .wtHolder::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.handsontable .wtHolder::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.handsontable .wtHolder::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.handsontable .wtHolder::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Frontend-specific styling fixes */
#frontend-handsontable-container .handsontable {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

/* Product column (first column) - Make text bold */
#frontend-handsontable-container .handsontable td[data-col="0"],
.orf-frontend-spreadsheet-container .handsontable td[data-col="0"] {
    font-weight: 600 !important;
    color: #000 !important;
}

/* Fix editing input field styling */
#frontend-handsontable-container .handsontable .handsontableInput,
.orf-frontend-spreadsheet-container .handsontable .handsontableInput {
    color: #000 !important;
    background: #fff !important;
    border: 1px solid #0073aa !important;
    box-shadow: 0 0 3px rgba(0, 115, 170, 0.3) !important;
    font-size: 14px !important;
    padding: 4px 6px !important;
    font-family: inherit !important;
}

/* Fix editing textarea styling */
#frontend-handsontable-container .handsontable .handsontableInputHolder textarea,
.orf-frontend-spreadsheet-container .handsontable .handsontableInputHolder textarea {
    color: #000 !important;
    background: #fff !important;
    border: 1px solid #0073aa !important;
    box-shadow: 0 0 3px rgba(0, 115, 170, 0.3) !important;
    font-size: 14px !important;
    padding: 4px 6px !important;
    font-family: inherit !important;
    resize: both !important;
}

/* Fix cell focus styling */
#frontend-handsontable-container .handsontable td.current,
.orf-frontend-spreadsheet-container .handsontable td.current {
    border: 2px solid #0073aa !important;
    background: #fff !important;
}

/* Ensure all text is black */
#frontend-handsontable-container .handsontable td,
.orf-frontend-spreadsheet-container .handsontable td {
    color: #000 !important;
}

/* Context menu styling */
.handsontable .htContextMenu {
    border-radius: 4px !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15) !important;
}

/* Fill handle styling */
.handsontable .wtBorder.fill {
    border-color: #0073aa !important;
}

/* Responsive behavior */
@media (max-width: 768px) {
    #admin-handsontable-container,
    #customer-handsontable-container {
        overflow-x: auto;
    }
    
    .handsontable td {
        min-width: 120px !important;
        padding: 6px !important;
    }
    
    .handsontable thead th {
        padding: 8px 6px !important;
        font-size: 13px !important;
    }
}

/* Loading state */
.orf-handsontable-loading {
    text-align: center;
    padding: 60px 20px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin: 10px 0;
}

.orf-loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

.orf-handsontable-loading p {
    color: #666;
    font-size: 14px;
    margin: 0;
    font-weight: 500;
}

.orf-handsontable-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    z-index: 1000;
}

.orf-handsontable-loading::after {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    font-weight: 600;
    color: #0073aa;
}

/* Success/Error message styling */
.orf-message {
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
    font-weight: 500;
}

.orf-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.orf-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Better focus indicators */
.handsontable:focus-within {
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

/* Improve text selection */
.handsontable td::selection {
    background: #0073aa;
    color: white;
}

.handsontable td::-moz-selection {
    background: #0073aa;
    color: white;
}
