/* search.css */

/* --- Home Bottom Search Bar --- */
.search-bar-home-container {
    position: fixed;
    bottom: 24px;
    left: 16px;
    right: 16px;
    z-index: 1000;
    /* Above map, below overlays */
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    /* Allow clicking through the container area */
}

/* Hide search bar when showing results */
body.showing-results .search-bar-home-container {
    display: none;
}

/* Hide search bar when selecting point on map */
body.selecting-map-point .search-bar-home-container {
    display: none;
}

/* Hide navbar and mobile summary when search overlay is active */
body.search-active .navbar,
body.search-active #navbar,
body.search-active header,
body.search-active .header,
body.search-active #mobileTopBar {
    display: none !important;
}

body.search-active .mobile-summary-bar,
body.search-active #mobileSummaryBar,
body.search-active .mobile-summary,
body.search-active #mobileConfigSummary {
    display: none !important;
}

/* FAB for Current Location */
.location-fab {
    align-self: flex-end;
    width: 48px;
    height: 48px;
    background-color: white;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    /* slate-600 */
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.2s, background-color 0.2s, color 0.2s;
}

.location-fab.active {
    color: #4f46e5;
    /* indigo-600 - matches route line */
}

.location-fab:active {
    transform: scale(0.95);
    background-color: #f8fafc;
}

/* FABs Row Container (Spinner + Location FAB) */
.search-bar-fabs-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    pointer-events: none;
    /* Allow clicking through empty space */
}

/* Loading Spinner FAB */
.loading-spinner-fab {
    width: 48px;
    height: 48px;
    background-color: white;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4f46e5;
    /* indigo-600 */
    cursor: default;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 0.3s ease;

    /* Hidden by default */
    opacity: 0;
    transform: scale(0);
}

.loading-spinner-fab.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* Spinner rotation animation */
.spinner-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* The Search Bar Itself */
.search-bar-home {
    background-color: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 12px 16px;
    /* Reduced padding */
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.2s;
}

.search-bar-home:active {
    transform: scale(0.98);
}

.search-bar-icon {
    color: #ef4444;
    /* red-500, similar to Airbnb/Maps accent */
    width: 24px;
    height: 24px;
}

.search-bar-text {
    font-size: 14px;
    /* Reduced font size */
    font-weight: 500;
    color: #64748b;
    /* slate-500 */
    transition: color 0.2s;
}

/* Purple text for "Lokasi saya" in search inputs */
.search-input.location-active {
    color: #4f46e5;
    /* indigo-600 - matches route line */
    font-weight: 500;
}


/* Body lock for iOS */
/* Body lock for iOS - REMOVED (Floating sheet doesn't need it) */
/* html.search-active, body.search-active styles removed */

/* --- Floating Search Overlay --- */
.search-overlay {
    position: fixed;
    top: 16px;
    left: 16px;
    right: 16px;
    height: auto;
    max-height: 80vh;
    /* Limit height */
    background-color: #f8fafc;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    border-radius: 24px;
    /* Rounded corners */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    /* Deep shadow */
    overflow: hidden;
    /* Clip content to corners */

    /* Animation */
    transform: translateY(-120%);
    /* Slide from top */
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);

    /* Ensure it sits safely on top */
    margin-top: env(safe-area-inset-top, 0px);
}

.search-overlay.open {
    transform: translateY(0);
}

/* Header */
.search-header {
    background-color: white;
    padding: 12px 16px;
    /* Reduced padding */
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    /* Never shrink */
}

.search-header-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-back-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #1e293b;
    transition: background-color 0.2s;
}

.search-back-btn:active {
    background-color: #f1f5f9;
}

.search-inputs {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-input-row {
    position: relative;
    display: flex;
    align-items: center;
}

/* Dot indicators */
.input-dot {
    position: absolute;
    left: 12px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    z-index: 10;
}

.input-dot.start {
    background-color: #ea580c;
    /* Orange-600 */
    border: 2px solid #fff7ed;
    /* Orange-50 */
}

/* Green */
.input-dot.end {
    background-color: #059669;
    /* Emerald-600 */
    border: 2px solid #ecfdf5;
    /* Emerald-50 */
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 32px;
    /* Reduced vertical padding, Increased right padding for X button */
    /* Space for dot */
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background-color: white;
    /* Changed from #f1f5f9 to white */
    font-size: 16px;
    /* 16px to prevent iOS zoom */
    color: #1e293b;
    outline: none;
    transition: background-color 0.2s, border-color 0.2s;
}

.search-input:focus {
    background-color: white;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.clear-input-btn {
    position: absolute;
    right: 8px;
    padding: 6px;
    color: #94a3b8;
    /* slate-400 */
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.2s;
}

.clear-input-btn:hover {
    color: #475569;
    /* slate-600 */
}

.clear-input-btn:active {
    background-color: #f1f5f9;
}

/* Results List */
.search-results {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    /* Allow vertical scroll */
    padding: 8px 0;
    background-color: white;
}

.search-results.hidden {
    display: none;
}

/* Remove footer top border when results are hidden to avoid double border with header */
.search-results.hidden+.search-footer {
    border-top: none;
}

.search-result-item {
    padding: 12px 16px;
    /* Reduced padding */
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: background-color 0.15s;
}

.search-result-item:active {
    background-color: #f8fafc;
}

.result-icon {
    color: #94a3b8;
    margin-top: 2px;
}

.result-text {
    flex: 1;
}

.result-title {
    font-size: 15px;
    font-weight: 500;
    color: #0f172a;
    margin-bottom: 2px;
}

.result-subtitle {
    font-size: 13px;
    color: #475569;
    /* Darkened from #64748b (slate-500) to slate-600 */
    line-height: 1.4;
}

/* Footer Actions */
.search-footer {
    padding: 16px;
    background-color: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.btn-map-pick {
    color: #475569;
    font-weight: 500;
    font-size: 14px;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-map-pick:active {
    background-color: #f1f5f9;
}

.btn-route {
    background-color: #4f46e5;
    /* indigo-600 */
    color: white;
    font-weight: 600;
    font-size: 15px;
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
    transition: background-color 0.2s;
    cursor: pointer;
}

.btn-route:disabled {
    background-color: #cbd5e1;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-route:active:not(:disabled) {
    background-color: #4338ca;
}

/* Desktop Tweaks */
@media (min-width: 768px) {
    .search-bar-home-container {
        top: 24px;
        left: 24px;
        bottom: auto;
        right: auto;
        width: 400px;
    }

    .search-input {
        font-size: 14px;
    }

    .search-overlay {
        width: 400px;
        left: 24px;
        top: 24px;
        right: auto;
        /* Height and max-height handled by base styles */
        transform: translateX(-120%);
        /* Slide from left */
    }

    .search-overlay.open {
        transform: translateX(0);
    }
}