/**
 * Auto-collected styles (from PHP templates).
 * Source: templates/partials/archive-search-bar.php
 */

/* Search Bar Styles */
    .hostaway-search-bar-wrapper {
        position: relative;
        z-index: 5;
        background: var(--hostaway-color-surface);
        border-radius: 12px;
        box-shadow: var(--hostaway-shadow, 0 2px 12px rgba(0, 0, 0, 0.08));
        padding: 15px;
        margin-bottom: 24px;
    }

    .search-fields-row {
        display: grid;
        grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr) minmax(0, 0.85fr) max-content;
        gap: 12px;
        align-items: center;
    }

    .search-field {
        position: relative;
    }

    .search-field-trigger {
        position: relative;
        padding: 8px 40px 8px 16px;
        border: 1px solid var(--hostaway-color-border);
        border-radius: 8px;
        cursor: pointer;
        background: var(--hostaway-color-surface);
        transition: border-color 0.2s, box-shadow 0.2s;
        min-height: 60px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .search-location .search-field-trigger::after,
    .search-dates .search-field-trigger::after,
    .search-guests .search-field-trigger::after {
        content: "";
        position: absolute;
        top: 50%;
        right: 18px;
        width: 8px;
        height: 8px;
        border-right: 2px solid var(--hostaway-color-text);
        border-bottom: 2px solid var(--hostaway-color-text);
        transform: translateY(-70%) rotate(45deg);
        pointer-events: none;
    }

    .search-location:has(.search-dropdown.active) .search-field-trigger::after,
    .search-guests:has(.search-dropdown.active) .search-field-trigger::after {
        transform: translateY(-20%) rotate(225deg);
    }

    .search-field-trigger:hover {
        border-color: var(--hostaway-color-primary);
    }

    .search-field-trigger label {
        font-size: 12px;
        font-weight: 600;
        color: var(--hostaway-color-text);
        margin-bottom: 4px;
        display: block;
        line-height: 1;
    }

    .search-field-trigger .field-value {
        font-size: 14px;
        font-weight: 500;
        color: var(--hostaway-color-text);
    }

    /* Dropdowns */
    .search-dropdown {
        position: absolute;
        top: calc(100% + 8px);
        left: 0;
        right: 0;
        background: var(--hostaway-color-surface);
        color: var(--hostaway-color-text);
        border: 1px solid var(--hostaway-color-border);
        border-radius: 8px;
        box-shadow: var(--hostaway-shadow-md, 0 4px 16px rgba(0, 0, 0, 0.15));
        z-index: 40;
        display: none;
        max-height: 280px;
        overflow-y: auto;
    }

    .search-dropdown.active {
        display: block;
    }

    .dropdown-content {
        padding: 8px;
    }

    .location-item {
        padding: 10px 12px;
        cursor: pointer;
        border-radius: 6px;
        font-size: 14px;
        font-weight: 500;
        line-height: 1.3;
        color: var(--hostaway-color-text);
        text-transform: capitalize;
        transition: background 0.2s;
    }

    .location-item:hover {
        background: var(--hostaway-color-surface-alt);
    }

    .location-item.active {
        background: var(--hostaway-color-primary-soft);
        color: var(--hostaway-color-text);
    }

    /* Guests Counter */
    .guests-counter {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px;
    }

    .counter-label,
    .guest-count {
        font-size: 14px;
        font-weight: 500;
        line-height: 1.2;
        color: var(--hostaway-color-text);
    }

    .counter-controls {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .counter-btn {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        border: 1px solid var(--hostaway-color-border);
        background: var(--hostaway-color-surface);
        color: var(--hostaway-color-text);
        cursor: pointer;
        font-size: 18px;
        line-height: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: border-color 0.2s, color 0.2s, background 0.2s;
    }

    .counter-btn:hover:not(:disabled) {
        border-color: var(--hostaway-color-primary);
        color: var(--hostaway-color-primary);
        background: var(--hostaway-color-primary-soft);
    }

    .counter-btn:disabled {
        opacity: 0.3;
        cursor: not-allowed;
    }

    .guest-count {
        font-weight: 500;
        min-width: 30px;
        text-align: center;
    }

    /* Search Button */
    .search-submit {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 12px;
        width: max-content;
        min-width: max-content;
    }

    .hostaway-search-form .search-btn {
        order: 2;
        position: static;
        top: auto;
        right: auto;
        transform: none;
        flex: 0 0 auto;
        width: auto;
        min-height: 52px;
        background: var(--hostaway-color-primary);
        color: var(--hostaway-color-on-primary);
        border: none;
        border-radius: 8px;
        padding: 0 22px;
        font-size: 16px;
        font-weight: 600;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        white-space: nowrap;
        transition: background 0.2s;
        text-decoration: none;
    }

    .hostaway-search-form .search-btn:hover {
        background: var(--hostaway-color-primary-hover);
        opacity: 1;
        transform: none;
    }

    .clear-search-btn {
        order: 1;
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 52px;
        padding: 0 18px;
        border: 1px solid var(--hostaway-color-border);
        border-radius: 8px;
        background: var(--hostaway-color-surface);
        color: var(--hostaway-color-danger);
        font-size: 14px;
        font-weight: 600;
        text-decoration: none;
        white-space: nowrap;
        transition: border-color 0.2s, background 0.2s, color 0.2s;
    }

    .clear-search-btn:hover {
        border-color: var(--hostaway-color-danger);
        background: var(--hostaway-color-surface-muted);
        color: var(--hostaway-color-danger-hover);
    }

    /* Calendar Popup */
    .calendar__shadow {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
        display: none;
    }

    .calendar__shadow.active {
        display: block;
    }

    .archive-calendar-popup {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: white;
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
        z-index: 9999;
        width: 90%;
        max-width: 900px;
        max-height: 90vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .archive-calendar-popup.hidden {
        display: none;
    }

    body.modal-open {
        overflow: hidden;
    }

    .popup-container {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    .popup-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20px 24px;
        border-bottom: 1px solid var(--hostaway-color-border-light);
    }

    .popup-header-content {
        display: flex;
        align-items: center;
        gap: 20px;
    }

    .popup-header h3 {
        margin: 0;
        font-size: 20px;
        font-weight: 500;
        color: var(--hostaway-color-text);
    }

    .popup-clear-btn,
    .popup-close-btn {
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
        color: var(--hostaway-color-text);
        transition: color 0.2s;
    }

    .popup-clear-btn:hover,
    .popup-close-btn:hover {
        color: var(--hostaway-color-danger);
    }

    .popup-selected-dates {
        padding: 16px 24px;
        background: var(--hostaway-color-surface-alt);
        border-bottom: 1px solid var(--hostaway-color-border-light);
    }

    .selected-dates-info {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .nights-count {
        color: var(--hostaway-color-text);
        font-size: 14px;
    }

    .calendar-navigation {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 24px;
        border-bottom: 1px solid var(--hostaway-color-border-light);
    }

    .nav-btn {
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
        border-radius: 50%;
        transition: background 0.2s;
    }

    .nav-btn:hover:not(:disabled) {
        background: var(--hostaway-color-surface-alt);
    }

    .nav-btn:disabled {
        opacity: 0.3;
        cursor: not-allowed;
    }

    .calendar-months {
        display: flex;
        gap: 20px;
        font-weight: 600;
    }

    .calendar-body {
        flex: 1;
        overflow-y: auto;
        padding: 24px;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 24px;
    }

    .month {
        display: flex;
        flex-direction: column;
    }

    .weekday-header {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 4px;
        margin-bottom: 8px;
    }

    .weekday {
        text-align: center;
        font-size: 12px;
        font-weight: 600;
        color: var(--hostaway-color-text);
        padding: 8px 0;
    }

    .days-grid {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 4px;
    }

    .day {
        aspect-ratio: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        border-radius: 8px;
        transition: all 0.2s;
    }

    .day:not(.disabled):hover {
        background: var(--hostaway-color-surface-alt);
    }

    .day.disabled {
        opacity: 0.3;
        cursor: not-allowed;
    }

    .day.selected .dayBox {
        background: var(--hostaway-color-danger);
        color: white;
        border-radius: 50%;
    }

    .day.in-range {
        background: rgba(231, 76, 60, 0.1);
    }

    .dayBox {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        font-size: 14px;
    }

    .popup-footer {
        display: flex;
        justify-content: flex-end;
        gap: 12px;
        padding: 20px 24px;
        border-top: 1px solid var(--hostaway-color-border-light);
    }

    .btn-secondary,
    .btn-primary {
        padding: 12px 24px;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
    }

    .btn-secondary {
        background: white;
        border: 1px solid var(--hostaway-color-border);
        color: var(--hostaway-color-text);
    }

    .btn-secondary:hover {
        background: var(--hostaway-color-surface-alt);
    }

    .btn-primary {
        background: var(--hostaway-color-danger);
        border: none;
        color: white;
    }

    .btn-primary:hover {
        background: var(--hostaway-color-danger-hover);
    }

    @media (max-width: 768px) {
        .archive-calendar-popup {
            width: 95%;
            max-height: 95vh;
        }

        .calendar-body {
            grid-template-columns: 1fr;
        }
    }

/* Archive page search bar polish (formerly in properties.css) */
.post-type-archive-property .archive-search-section .hostaway-search-bar-wrapper {
    border-radius: 60px;
}

.post-type-archive-property .archive-search-section .hostaway-search-bar-wrapper .search-field-trigger,
.post-type-archive-property .archive-search-section .search-btn,
.post-type-archive-property .archive-search-section .clear-search-btn {
    border-radius: 50px;
}

.hostaway-search-bar-wrapper:has(.search-dropdown.active) {
    z-index: 40;
}

/* 1280 / 1366: keep one row, slightly tighter fields */
@media (max-width: 1280px) {
    .search-fields-row {
        gap: 10px;
    }

    .hostaway-search-form .search-btn {
        padding: 0 18px;
    }
}

/* Tablet and below: Location + Dates, then Guests + Clear All + Search.
   Open menus sit in the flow so they don't cover the second row. */
@media (max-width: 1024px) {
    .search-fields-row {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    .search-location,
    .search-dates {
        flex: 1 1 calc(50% - 5px);
        max-width: calc(50% - 5px);
        min-width: 0;
    }

    .search-guests {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
    }

    .search-submit {
        flex: 0 0 auto;
        width: auto;
        min-width: 0;
        justify-content: flex-end;
        gap: 10px;
    }

    .hostaway-search-form .search-btn,
    .clear-search-btn {
        min-height: 60px;
    }

    .post-type-archive-property .archive-search-section .hostaway-search-bar-wrapper {
        border-radius: 28px;
    }

    .search-dropdown.active {
        position: relative;
        top: 8px;
        left: auto;
        right: auto;
        width: 100%;
    }
}

/* Phones: tighter spacing, smaller type, fields and buttons the same height */
@media (max-width: 580px) {
    .hostaway-search-bar-wrapper {
        padding: 10px;
    }

    .search-fields-row {
        gap: 8px;
    }

    .search-field-trigger {
        min-height: 44px;
        padding: 5px 24px 5px 10px;
    }

    .search-field-trigger label {
        font-size: 10px;
        margin-bottom: 1px;
    }

    .search-field-trigger .field-value {
        font-size: 12px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .post-type-archive-property .archive-search-section .hostaway-search-bar-wrapper .search-field-trigger,
    .post-type-archive-property .archive-search-section .search-btn,
    .post-type-archive-property .archive-search-section .clear-search-btn {
        border-radius: 10px;
    }

    .search-location .search-field-trigger::after,
    .search-dates .search-field-trigger::after,
    .search-guests .search-field-trigger::after {
        right: 12px;
        width: 7px;
        height: 7px;
    }

    .search-submit {
        gap: 8px;
    }

    .hostaway-search-form .search-btn,
    .clear-search-btn {
        min-height: 44px;
        padding: 0 12px;
        font-size: 12px;
        border-radius: 10px;
    }

    .post-type-archive-property .archive-search-section .hostaway-search-bar-wrapper {
        border-radius: 20px;
    }
}

@media (max-width: 375px) {
    .hostaway-search-form .search-btn,
    .clear-search-btn {
        padding: 0 12px;
        font-size: 12px;
    }

    .post-type-archive-property .archive-search-section .hostaway-search-bar-wrapper {
        border-radius: 16px;
        padding: 8px;
    }
}
