/**
 * ticketWP Search Widget Styles
 */

.ticketwp-search-container {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.ticketwp-search-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.ticketwp-search-wrapper.ticketwp-button-inside {
    gap: 0;
    flex-wrap: nowrap;
}

.ticketwp-search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
}

/* When button is inside, allow wrapper to shrink more */
.ticketwp-search-wrapper.ticketwp-button-inside .ticketwp-search-input-wrapper {
    min-width: 0;
    flex: 1 1 0%;
    width: 100%;
    max-width: 100%;
}

.ticketwp-search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 15px;
    border: 1px solid #cccccc;
    border-radius: 4px;
    font-size: 16px;
    outline: none;
}

.ticketwp-search-input-wrapper .ticketwp-search-input {
    min-width: 0;
    padding-right: 50px;
    border-radius: 4px 0 0 4px;
    border-right: none;
    flex: 1 1 auto;
    width: 100%;
    box-sizing: border-box;
}

.ticketwp-button-inside-field {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    margin: 0;
    border: none;
    border-left: 1px solid #cccccc;
    border-radius: 0 4px 4px 0;
    background-color: transparent;
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    height: 100%;
    width: auto;
    z-index: 1;
}

.ticketwp-button-inside-field:hover {
    background-color: #f5f5f5;
}

/* Override hover styles when set via Elementor controls */
.ticketwp-search-button:hover,
.ticketwp-button-inside-field:hover {
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.ticketwp-button-inside-field.ticketwp-button-image {
    border-left: none;
    padding: 0 10px;
    width: auto;
    max-width: 60px;
}

.ticketwp-button-inside-field.ticketwp-button-image img {
    max-width: 24px;
    max-height: 24px;
    display: block;
}

/* When button is inside, remove right border radius from input */
.ticketwp-search-input-wrapper .ticketwp-search-input:focus {
    border-radius: 4px 0 0 4px;
}

.ticketwp-search-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

.ticketwp-date-range-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    order: -1;
    margin-bottom: 10px;
}

.ticketwp-date-range-picker {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 0;
    border: none;
    background-color: transparent;
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
}

.ticketwp-date-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 150px;
    display: flex;
    align-items: center;
}

.ticketwp-date-start,
.ticketwp-date-end {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 1px solid #cccccc;
    border-radius: 4px;
    font-size: 16px;
    background-color: #ffffff;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    outline: none;
}

.ticketwp-date-start:focus,
.ticketwp-date-end:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

.ticketwp-calendar-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #666666;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
}

.ticketwp-date-start:focus ~ .ticketwp-calendar-icon,
.ticketwp-date-end:focus ~ .ticketwp-calendar-icon {
    color: #0073aa;
}

.ticketwp-date-range-separator {
    font-size: 14px;
    color: #666666;
    font-weight: 500;
    white-space: nowrap;
}

.ticketwp-search-button {
    padding: 10px 20px;
    background-color: #0073aa;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ticketwp-search-button:hover {
    background-color: #005a87;
}

.ticketwp-search-button img {
    display: block;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

/* Remove background when button is image type */
.ticketwp-search-button.ticketwp-button-image {
    background-color: transparent !important;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ticketwp-search-button.ticketwp-button-image:hover {
    background-color: transparent !important;
}

/* Default image button constraints - prevent huge images */
.ticketwp-search-button.ticketwp-button-image:not(.ticketwp-button-inside-field) img {
    max-width: 60px;
    max-height: 60px;
    width: auto;
    height: auto;
}

.ticketwp-ajax-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #cccccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 2px;
}

.ticketwp-ajax-results-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

/* Option 1 - Grouped List Style with Headers and Blue Bars */
.ticketwp-ajax-style-1 .ticketwp-ajax-group {
    position: relative;
    border-bottom: 1px solid #e0e0e0;
    padding-left: 4px;
}

.ticketwp-ajax-style-1 .ticketwp-ajax-group::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: #0073aa;
    display: block;
}

.ticketwp-ajax-style-1 .ticketwp-ajax-group:last-child {
    border-bottom: none;
}

.ticketwp-ajax-style-1 .ticketwp-ajax-group-header {
    padding: 10px 15px;
    background-color: #ffffff;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: #333333;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e0e0e0;
    margin: 0;
    cursor: default;
    user-select: none;
}

.ticketwp-ajax-style-1 .ticketwp-ajax-group-items {
    background-color: #ffffff;
}

.ticketwp-ajax-style-1 .ticketwp-ajax-result-item {
    border-bottom: 1px solid #eeeeee;
}

.ticketwp-ajax-style-1 .ticketwp-ajax-result-item:last-child {
    border-bottom: none;
}

.ticketwp-ajax-style-1 .ticketwp-ajax-result-link {
    display: block;
    padding: 12px 15px;
    color: #333333;
    text-decoration: none;
    transition: background-color 0.2s;
    font-size: 14px;
    line-height: 1.5;
}

.ticketwp-ajax-style-1 .ticketwp-ajax-result-item:hover {
    background-color: #f5f5f5 !important;
}

.ticketwp-ajax-style-1 .ticketwp-ajax-result-link:hover {
    background-color: transparent;
    color: #0073aa;
}

/* Option 2 - Grouped Style */
.ticketwp-ajax-style-2 .ticketwp-ajax-group {
    border-bottom: 1px solid #e0e0e0;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-group:last-child {
    border-bottom: none;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-group-header {
    padding: 10px 15px;
    background-color: #f8f8f8;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: #666666;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e0e0e0;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-group-items {
    background-color: #ffffff;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-result-item {
    border-bottom: 1px solid #f0f0f0;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-result-item:last-child {
    border-bottom: none;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-result-link {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: #333333;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
    font-size: 14px;
    line-height: 1.5;
    gap: 15px;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-result-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    overflow: hidden;
    border-radius: 6px;
    background-color: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-result-image-placeholder {
    width: 100%;
    height: 100%;
    background-color: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999999;
    font-size: 24px;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-result-image-placeholder::before {
    content: '📷';
    opacity: 0.3;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-result-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-result-title {
    font-weight: 500;
    color: #333333;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-event-venue {
    font-size: 12px;
    color: #666666;
    font-weight: normal;
    display: block;
    margin-top: 2px;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-event-venue .ticketwp-event-price {
    font-weight: 600;
    color: #333333;
}

/* Event-specific styling for style 2 */
.ticketwp-ajax-style-2 .ticketwp-ajax-event-item .ticketwp-ajax-result-link {
    align-items: flex-start;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-event-date-card {
    flex-shrink: 0;
    width: 50px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin-right: 12px;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-event-date-month {
    background-color: #4a4a4a;
    color: #ffffff;
    padding: 6px 4px;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.2;
    flex: 0 0 auto;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-event-date-day {
    background-color: #e8e8e8;
    color: #333333;
    padding: 8px 4px;
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    line-height: 1;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-result-item:hover {
    background-color: #f5f5f5 !important;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-result-link:hover {
    background-color: transparent;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-result-link:hover .ticketwp-ajax-result-title {
    color: #0073aa;
}

.ticketwp-ajax-style-2 .ticketwp-ajax-result-link:hover .ticketwp-ajax-event-venue {
    color: #0073aa;
}

.ticketwp-ajax-loading,
.ticketwp-ajax-no-results,
.ticketwp-ajax-error {
    padding: 15px;
    text-align: center;
    color: #666666;
}

.ticketwp-ajax-error {
    color: #d32f2f;
}

/* Flatpickr Date Picker Customization */
.flatpickr-calendar {
    font-family: inherit;
    box-shadow: 0 3px 13px rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay.flatpickr-disabled {
    color: #cccccc;
    cursor: not-allowed;
    background-color: #f5f5f5;
}

.flatpickr-day.flatpickr-disabled:hover {
    background-color: #f5f5f5;
    color: #cccccc;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background-color: #0073aa;
    border-color: #0073aa;
    color: #ffffff;
}

.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
    background-color: #005a87;
    border-color: #005a87;
}

.flatpickr-day.inRange {
    background-color: #e3f2fd;
    border-color: #e3f2fd;
}

.flatpickr-day:hover {
    background-color: #f0f0f0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ticketwp-search-container {
        gap: 8px;
    }
    
    /* Date Range - Stack vertically and ensure full width */
    .ticketwp-date-range-wrapper {
        width: 100%;
        margin-bottom: 12px;
    }
    
    .ticketwp-date-range-picker {
        width: 100%;
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .ticketwp-date-input-wrapper {
        width: 100%;
        flex: 1 1 100%;
        min-width: 100%;
        max-width: 100%;
    }
    
    .ticketwp-date-start,
    .ticketwp-date-end {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .ticketwp-date-range-separator {
        display: none;
    }
    
    /* Search Wrapper - Keep horizontal when button is inside, stack when outside */
    .ticketwp-search-wrapper {
        width: 100%;
        gap: 10px;
    }
    
    /* When button is inside, keep it horizontal (don't stack) */
    .ticketwp-search-wrapper.ticketwp-button-inside {
        flex-direction: row;
        gap: 0;
        flex-wrap: nowrap;
        width: 100%;
    }
    
    /* When button is outside, keep it next to search box on same line */
    .ticketwp-search-wrapper:not(.ticketwp-button-inside) {
        flex-direction: row;
        flex-wrap: nowrap;
    }
    
    /* Search Input Wrapper - Full width on mobile */
    .ticketwp-search-input-wrapper {
        width: 100%;
        flex: 1 1 100%;
        min-width: 100%;
        max-width: 100%;
    }
    
    /* When image button is outside, allow input wrapper to shrink */
    .ticketwp-search-wrapper:not(.ticketwp-button-inside) .ticketwp-search-input-wrapper {
        flex: 1 1 auto;
        min-width: 0;
    }
    
    /* When button is inside, ensure wrapper doesn't wrap - keep it in one line */
    .ticketwp-search-wrapper.ticketwp-button-inside .ticketwp-search-input-wrapper {
        flex: 1 1 0%;
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }
    
    /* Search Input - Full width, proper padding when button is inside */
    .ticketwp-search-input {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .ticketwp-search-input-wrapper .ticketwp-search-input {
        width: 100%;
        min-width: 0;
        padding-right: 50px;
        border-radius: 4px;
        border-right: 1px solid #cccccc;
    }
    
    /* When button is inside, ensure input is still visible and doesn't wrap */
    .ticketwp-search-wrapper.ticketwp-button-inside .ticketwp-search-input-wrapper {
        position: relative;
        flex: 1 1 0%;
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .ticketwp-search-wrapper.ticketwp-button-inside .ticketwp-search-input-wrapper .ticketwp-search-input {
        padding-right: 50px;
        border-radius: 4px 0 0 4px;
        border-right: none;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }
    
    /* Button inside field - Make it smaller on mobile so input is visible */
    .ticketwp-button-inside-field {
        position: absolute;
        right: 0;
        width: auto;
        min-width: 50px;
        max-width: 60px;
        padding: 0 10px;
    }
    
    .ticketwp-button-inside-field.ticketwp-button-image {
        padding: 0 8px;
        min-width: 40px;
        max-width: 50px;
    }
    
    .ticketwp-button-inside-field.ticketwp-button-image img {
        max-width: 20px;
        max-height: 20px;
    }
    
    /* Button outside field - Auto width to stay next to search box */
    .ticketwp-search-button:not(.ticketwp-button-inside-field):not(.ticketwp-button-image) {
        width: auto;
        min-width: auto;
        flex-shrink: 0;
        box-sizing: border-box;
    }
    
    /* Image button outside field - Stay next to search box, don't wrap */
    .ticketwp-search-button:not(.ticketwp-button-inside-field).ticketwp-button-image {
        width: auto;
        min-width: auto;
        max-width: none;
        margin: 0;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px;
    }
    
    .ticketwp-search-button:not(.ticketwp-button-inside-field).ticketwp-button-image img {
        max-width: 50px;
        max-height: 50px;
        width: auto;
        height: auto;
        object-fit: contain;
    }
    
    /* Ensure button doesn't appear inside when it shouldn't */
    .ticketwp-search-wrapper:not(.ticketwp-button-inside) .ticketwp-search-input-wrapper .ticketwp-search-input {
        padding-right: 15px;
        border-radius: 4px;
        border-right: 1px solid #cccccc;
    }
    
    /* AJAX Results - Full width on mobile */
    .ticketwp-ajax-results {
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    /* Make button inside field even more compact */
    .ticketwp-button-inside-field {
        min-width: 45px;
        max-width: 55px;
        padding: 0 8px;
        font-size: 14px;
    }
    
    .ticketwp-button-inside-field.ticketwp-button-image {
        min-width: 35px;
        max-width: 45px;
        padding: 0 6px;
    }
    
    .ticketwp-button-inside-field.ticketwp-button-image img {
        max-width: 18px;
        max-height: 18px;
    }
    
    /* Image button outside field on small screens */
    .ticketwp-search-button:not(.ticketwp-button-inside-field).ticketwp-button-image img {
        max-width: 40px;
        max-height: 40px;
    }
    
    /* Ensure input has enough space */
    .ticketwp-search-input-wrapper .ticketwp-search-input {
        padding-right: 45px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .ticketwp-search-wrapper.ticketwp-button-inside .ticketwp-search-input-wrapper .ticketwp-search-input {
        padding-right: 45px;
    }
    
    /* Date inputs - ensure they're readable */
    .ticketwp-date-start,
    .ticketwp-date-end {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px 40px 12px 15px;
    }
}