/**
 * Property Integration Styles
 * CRM <-> Property Listing Integration
 * Modern, compact design matching CRM interface
 */

/* ===========================
 * GLOBAL MOBILE CONSTRAINTS
 * =========================== */

@media screen and (max-width: 768px) {
    /* Stack property card vertically on mobile */
    .recrm-detail-section .recrm-property-card {
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    /* Prevent ALL property elements from exceeding viewport */
    .recrm-property-section,
    .recrm-property-card,
    .recrm-property-search-modal,
    .recrm-property-details {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    
    /* Make image full width on mobile */
    .recrm-detail-section .recrm-property-image {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        height: 200px !important;
        max-height: 200px !important;
    }
    
    /* Ensure images are constrained */
    .recrm-property-image img {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        object-fit: cover !important;
    }
    
    /* Details container full width below image */
    .recrm-detail-section .recrm-property-details {
        width: 100% !important;
        flex: 1 !important;
    }
    
    /* Responsive text */
    .recrm-property-title {
        word-break: break-word !important;
        hyphens: auto !important;
    }
}

/* ===========================
 * PROPERTY SECTION
 * =========================== */

.recrm-property-section {
    margin-top: 20px;
}

.recrm-property-empty {
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px dashed #ddd;
}

.recrm-property-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
}

.recrm-property-actions .button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.recrm-property-actions .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* ===========================
 * PROPERTY CARD - Horizontal Layout with Thumbnail
 * =========================== */

.recrm-detail-section .recrm-property-card {
    display: flex !important;
    flex-direction: row !important; /* Horizontal on desktop */
    gap: 20px !important;
    background: #ffffff !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 4px !important;
    padding: 20px !important;
    transition: box-shadow 0.2s ease, border-color 0.2s ease !important;
    align-items: flex-start !important;
}

/* Desktop: Image is fixed width thumbnail */
@media screen and (min-width: 769px) {
    .recrm-detail-section .recrm-property-card {
        flex-direction: row !important;
    }
}

.recrm-detail-section .recrm-property-card:hover {
    border-color: #667eea !important;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1) !important;
}

/* Thumbnail Image - Responsive */
.recrm-detail-section .recrm-property-image {
    flex-shrink: 0 !important;
    width: 150px !important; /* Desktop default */
    height: 110px !important;
    min-width: 150px !important;
    min-height: 110px !important;
    max-width: 150px !important;
    max-height: 110px !important;
    border-radius: 4px !important;
    overflow: hidden !important;
    background: #f5f5f5 !important;
    border: 1px solid #e0e0e0 !important;
    display: block !important;
}

/* Desktop: Fixed thumbnail size */
@media screen and (min-width: 769px) {
    .recrm-detail-section .recrm-property-image {
        width: 150px !important;
        height: 110px !important;
        min-width: 150px !important;
        max-width: 150px !important;
    }
}

.recrm-detail-section .recrm-property-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

.recrm-detail-section .recrm-property-image .dashicons {
    font-size: 40px !important;
    color: #ccc !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Property Details */
.recrm-detail-section .recrm-property-details {
    flex: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

.recrm-detail-section .recrm-property-title {
    margin: 0 0 12px 0 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #23282d !important;
    line-height: 1.4 !important;
}

.recrm-detail-section .recrm-property-title a {
    color: inherit !important;
    text-decoration: none !important;
}

.recrm-detail-section .recrm-property-title a:hover {
    color: #667eea !important;
}

/* Info Grid - Compact 2-column layout */
.recrm-detail-section .recrm-property-info-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 15px !important;
}

.recrm-detail-section .recrm-property-info-item {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 13px !important;
    color: #555 !important;
    line-height: 1.4 !important;
}

.recrm-detail-section .recrm-property-info-item .dashicons {
    color: #667eea !important;
    font-size: 16px !important;
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0 !important;
}

.recrm-detail-section .recrm-property-info-item strong {
    font-weight: 600 !important;
    color: #23282d !important;
}

.recrm-detail-section .recrm-property-price {
    font-size: 18px !important;
    font-weight: 700 !important;
    color: #667eea !important;
}

.recrm-detail-section .recrm-property-address {
    grid-column: 1 / -1 !important;
    color: #666 !important;
    font-size: 12px !important;
}

/* Property Actions - Bottom aligned */
.recrm-detail-section .recrm-property-card-actions {
    display: flex !important;
    gap: 8px !important;
    margin-top: auto !important;
    padding-top: 10px !important;
    border-top: 1px solid #f0f0f0 !important;
}

.recrm-detail-section .recrm-property-card-actions .button {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    font-size: 13px !important;
    padding: 6px 12px !important;
    height: auto !important;
}

.recrm-detail-section .recrm-property-card-actions .button .dashicons {
    font-size: 14px !important;
    width: 14px !important;
    height: 14px !important;
}

/* Property Badges */
.recrm-detail-section .recrm-property-badge {
    display: inline-flex !important;
    align-items: center !important;
    padding: 3px 8px !important;
    border-radius: 3px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px !important;
}

.recrm-detail-section .recrm-property-badge.type-badge {
    background: #e3f2fd !important;
    color: #1565c0 !important;
}

.recrm-detail-section .recrm-property-badge.status-available,
.recrm-detail-section .recrm-property-badge.status-for-sale,
.recrm-detail-section .recrm-property-badge.status-for-rent {
    background: #e8f5e9 !important;
    color: #2e7d32 !important;
}

.recrm-detail-section .recrm-property-badge.status-sold {
    background: #ffebee !important;
    color: #c62828 !important;
}

.recrm-detail-section .recrm-property-badge.status-pending {
    background: #fff3e0 !important;
    color: #ef6c00 !important;
}

.recrm-detail-section .recrm-property-badge.status-rented {
    background: #f3e5f5 !important;
    color: #7b1fa2 !important;
}

/* Error State */
.recrm-property-error {
    padding: 15px 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.recrm-property-error .dashicons {
    color: #ff9800;
    flex-shrink: 0;
}

/* ===========================
 * PROPERTY SEARCH MODAL
 * =========================== */

.recrm-property-search-modal-wrapper {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 999999 !important;
    display: none; /* NO !important so JS can override it */
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
    background-color: rgba(0, 0, 0, 0.75) !important; /* Dark overlay background */
    background: rgba(0, 0, 0, 0.75) !important;
    backdrop-filter: blur(3px) !important;
    -webkit-backdrop-filter: blur(3px) !important;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Ensure background shows even with inline styles */
div.recrm-property-search-modal-wrapper[style*="display: flex"] {
    background-color: rgba(0, 0, 0, 0.75) !important;
    background: rgba(0, 0, 0, 0.75) !important;
}

.recrm-property-search-modal {
    position: relative !important;
    max-width: 900px !important;
    width: 100% !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
    border-radius: 8px !important;
    padding: 30px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3) !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    z-index: 1000000 !important;
}

/* Force white background on modal container */
div.recrm-property-search-modal {
    background: #fff !important;
    background-color: #fff !important;
}

.recrm-property-search-modal h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #23282d;
}

.recrm-property-search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.recrm-property-search-box input {
    flex: 1;
}

.recrm-property-search-box .button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.recrm-property-search-results {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fafafa;
}

.recrm-property-results-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.recrm-property-result-item {
    display: flex;
    gap: 15px;
    padding: 15px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.recrm-property-result-item:last-child {
    border-bottom: none;
}

.recrm-property-result-item:hover {
    background: #f8f9fa;
}

.recrm-property-result-image {
    flex-shrink: 0;
    width: 100px;
    height: 75px;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
}

.recrm-property-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.recrm-property-result-details {
    flex: 1;
    min-width: 0;
}

.recrm-property-result-details h4 {
    margin: 0 0 6px 0;
    font-size: 14px;
    font-weight: 600;
    color: #23282d;
}

.recrm-property-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 12px;
    color: #666;
}

.recrm-property-result-meta span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.recrm-property-result-address {
    margin: 0;
    font-size: 12px;
    color: #999;
    display: flex;
    align-items: center;
    gap: 4px;
}

.recrm-property-result-address::before {
    content: "\f230";
    font-family: dashicons;
}

.recrm-link-property-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    margin-top: 5px;
}

/* ===========================
 * LOADING STATES
 * =========================== */

.recrm-property-loading {
    padding: 30px;
    text-align: center;
    color: #666;
}

.recrm-loading-spinner .dashicons {
    display: inline-block;
    animation: recrm-spin 1s linear infinite;
    color: #667eea;
}

@keyframes recrm-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes recrm-fadeInScale {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===========================
 * RESPONSIVE DESIGN
 * =========================== */

@media screen and (max-width: 960px) {
    .recrm-detail-section .recrm-property-info-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
}

@media screen and (max-width: 782px) {
    /* Force vertical stacking on tablets */
    .recrm-detail-section .recrm-property-card {
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    /* Full width image on tablets */
    .recrm-detail-section .recrm-property-image {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        height: 180px !important;
        max-height: 180px !important;
    }
    
    /* Full width details */
    .recrm-detail-section .recrm-property-details {
        width: 100% !important;
    }
    
    .recrm-property-actions {
        flex-direction: column;
    }
    
    .recrm-property-actions .button {
        width: 100%;
        justify-content: center;
    }
    
    .recrm-detail-section .recrm-property-card-actions {
        flex-wrap: wrap !important;
    }
    
    .recrm-detail-section .recrm-property-card-actions .button {
        flex: 1 !important;
        justify-content: center !important;
    }
    
    .recrm-property-search-box {
        flex-direction: column;
    }
    
    .recrm-property-search-box .button {
        width: 100%;
        justify-content: center;
    }
    
    .recrm-property-result-item {
        flex-direction: column;
    }
    
    .recrm-property-result-image {
        width: 100%;
        height: 150px;
    }
}

@media screen and (max-width: 600px) {
    /* Prevent property card from exceeding container AND stack vertically */
    .recrm-detail-section .recrm-property-card {
        flex-direction: column !important;
        padding: 15px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        gap: 12px !important;
    }
    
    .recrm-detail-section .recrm-property-title {
        font-size: 15px !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    .recrm-detail-section .recrm-property-info-item {
        font-size: 12px !important;
    }
    
    .recrm-detail-section .recrm-property-price {
        font-size: 16px !important;
    }
    
    /* Ensure images don't overflow */
    .recrm-detail-section .recrm-property-image {
        width: 100% !important;
        height: 160px !important;
        min-width: 100% !important;
        max-width: 100% !important;
    }
    
    .recrm-detail-section .recrm-property-image img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    /* Modal responsive */
    .recrm-property-search-modal {
        padding: 15px !important;
        margin: 0 !important;
        max-width: calc(100vw - 20px) !important;
        max-height: calc(100vh - 20px) !important;
        box-sizing: border-box !important;
    }
    
    .recrm-property-search-modal-wrapper {
        padding: 10px !important;
    }
}

/* ===========================
 * PRINT STYLES
 * =========================== */

@media print {
    .recrm-property-actions,
    .recrm-property-card-actions {
        display: none;
    }
    
    .recrm-property-card {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
}
