/**
 * Global Search Styles
 * Search modal, input, and autocomplete dropdown
 */

/* ================================
   HEADER SEARCH BUTTON
   ================================ */
.safaroto-header-search-btn {
    background: none;
    border: none;
    color: #26b8f3; /* Light blue color */
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
    order: 2; /* Position before profile */
    margin-left: auto; /* Push to the right side */
    margin-right: 8px; /* Add spacing before profile */
}

.safaroto-header-search-btn:hover {
    opacity: 0.7;
}

.safaroto-header-search-btn:focus {
    outline: 2px solid #26b8f3;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Ensure profile is on the far right */
.safaroto-header-nav-profile {
    margin-left: auto; /* Push to the right side */
}

/* ================================
   NAV PANEL SEARCH BUTTON
   ================================ */
.safaroto-nav-search-btn {
    /* Inherits nav-panel-menu-item styles */
    text-align: left;
    width: 100%;
    border: none;
    background: none;
}

/* ================================
   SEARCH MODAL
   ================================ */
.safaroto-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20000; /* Above nav panel (19999) */
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 100px;
}

.safaroto-search-modal.active {
    display: flex;
}

/* Prevent body scroll when modal is open */
body.search-modal-open {
    overflow: hidden;
}

/* Modal overlay */
.safaroto-search-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1;
}

/* Modal content */
.safaroto-search-modal-content {
    position: relative;
    z-index: 2;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal header */
.safaroto-search-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
}

.safaroto-search-modal-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.safaroto-search-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    border-radius: 4px;
}

.safaroto-search-modal-close:hover {
    color: #333;
    background: #f5f5f5;
}

/* Modal body */
.safaroto-search-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* ================================
   SEARCH INPUT
   ================================ */
.safaroto-search-modal .safaroto-search-input-wrapper {
    position: relative;
    margin-bottom: 12px;
}

.safaroto-search-modal .safaroto-search-input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 16px;
    pointer-events: none;
    z-index: 1;
}

/* More specific selector to override any conflicts */
.safaroto-search-modal .safaroto-search-modal-body .safaroto-search-input,
.safaroto-search-modal input.safaroto-search-input {
    width: 100%;
    padding: 14px 16px 14px 40px !important;
    font-size: 16px;
    border: 2px solid #26b8f3 !important;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.safaroto-search-modal .safaroto-search-input:focus,
.safaroto-search-modal input.safaroto-search-input:focus {
    border-color: #26b8f3 !important;
}

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

/* ================================
   AUTOCOMPLETE DROPDOWN
   ================================ */
.safaroto-search-autocomplete-dropdown {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: white;
}

/* Autocomplete section */
.search-autocomplete-section {
    border-bottom: 1px solid #f0f0f0;
}

.search-autocomplete-section:last-child {
    border-bottom: none;
}

.search-autocomplete-section-title {
    padding: 12px 16px 8px;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f9f9f9;
}

/* Autocomplete item */
.search-autocomplete-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-left: 3px solid transparent;
}

.search-autocomplete-item:hover,
.search-autocomplete-item.selected {
    background-color: #f5f5f5;
    border-left-color: var(--safaroto-primary-color, #24B8F4);
}

/* Avatar for members */
.search-item-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 12px;
    flex-shrink: 0;
}

/* Flag for countries and cities */
.search-item-flag {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
    flex-shrink: 0;
}

/* Item name */
.search-item-name {
    font-size: 15px;
    color: #333;
    font-weight: 500;
    flex: 1;
}

/* City country label */
.search-item-country {
    font-size: 13px;
    color: #666;
    margin-left: 8px;
}

/* No results */
.search-no-results {
    padding: 24px 16px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* ================================
   MOBILE RESPONSIVE
   ================================ */
@media (max-width: 768px) {
    .safaroto-search-modal {
        padding-top: 0;
        align-items: stretch;
    }

    .safaroto-search-modal-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        animation: slideUp 0.3s ease-out;
    }

    @keyframes slideUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .safaroto-search-modal-header {
        padding: 16px 20px;
    }

    .safaroto-search-modal-title {
        font-size: 18px;
    }

    .safaroto-search-modal-body {
        padding: 20px;
    }

    .safaroto-search-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .safaroto-search-autocomplete-dropdown {
        max-height: calc(100vh - 240px);
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .search-autocomplete-item {
        padding: 10px 12px;
    }

    .search-item-avatar,
    .search-item-flag {
        width: 28px;
        height: 28px;
        margin-right: 10px;
    }

    .search-item-name {
        font-size: 14px;
    }

    .search-item-country {
        font-size: 12px;
    }
}
