/**
 * Lookup Modal Styles
 * Card-based record selection modal for table fields
 */

/* Prevent body scroll when modal is open */
body.lookup-modal-open {
    overflow: hidden;
}

/* Modal overlay */
.lookup-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: lookupFadeIn 0.2s ease;
}

@keyframes lookupFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Modal container */
.lookup-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90vw;
    max-width: 1200px;
    height: 85vh;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: lookupSlideIn 0.2s ease;
}

@keyframes lookupSlideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Header */
.lookup-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    flex-shrink: 0;
}

.lookup-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1e1e1e;
}

.lookup-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s;
}

.lookup-modal-close:hover {
    color: #d63638;
}

/* Toolbar (search + filters) */
.lookup-modal-toolbar {
    padding: 12px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
}

.lookup-modal-search {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
}

.lookup-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.lookup-search-input:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.15);
}

/* Filters */
.lookup-modal-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.lookup-filter {
    display: flex;
    align-items: center;
    gap: 6px;
}

.lookup-filter-label {
    font-size: 13px;
    color: #555;
    font-weight: 500;
}

.lookup-filter-select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
}

.lookup-filter-radio {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.lookup-filter-radio:hover {
    background: #eee;
}

.lookup-filter-radio input {
    margin: 0;
}

.lookup-clear-filters {
    padding: 6px 12px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    transition: background 0.15s;
}

.lookup-clear-filters:hover {
    background: #e0e0e0;
}

/* Results info */
.lookup-modal-info {
    padding: 8px 20px;
    background: #fff;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #666;
    flex-shrink: 0;
}

.lookup-selected-count {
    color: #2271b1;
    font-weight: 500;
}

/* Body (cards container) */
.lookup-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: #f5f5f5;
}

/* Cards grid */
.lookup-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* Single card */
.lookup-card {
    background: #fff;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    display: flex;
    flex-direction: column;
    position: relative;
}

.lookup-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.lookup-card.selected {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
}

/* Card checkbox (multi-select) */
.lookup-card-select {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
}

.lookup-card-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Card image */
.lookup-card-image {
    width: 100%;
    height: 140px;
    overflow: hidden;
    background: #f0f0f0;
}

.lookup-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lookup-card-no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
}

.lookup-card-no-image .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
}

/* Card content */
.lookup-card-content {
    padding: 12px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.lookup-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #1e1e1e;
    margin-bottom: 4px;
    line-height: 1.3;
}

.lookup-card-subtitle {
    font-size: 13px;
    color: #555;
    margin-bottom: 4px;
}

.lookup-card-description {
    font-size: 12px;
    color: #777;
    margin-bottom: 8px;
    line-height: 1.4;
}

/* Card meta */
.lookup-card-meta {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lookup-card-meta-item {
    font-size: 12px;
}

.lookup-meta-label {
    color: #888;
}

.lookup-meta-value {
    color: #333;
    font-weight: 500;
}

/* Loading and messages */
.lookup-loading,
.lookup-error,
.lookup-no-results {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 15px;
}

.lookup-error {
    color: #d63638;
}

/* Footer */
.lookup-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

/* Pagination */
.lookup-pagination {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lookup-page-prev,
.lookup-page-next {
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.lookup-page-prev:hover:not(:disabled),
.lookup-page-next:hover:not(:disabled) {
    background: #f0f0f0;
    border-color: #bbb;
}

.lookup-page-prev:disabled,
.lookup-page-next:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lookup-page-info {
    font-size: 13px;
    color: #555;
}

/* Actions */
.lookup-actions {
    display: flex;
    gap: 10px;
}

.lookup-cancel {
    padding: 8px 16px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.lookup-cancel:hover {
    background: #e0e0e0;
}

.lookup-confirm {
    padding: 8px 20px;
    background: #2271b1;
    border: none;
    border-radius: 4px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.lookup-confirm:hover:not(:disabled) {
    background: #135e96;
}

.lookup-confirm:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ==========================================================================
   Table Cell Trigger Styles (space-efficient)
   ========================================================================== */

/* Lookup cell in table - minimal visual footprint */
.lookup-modal-cell {
    cursor: pointer;
    position: relative;
    min-width: 100px;
    padding-right: 20px !important;
}

.lookup-modal-cell::after {
    content: '\25BE'; /* Small down triangle */
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    opacity: 0.4;
    transition: opacity 0.15s;
    pointer-events: none;
}

.lookup-modal-cell:hover {
    background: #f8f9fa;
}

.lookup-modal-cell:hover::after {
    opacity: 0.8;
}

/* Input inside lookup cell */
.lookup-modal-cell input {
    cursor: pointer;
    background: transparent;
    border: 1px dashed transparent;
    transition: border-color 0.15s;
}

.lookup-modal-cell:hover input {
    border-color: #ddd;
}

/* Hidden reference field */
.lookup-reference-field {
    display: none !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .lookup-modal {
        width: 95vw;
        height: 90vh;
        border-radius: 4px;
    }
    
    .lookup-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 12px;
    }
    
    .lookup-modal-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .lookup-modal-search {
        max-width: none;
    }
    
    .lookup-modal-footer {
        flex-direction: column;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .lookup-cards-grid {
        grid-template-columns: 1fr;
    }
    
    .lookup-card-image {
        height: 120px;
    }
}
