/**
 * LMS Property Advanced Search Styles
 *
 * Styles for all 5 search form layouts:
 * - horizontal (hero/inline style)
 * - vertical (stacked full-width)
 * - advanced (basic fields + expandable section)
 * - widget (compact sidebar)
 * - half-map (split view: 40% filters, 60% map)
 *
 * @package WP_Loan_Management_System
 * @version 1.2.0
 */

/* ==========================================================================
   1. Base Search Form Styles
   ========================================================================== */

.lms-search-form {
    position: relative;
    margin: 0 0 30px 0;
    padding: 0;
    background: #fff;
    border-radius: 4px;
}

.lms-search-form * {
    box-sizing: border-box;
}

.lms-search-form-inner {
    padding: 20px;
}

/* Form Fields */
.lms-search-field {
    margin-bottom: 15px;
}

.lms-search-field label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.lms-search-field input[type="text"],
.lms-search-field input[type="number"],
.lms-search-field input[type="email"],
.lms-search-field select {
    width: 100%;
    padding: 10px 15px;
    font-size: 14px;
    line-height: 1.5;
    color: #555;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
    transition: border-color 0.3s ease;
}

.lms-search-field input:focus,
.lms-search-field select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px rgba(0, 115, 170, 0.1);
}

.lms-search-field input::placeholder {
    color: #999;
}

/* Range Fields */
.lms-search-range {
    display: flex;
    gap: 10px;
    align-items: center;
}

.lms-search-range input {
    flex: 1;
}

.lms-search-range-separator {
    flex: 0 0 auto;
    color: #999;
    font-size: 14px;
}

/* Checkbox Fields */
.lms-search-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.lms-search-checkbox input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.lms-search-checkbox label {
    margin: 0;
    font-weight: normal;
    cursor: pointer;
}

/* Buttons */
.lms-search-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.lms-search-submit,
.lms-search-reset {
    padding: 12px 30px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lms-search-submit {
    background: #0073aa;
    color: #fff;
    flex: 1;
}

.lms-search-submit:hover {
    background: #005a87;
}

.lms-search-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.lms-search-reset {
    background: #f5f5f5;
    color: #555;
    flex: 0 0 auto;
}

.lms-search-reset:hover {
    background: #e5e5e5;
}

/* Loading State */
.lms-search-form.loading {
    opacity: 0.6;
    pointer-events: none;
}

.lms-search-loading {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.lms-search-form.loading .lms-search-loading {
    display: block;
}

.lms-search-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 115, 170, 0.2);
    border-radius: 50%;
    border-top-color: #0073aa;
    animation: lms-spin 0.8s linear infinite;
}

@keyframes lms-spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   2. Horizontal Layout (Hero Style)
   ========================================================================== */

.lms-search-form.layout-horizontal {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.lms-search-form.layout-horizontal .lms-search-form-inner {
    padding: 0;
}

.lms-search-form.layout-horizontal .lms-search-field label {
    color: #fff;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lms-search-form.layout-horizontal .lms-search-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.lms-search-form.layout-horizontal .lms-search-field {
    margin-bottom: 0;
}

.lms-search-form.layout-horizontal .lms-search-buttons {
    margin-top: 0;
}

.lms-search-form.layout-horizontal .lms-search-submit {
    background: #fff;
    color: #667eea;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.lms-search-form.layout-horizontal .lms-search-submit:hover {
    background: #f5f5f5;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.lms-search-form.layout-horizontal .lms-search-reset {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.lms-search-form.layout-horizontal .lms-search-reset:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   3. Vertical Layout (Stacked Full-Width)
   ========================================================================== */

.lms-search-form.layout-vertical {
    border: 1px solid #e5e5e5;
}

.lms-search-form.layout-vertical .lms-search-fields {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.lms-search-form.layout-vertical .lms-search-field {
    margin-bottom: 0;
}

.lms-search-form.layout-vertical .lms-search-range {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 15px;
}

/* ==========================================================================
   4. Advanced Layout (Basic + Expandable Section)
   ========================================================================== */

.lms-search-form.layout-advanced {
    border: 1px solid #e5e5e5;
}

.lms-search-form.layout-advanced .lms-search-basic-fields {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.lms-search-form.layout-advanced .lms-search-advanced-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: #f5f5f5;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    transition: background 0.3s ease;
    width: 100%;
    margin-bottom: 15px;
}

.lms-search-form.layout-advanced .lms-search-advanced-toggle:hover {
    background: #e5e5e5;
}

.lms-search-form.layout-advanced .lms-search-advanced-toggle .lms-toggle-icon {
    transition: transform 0.3s ease;
}

.lms-search-form.layout-advanced .lms-search-advanced-toggle.active .lms-toggle-icon {
    transform: rotate(180deg);
}

.lms-search-form.layout-advanced .lms-search-advanced-fields {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 15px;
    padding-top: 15px;
    border-top: 1px solid #e5e5e5;
}

.lms-search-form.layout-advanced .lms-search-advanced-fields.active {
    display: grid;
}

.lms-search-form.layout-advanced .lms-search-field.full-width {
    grid-column: 1 / -1;
}

/* ==========================================================================
   5. Widget Layout (Compact Sidebar)
   ========================================================================== */

.lms-search-form.layout-widget {
    background: #f9f9f9;
    border: 1px solid #e5e5e5;
}

.lms-search-form.layout-widget .lms-search-form-inner {
    padding: 15px;
}

.lms-search-form.layout-widget .lms-search-field {
    margin-bottom: 12px;
}

.lms-search-form.layout-widget .lms-search-field label {
    font-size: 13px;
    margin-bottom: 4px;
}

.lms-search-form.layout-widget .lms-search-field input,
.lms-search-form.layout-widget .lms-search-field select {
    padding: 8px 12px;
    font-size: 13px;
}

.lms-search-form.layout-widget .lms-search-buttons {
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
}

.lms-search-form.layout-widget .lms-search-submit,
.lms-search-form.layout-widget .lms-search-reset {
    width: 100%;
    padding: 10px;
    font-size: 13px;
}

/* ==========================================================================
   6. Half-Map Layout (Split View)
   ========================================================================== */

.lms-search-form.layout-half-map {
    display: grid;
    grid-template-columns: 40% 60%;
    gap: 0;
    margin: 0;
    border-radius: 0;
}

.lms-search-form.layout-half-map .lms-search-form-inner {
    padding: 30px;
    background: #fff;
    border-right: 1px solid #e5e5e5;
    overflow-y: auto;
    max-height: 600px;
}

.lms-search-form.layout-half-map .lms-search-map-placeholder {
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 16px;
    min-height: 600px;
    background-image:
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.lms-search-form.layout-half-map .lms-search-fields {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* ==========================================================================
   7. Autocomplete Dropdown
   ========================================================================== */

.lms-autocomplete-wrapper {
    position: relative;
}

.lms-autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 3px 3px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.lms-autocomplete-results.active {
    display: block;
}

.lms-autocomplete-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f5f5f5;
}

.lms-autocomplete-item:last-child {
    border-bottom: none;
}

.lms-autocomplete-item:hover,
.lms-autocomplete-item.active {
    background: #f5f5f5;
}

.lms-autocomplete-thumbnail {
    flex: 0 0 50px;
    height: 50px;
    border-radius: 3px;
    background-size: cover;
    background-position: center;
    background-color: #e5e5e5;
}

.lms-autocomplete-info {
    flex: 1;
}

.lms-autocomplete-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 4px 0;
}

.lms-autocomplete-meta {
    font-size: 12px;
    color: #999;
}

.lms-autocomplete-loading {
    padding: 15px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

.lms-autocomplete-empty {
    padding: 15px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* ==========================================================================
   8. Search Results & Summary
   ========================================================================== */

.lms-search-results {
    margin: 30px 0;
}

.lms-search-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f9f9f9;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    margin-bottom: 20px;
}

.lms-search-results-count {
    font-size: 14px;
    color: #555;
}

.lms-search-results-count strong {
    font-weight: 700;
    color: #333;
}

.lms-search-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.lms-active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
    color: #555;
}

.lms-active-filter-tag .remove {
    cursor: pointer;
    color: #999;
    font-weight: bold;
    transition: color 0.2s ease;
}

.lms-active-filter-tag .remove:hover {
    color: #d00;
}

.lms-search-clear-all {
    padding: 5px 12px;
    background: #fff;
    border: 1px solid #d00;
    border-radius: 3px;
    color: #d00;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lms-search-clear-all:hover {
    background: #d00;
    color: #fff;
}

.lms-search-sorting {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lms-search-sorting label {
    font-size: 13px;
    color: #555;
    margin: 0;
}

.lms-search-sorting select {
    padding: 5px 10px;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.lms-search-view-toggle {
    display: flex;
    gap: 5px;
}

.lms-search-view-toggle button {
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lms-search-view-toggle button:hover {
    background: #f5f5f5;
}

.lms-search-view-toggle button.active {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
}

/* No Results Message */
.lms-search-no-results {
    padding: 60px 20px;
    text-align: center;
    background: #f9f9f9;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
}

.lms-search-no-results-icon {
    font-size: 48px;
    color: #ccc;
    margin-bottom: 20px;
}

.lms-search-no-results h3 {
    margin: 0 0 10px 0;
    font-size: 20px;
    color: #333;
}

.lms-search-no-results p {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 14px;
}

.lms-search-suggestions {
    list-style: none;
    padding: 0;
    margin: 20px 0 0 0;
    text-align: left;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.lms-search-suggestions li {
    padding: 8px 0;
    color: #555;
    font-size: 14px;
}

.lms-search-suggestions li:before {
    content: "•";
    color: #0073aa;
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-right: 8px;
}

/* ==========================================================================
   9. Pagination & Load More
   ========================================================================== */

.lms-search-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 30px 0;
}

.lms-search-pagination button,
.lms-search-pagination a {
    padding: 10px 15px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
    color: #555;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.lms-search-pagination button:hover,
.lms-search-pagination a:hover {
    background: #f5f5f5;
}

.lms-search-pagination button.active,
.lms-search-pagination a.active {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
}

.lms-search-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lms-search-load-more {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 30px auto;
    padding: 15px;
    background: #fff;
    border: 2px solid #0073aa;
    border-radius: 3px;
    color: #0073aa;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lms-search-load-more:hover {
    background: #0073aa;
    color: #fff;
}

.lms-search-load-more:disabled {
    border-color: #ccc;
    color: #ccc;
    cursor: not-allowed;
}

.lms-search-load-more:disabled:hover {
    background: #fff;
    color: #ccc;
}

/* ==========================================================================
   10. Responsive Breakpoints
   ========================================================================== */

/* Tablets (768px and below) */
@media (max-width: 768px) {
    .lms-search-form.layout-horizontal .lms-search-fields {
        grid-template-columns: repeat(2, 1fr);
    }

    .lms-search-form.layout-advanced .lms-search-basic-fields,
    .lms-search-form.layout-advanced .lms-search-advanced-fields {
        grid-template-columns: repeat(2, 1fr);
    }

    .lms-search-form.layout-half-map {
        grid-template-columns: 1fr;
    }

    .lms-search-form.layout-half-map .lms-search-form-inner {
        border-right: none;
        border-bottom: 1px solid #e5e5e5;
        max-height: none;
    }

    .lms-search-form.layout-half-map .lms-search-map-placeholder {
        min-height: 400px;
    }

    .lms-search-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .lms-search-active-filters {
        width: 100%;
    }

    .lms-search-sorting {
        width: 100%;
        justify-content: space-between;
    }
}

/* Mobile (480px and below) */
@media (max-width: 480px) {
    .lms-search-form.layout-horizontal {
        padding: 20px;
    }

    .lms-search-form.layout-horizontal .lms-search-fields {
        grid-template-columns: 1fr;
    }

    .lms-search-form.layout-advanced .lms-search-basic-fields,
    .lms-search-form.layout-advanced .lms-search-advanced-fields {
        grid-template-columns: 1fr;
    }

    .lms-search-buttons {
        flex-direction: column;
    }

    .lms-search-submit,
    .lms-search-reset {
        width: 100%;
    }

    .lms-search-pagination {
        flex-wrap: wrap;
    }

    .lms-search-view-toggle {
        width: 100%;
        justify-content: stretch;
    }

    .lms-search-view-toggle button {
        flex: 1;
    }
}

/* ==========================================================================
   11. Accessibility
   ========================================================================== */

/* Focus states for keyboard navigation */
.lms-search-field input:focus,
.lms-search-field select:focus,
.lms-search-submit:focus,
.lms-search-reset:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Screen reader only text */
.lms-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   12. Print Styles
   ========================================================================== */

@media print {
    .lms-search-form,
    .lms-search-buttons,
    .lms-search-pagination,
    .lms-search-load-more {
        display: none !important;
    }

    .lms-search-results {
        margin: 0;
    }
}
