/* Reset previous styles and keep only what we need */
.header-search {
    position: relative;
}

/* Style the search trigger button */
.search-trigger {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-trigger:focus {
    outline: none;
}

/* Search Icon */
.search-icon {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.search-trigger:hover .search-icon {
    opacity: 1;
}

/* Remove all the input and results styles since we'll handle those in the modal */

/* Search Modal */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.search-modal.active {
    display: block;
    opacity: 1;
}

.search-modal__inner {
    background-color: #fff;
    width: calc(100% - 120px);
    margin: 40px auto;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.search-modal__inner.initial-height {
    transition: height 0.3s ease-in-out;
}

.search-modal__inner.expanded {
    height: calc(100vh - 80px) !important;
    transition: height 0.3s ease-in-out;
}

.search-modal__inner.header-only {
    /* This class can be removed if not needed */
}

/* Search header */
.search-modal__header {
    position: relative;
    background-color: #008080;
    width: 100%;
    padding: 60px 0 30px;
    flex-shrink: 0;
}

.search-modal__header-content {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.search-modal__form {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* Input wrap */
.search-modal__input-wrap {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

/* Search input */
.search-modal__input {
    width: 100%;
    height: 56px;
    padding: 8px 16px 8px 64px;
    border: none;
    background-color: #fff;
    font-size: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-family: "Montserrat", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    outline: none;
}

.search-modal__input:focus {
    outline: none;
}

.search-modal__input::placeholder {
    color: #333;
    opacity: 0.8;
}

/* Search icon in input */
.search-modal__icon {
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    opacity: 0.7;
}

/* Results count - update styles */
.search-modal__results-count {
    color: rgba(255, 255, 255, 1);
    font-size: 14px;
    font-family: "Montserrat", sans-serif;
    text-align: left;
    margin-top: 16px;
    margin-bottom: 0;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 0 20px;
}

.search-modal__results-count .count {
    transition: opacity 0.3s ease;
}

.search-modal__results-count.visible {
    opacity: 1;
    visibility: visible;
}

.search-modal__results-count.searching {
    opacity: 0.7;
}

.search-modal__results-count.searching::after {
    content: '';
    display: inline-block;
    width: 3px;
    height: 3px;
    background-color: currentColor;
    border-radius: 50%;
    margin-left: 4px;
    animation: typing 1s infinite;
    box-shadow: 6px 0 0 currentColor, 12px 0 0 currentColor;
}

@keyframes typing {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Content area - remove overflow */
.search-modal__content {
    flex: 1;
    padding: 40px 40px;
    position: relative;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.search-modal__body.visible .search-modal__content {
    opacity: 1;
}

/* Filters */
.search-modal__filters {
    width: 200px;
    padding-top: 40px;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.search-modal__filter {
    background-color: #C4E2E3;
    border: none;
    color: #333;
    padding: 8px 25px;
    border-radius: 20px;
    font-family: "Montserrat", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: fit-content;
    outline: none;
}

.search-modal__filter:focus {
    outline: none;
}

.search-modal__filter:hover {
    background-color: #d0e5e5;
}

.search-modal__filter.active {
    background-color: #008080;
    color: #fff;
}

/* Results area */
.search-modal__results {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
}

/* Results sections */
.search-results-section {
    margin-bottom: 40px;
    padding: 24px 0;
}

/* Remove top padding from first section */
.search-results-section:first-child {
    padding-top: 0;
}

.search-results-section__title {
    font-family: "Georgia", serif;
    font-size: 26px;
    color: #1A1A1A;
    padding-bottom: 16px;
    border-bottom: 1px solid #EEEEEE;
    font-weight: normal;
}

/* Result items */
.search-result-item {
    display: flex;
    gap: 16px;
    padding: 24px 0;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #EEEEEE;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover .search-result-item__title {
    color: #008080;
}

.search-result-item__image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.search-result-item__content {
    flex: 1;
    min-width: 0; /* Prevents flex item from overflowing */
}

/* Meta information (tags, dates, etc.) */
.search-result-item__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.search-result-item__tag {
    color: #333333;
    font-size: 12px;
    border-radius: 100px;
    display: inline-block;
}

.search-result-item__title {
    font-size: 16px;
    color: #1A1A1A;
    margin-bottom: 4px;
    font-weight: 500;
    line-height: 1.3;
}

.search-result-item__subtitle {
    color: #666666;
    font-size: 14px;
    margin-top: 4px;
    line-height: 1.4;
}

.search-result-item__date {
    color: #666666;
    font-size: 14px;
    margin-top: -6px;
}

/* Empty state */
.search-results-empty {
    text-align: center;
    padding: 40px 0;
    color: #666666;
    font-size: 16px;
}

/* Close button */
.search-modal__close {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 2;
}

.search-modal__close-icon::before,
.search-modal__close-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 2px;
    background-color: #fff;
    transform-origin: center;
}

.search-modal__close-icon::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.search-modal__close-icon::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* Responsive adjustments */
@media (max-width: 868px) {
    .search-modal__inner {
        width: 100%;
        height: 100vh !important; /* Force full height */
        margin: 0;
        border-radius: 0;
    }

    /* Override any expanded state height on mobile */
    .search-modal__inner.expanded {
        height: 100vh !important;
    }
    
    .search-modal__body {
        flex-direction: column; /* Stack filters above content */
        max-width: 100%;
        padding: 0 20px;
        overflow-y: auto; /* Ensure overflow remains on mobile */
    }

    /* Adjust filters for mobile */
    .search-modal__filters {
        width: 100%;
        padding: 20px 0;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        border-bottom: 1px solid #EEEEEE;
    }

    .search-modal__filter {
        font-size: 13px;
        padding: 6px 16px;
    }

    /* Adjust content area for mobile */
    .search-modal__content {
        padding: 20px 0;
    }

    /* Adjust header for mobile */
    .search-modal__header {
        padding: 60px 20px 30px;
    }

    .search-modal__close {
        top: 24px;
        right: 16px;
    }

    /* Adjust search input for mobile */
    .search-modal__input {
        height: 48px;
        font-size: 15px;
    }

    /* Adjust results for mobile */
    .search-result-item {
        padding: 16px 0;
    }

    .search-result-item__image {
        width: 60px;
        height: 60px;
    }

    .search-result-item__title {
        font-size: 15px;
    }

    .search-results-section__title {
        font-size: 22px;
        padding-bottom: 12px;
        margin-bottom: 8px;
    }

    /* Adjust load more button for mobile */
    .search-results-load-more {
        margin-top: 16px;
        padding: 10px;
        font-size: 13px;
    }
}

/* Add styles for very small screens */
@media (max-width: 380px) {
    .search-modal__filters {
        gap: 6px;
    }

    .search-modal__filter {
        font-size: 12px;
        padding: 5px 12px;
    }

    .search-result-item__image {
        width: 50px;
        height: 50px;
    }
}

/* Body wrapper - handles scrolling */
.search-modal__body {
    display: flex;
    background-color: #fff;
    flex: 1;
    overflow-y: auto;
    width: 100%;
    transition: opacity 0.3s ease-in-out;
    opacity: 0;
    visibility: hidden;
}

/* New inner wrapper - handles max-width */
.search-modal__body-inner {
    display: flex;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.search-modal__body.visible {
    opacity: 1;
    visibility: visible;
}

/* Update mobile styles */
@media (max-width: 868px) {
    .search-modal__body {
        padding: 0;
    }
    
    .search-modal__body-inner {
        flex-direction: column;
        padding: 0 20px;
    }
}

/* Loading spinner */
.search-modal__content.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #008080;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 2;
}

.search-modal__content.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 1;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Load more button */
.search-results-load-more {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 24px;
    background-color: #E8F6F6;
    border: none;
    border-radius: 4px;
    color: #008080;
    font-family: "Montserrat", sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-results-load-more:hover {
    background-color: #d0e5e5;
}

.search-results-load-more.loading {
    position: relative;
    color: transparent;
}

.search-results-load-more.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #008080;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}