/**
 * MOBILE-OPTIMIZED Advanced Search Bar - iPhone Date Fix
 * Theme Color: #002349
 * CRITICAL FIX: iPhone date selection now works properly
 */

:root {
    --hk-primary: #002349;
    --hk-primary-light: #003d7a;
    --hk-primary-dark: #001529;
    --hk-accent: #0066cc;
    --hk-text: #2C3E50;
    --hk-text-light: #718096;
    --hk-border: #E2E8F0;
    --hk-bg: #F7FAFC;
    --hk-white: #FFFFFF;
    --hk-shadow: 0 4px 20px rgba(0, 35, 73, 0.15);
    --hk-shadow-lg: 0 10px 40px rgba(0, 35, 73, 0.2);
    --hk-radius: 16px;
    --hk-radius-sm: 12px;
    --hk-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===================================
   SEARCH BAR WRAPPER
   =================================== */
.hk-advanced-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.hk-advanced-search-wrapper.hk-standalone-search {
    padding: 0 20px;
}

.hk-search-bar-advanced {
    background: var(--hk-white);
    border-radius: var(--hk-radius);
    box-shadow: var(--hk-shadow);
    padding: 24px;
    margin: 32px 0;
    border: 1px solid rgba(0, 35, 73, 0.08);
}

/* ===================================
   MAIN SEARCH FIELDS
   =================================== */
.hk-search-main-fields {
    display: grid;
    grid-template-columns: 1fr 350px 1fr 50px 100px auto;
    gap: 16px;
    align-items: end;
}

.hk-search-field {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.hk-field-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--hk-primary);
    margin-bottom: 10px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===================================
   INPUT FIELDS
   =================================== */
.hk-field-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--hk-border);
    background: var(--hk-white);
    border-radius: var(--hk-radius-sm);
    font-size: 15px;
    font-weight: 500;
    color: var(--hk-text);
    outline: none;
    transition: var(--hk-transition);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-sizing: border-box;
}

.hk-field-input:focus {
    border-color: var(--hk-primary);
    box-shadow: 0 0 0 4px rgba(0, 35, 73, 0.1);
}

.hk-field-input::placeholder {
    color: var(--hk-text-light);
    font-weight: 400;
}

/* ===================================
   DATE INPUTS - DESKTOP
   =================================== */
.hk-field-when {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 6px;
    align-items: end;
}

.hk-date-group1 {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.hk-date-input {
    position: relative;
    color: var(--hk-text);
    cursor: pointer !important;
    max-width: 100%;
    box-sizing: border-box;
}

/* Desktop date input styling */
input[type="date"].hk-field-input {
    position: relative;
    color: var(--hk-text);
    cursor: pointer !important;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

input[type="date"].hk-field-input::-webkit-calendar-picker-indicator {
    cursor: pointer !important;
    opacity: 1 !important;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    color: transparent;
    background: transparent;
}

.hk-date-separator {
    color: var(--hk-text-light);
    font-weight: 300;
    font-size: 18px;
    flex-shrink: 0;
    align-self: center;
    padding-bottom: 14px;
}

/* ===================================
   GUEST COUNTER
   =================================== */
.hk-guest-counter {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--hk-white);
    border: 2px solid var(--hk-border);
    border-radius: var(--hk-radius-sm);
    padding: 0px 4px 0px 4px;
    transition: var(--hk-transition);
}

.hk-guest-counter:focus-within {
    border-color: var(--hk-primary);
    box-shadow: 0 0 0 4px rgba(0, 35, 73, 0.1);
}

.hk-guest-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--hk-primary);
    color: var(--hk-white);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--hk-transition);
    flex-shrink: 0;
}

.hk-guest-btn:hover:not(:disabled) {
    background: var(--hk-primary-light);
    transform: scale(1.05);
}

.hk-guest-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.hk-guest-btn:disabled {
    background: var(--hk-border);
    cursor: not-allowed;
    opacity: 0.5;
}

.hk-guest-btn svg {
    width: 16px;
    height: 16px;
}

.hk-guest-display {
    flex: 1;
    text-align: center;
    border: none;
    background: transparent;
    font-size: 16px;
    font-weight: 700;
    color: var(--hk-primary);
    padding: 8px;
    min-width: 40px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===================================
   FILTER BUTTON
   =================================== */
.hk-filter-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 56px;
    height: 46px;
    padding: 0;
    background: linear-gradient(135deg, var(--hk-primary) 0%, var(--hk-primary-dark) 100%);
    border: none;
    border-radius: var(--hk-radius-sm);
    color: var(--hk-white);
    cursor: pointer;
    transition: var(--hk-transition);
    box-shadow: 0 4px 12px rgba(0, 35, 73, 0.3);
}

.hk-filter-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 35, 73, 0.4);
}

.hk-filter-count {
    position: absolute;
    top: -6px;
    right: -6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: #E74C3C;
    color: var(--hk-white);
    font-size: 11px;
    font-weight: 700;
    border-radius: 12px;
    border: 3px solid var(--hk-white);
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.4);
}

/* ===================================
   SEARCH BUTTON
   =================================== */
.hk-search-submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 32px;
    background: linear-gradient(135deg, var(--hk-primary) 0%, var(--hk-primary-dark) 100%);
    color: var(--hk-white);
    border: none;
    border-radius: var(--hk-radius-sm);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--hk-transition);
    box-shadow: 0 4px 12px rgba(0, 35, 73, 0.3);
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.hk-search-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 35, 73, 0.4);
}

/* ===================================
   CITY DROPDOWN
   =================================== */
.hk-city-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--hk-white);
    border-radius: var(--hk-radius-sm);
    box-shadow: var(--hk-shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    border: 1px solid var(--hk-border);
}

.hk-city-item {
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s ease;
    color: var(--hk-text);
    font-weight: 500;
}

.hk-city-item:hover {
    background: rgba(0, 35, 73, 0.08);
    color: var(--hk-primary);
}

/* ===================================
   FILTER POPUP
   =================================== */
.hk-filter-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.hk-filter-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 35, 73, 0.7);
    backdrop-filter: blur(4px);
}

.hk-filter-content {
    position: relative;
    background: var(--hk-white);
    border-radius: var(--hk-radius);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 35, 73, 0.3);
}

.hk-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 2px solid var(--hk-border);
}

.hk-filter-header h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--hk-primary);
    margin: 0;
}

.hk-filter-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(0, 35, 73, 0.08);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--hk-transition);
    color: var(--hk-primary);
}

.hk-filter-close:hover {
    background: var(--hk-primary);
    color: var(--hk-white);
    transform: rotate(90deg);
}

.hk-filter-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.hk-filter-section {
    margin-bottom: 24px;
}

.hk-filter-label {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--hk-primary);
    margin-bottom: 12px;
}

.hk-filter-input,
.hk-filter-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--hk-border);
    border-radius: var(--hk-radius-sm);
    font-size: 15px;
    color: var(--hk-text);
    transition: var(--hk-transition);
}

.hk-filter-input:focus,
.hk-filter-select:focus {
    outline: none;
    border-color: var(--hk-primary);
    box-shadow: 0 0 0 4px rgba(0, 35, 73, 0.1);
}

/* Price Inputs */
.hk-price-inputs {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: end;
}

.hk-price-input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--hk-text);
    margin-bottom: 8px;
}

.hk-price-input-wrapper {
    position: relative;
}

.hk-currency-symbol {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    color: var(--hk-primary);
}

.hk-price-input {
    padding-left: 36px !important;
}

/* Number Buttons */
.hk-number-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hk-number-btn {
    padding: 10px 20px;
    background: var(--hk-white);
    border: 2px solid var(--hk-border);
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    color: var(--hk-text);
    cursor: pointer;
    transition: var(--hk-transition);
}

.hk-number-btn:hover {
    border-color: var(--hk-primary);
    color: var(--hk-primary);
}

.hk-number-btn.active {
    background: var(--hk-primary);
    color: var(--hk-white);
    border-color: var(--hk-primary);
}

/* Checkbox Group */
.hk-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hk-checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 12px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.hk-checkbox-label:hover {
    background: rgba(0, 35, 73, 0.05);
}

.hk-checkbox-label input[type="checkbox"],
.hk-checkbox-label input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--hk-primary);
}

/* Amenities Grid */
.hk-amenities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.hk-amenity-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--hk-white);
    border: 2px solid var(--hk-border);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--hk-transition);
}

.hk-amenity-checkbox:hover {
    border-color: var(--hk-primary);
}

.hk-amenity-checkbox.selected {
    background: rgba(0, 35, 73, 0.08);
    border-color: var(--hk-primary);
}

.hk-amenity-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--hk-primary);
}

/* Filter Footer */
.hk-filter-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-top: 2px solid var(--hk-border);
    gap: 16px;
}

.hk-filter-clear,
.hk-filter-apply {
    padding: 14px 32px;
    border: none;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--hk-transition);
}

.hk-filter-clear {
    background: transparent;
    color: var(--hk-text);
    text-decoration: underline;
}

.hk-filter-apply {
    background: linear-gradient(135deg, var(--hk-primary) 0%, var(--hk-primary-dark) 100%);
    color: var(--hk-white);
    box-shadow: 0 4px 12px rgba(0, 35, 73, 0.3);
    flex: 1;
}

/* ===================================
   TABLET
   =================================== */
@media (max-width: 1024px) {
    .hk-search-main-fields {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .hk-field-when {
        grid-column: 1 / -1;
    }
    
    .hk-field-submit {
        grid-column: 1 / -1;
    }
}

/* ===================================
   MOBILE - CRITICAL IPHONE FIX
   =================================== */
@media (max-width: 768px) {
    .hk-advanced-search-wrapper {
        padding: 0 !important;
    }
    
    .hk-search-bar-advanced {
        border-radius: 12px;
        padding: 16px;
        margin: 16px;
        max-width: calc(100vw - 32px);
        box-sizing: border-box;
    }
    
    /* Stack all fields vertically */
    .hk-search-main-fields {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }
    
    .hk-search-field {
        width: 100%;
    }
    
    /* ===================================
       CRITICAL IPHONE DATE FIX
       =================================== */
    
    /* Stack dates vertically on mobile */
    .hk-field-when {
        display: flex;
        flex-direction: column;
        gap: 16px;
        width: 100%;
    }
    
    .hk-date-separator {
        display: none !important;
    }
    
    .hk-date-group1 {
        width: 100%;
        min-width: 0;
    }
    
    /* CRITICAL: Mobile date input fixes for iPhone */
    input[type="date"].hk-field-input {
        /* Sizing */
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: 50px !important;
        
        /* Prevent overflow */
        box-sizing: border-box !important;
        overflow: visible !important;
        
        /* Touch-friendly padding */
        padding: 12px 40px 12px 14px !important;
        
        /* Font sizing - prevents iOS zoom */
        font-size: 16px !important;
        line-height: 1.5 !important;
        
        /* Remove default appearance */
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
        
        /* Allow user interaction */
        -webkit-user-select: auto !important;
        user-select: auto !important;
        pointer-events: auto !important;
        
        /* Text color */
        color: var(--hk-text) !important;
    }
    
    /* Fix calendar picker on iPhone */
    input[type="date"].hk-field-input::-webkit-calendar-picker-indicator {
        /* Position calendar icon */
        position: absolute !important;
        right: 12px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        
        /* Size */
        width: 24px !important;
        height: 24px !important;
        
        /* Make it visible and clickable */
        opacity: 0.6 !important;
        cursor: pointer !important;
        pointer-events: auto !important;
        
        /* Reset any blocking styles */
        background: transparent !important;
        color: var(--hk-primary) !important;
    }
    
    /* Improve date text visibility */
    input[type="date"].hk-field-input::-webkit-datetime-edit {
        color: var(--hk-text) !important;
        padding: 0 !important;
    }
    
    /* Show placeholder when empty */
    input[type="date"].hk-field-input:not(:focus)::-webkit-datetime-edit {
        color: var(--hk-text-light) !important;
    }
    
    /* Individual date components */
    input[type="date"].hk-field-input::-webkit-datetime-edit-fields-wrapper {
        padding: 0 !important;
    }
    
    input[type="date"].hk-field-input::-webkit-datetime-edit-text {
        color: var(--hk-text-light) !important;
        padding: 0 2px !important;
    }
    
    input[type="date"].hk-field-input::-webkit-datetime-edit-month-field,
    input[type="date"].hk-field-input::-webkit-datetime-edit-day-field,
    input[type="date"].hk-field-input::-webkit-datetime-edit-year-field {
        color: var(--hk-text) !important;
        padding: 0 2px !important;
    }
    
    /* Hide placeholder parts when empty */
    input[type="date"].hk-field-input:not([value])::-webkit-datetime-edit-month-field::before,
    input[type="date"].hk-field-input:not([value])::-webkit-datetime-edit-day-field::before,
    input[type="date"].hk-field-input:not([value])::-webkit-datetime-edit-year-field::before {
        content: attr(placeholder) !important;
        color: var(--hk-text-light) !important;
    }
    
    /* Label styling */
    .hk-field-label {
        font-size: 11px;
        margin-bottom: 8px;
    }
    
    /* Guest counter */
    .hk-guest-counter {
        height: 50px;
        padding: 6px;
    }
    
    .hk-guest-btn {
        width: 44px;
        height: 44px;
    }
    
    /* Full width buttons */
    .hk-filter-toggle-btn {
        width: 100%;
        height: 52px;
    }
    
    .hk-search-submit-btn {
        width: 100%;
        padding: 16px 24px;
    }
    
    /* Filter popup */
    .hk-filter-popup {
        padding: 0;
        align-items: flex-end;
    }
    
    .hk-filter-content {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 95vh;
    }
    
    .hk-price-inputs {
        grid-template-columns: 1fr;
    }
    
    .hk-price-separator {
        display: none;
    }
    
    .hk-amenities-grid {
        grid-template-columns: 1fr;
    }
}

/* ===================================
   SMALL MOBILE
   =================================== */
@media (max-width: 480px) {
    .hk-search-bar-advanced {
        padding: 12px !important;
        margin: 12px !important;
    }
    
    input[type="date"].hk-field-input {
        height: 46px !important;
        font-size: 15px !important;
    }
}