/* Global Search Styles - Fixed version */
.main-header .search-container {
    position: relative;
    width: 350px;
    margin-right: 20px;
}

.main-header .search-input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.875rem;
    transition: var(--phs-transition);
}

.main-header .search-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] .main-header .search-input::placeholder {
    color: white !important;
}

.main-header .search-input:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

/* Search Results Dropdown - FIXED */
.search-results-dropdown {
    position: fixed;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: none;
    overflow: hidden;
    z-index: var(--phs-z-search-dropdown);
    min-width: 400px;  /* Ensure minimum width */
    max-width: 600px;  /* Maximum width */
}

body.dark-mode .search-results-dropdown {
    background: #2d3748;
    border-color: #4a5568;
    color: var(--phs-border-subtle);
}

.search-dropdown-content {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;  /* Prevent horizontal scroll */
}

.search-dropdown-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #666;
}

body.dark-mode .search-dropdown-loading {
    color: #a0aec0;
}

/* Search Sections */
.search-section {
    padding: 8px 0;
}

.search-section-header {
    padding: 12px 16px;
    font-size: var(--phs-type-label);
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: #f7f7f7;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body.dark-mode .search-section-header {
    color: #a0aec0;
    background-color: #1a202c;
    border-bottom-color: #4a5568;
}

/* Clear button in header */
.search-section-header .btn-link {
    padding: 2px 6px !important;
    margin: -2px 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.search-section-header .btn-link:hover {
    opacity: 1;
}

/* Search Result Items */
.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border: none;
    width: 100%;
    text-align: left;
    position: relative;
    min-height: 50px;  /* Ensure minimum height */
}

.search-result-item:hover,
.search-result-item.active {
    background-color: #f5f5f5;
}

body.dark-mode .search-result-item:hover,
body.dark-mode .search-result-item.active {
    background-color: #3a4759;
}

.search-result-item .search-icon {
    font-size: 1rem;
    color: #666;
    margin-right: 12px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;  /* Prevent icon from shrinking */
}

body.dark-mode .search-result-item .search-icon {
    color: #a0aec0;
}

.search-result-item.recent-search .search-icon {
    color: var(--phs-ink-muted);
}

.search-result-content {
    flex: 1;
    overflow: hidden;
    padding-right: 30px;  /* Space for delete button */
}

.search-result-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
}

body.dark-mode .search-result-title {
    color: var(--phs-border-subtle);
}

/* Count badge */
.search-result-title .badge {
    margin-left: 8px;
    font-size: var(--phs-type-label);
    padding: 2px 6px;
    flex-shrink: 0;
}

.search-result-subtitle {
    font-size: var(--phs-type-label);
    color: #666;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.dark-mode .search-result-subtitle {
    color: #a0aec0;
}

/* Delete button for individual items */
.search-result-item > .btn-link {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 8px !important;
    opacity: 0;
    transition: opacity 0.2s;
}

.search-result-item:hover > .btn-link {
    opacity: 0.6;
}

.search-result-item > .btn-link:hover {
    opacity: 1;
}

/* View All Link */
.search-view-all {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #3b82f6;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-top: 1px solid #e0e0e0;
    transition: background-color 0.2s ease;
}

body.dark-mode .search-view-all {
    border-top-color: #4a5568;
    color: #60a5fa;
}

.search-view-all:hover {
    background-color: #f5f5f5;
}

body.dark-mode .search-view-all:hover {
    background-color: #3a4759;
}

/* No Results */
.search-no-results {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

body.dark-mode .search-no-results {
    color: #a0aec0;
}

.search-no-results i {
    font-size: 2rem;
    margin-bottom: 12px;
}

/* Global Search Styles - Fixed version */

.main-header .search-container {
    position: relative;
    width: 350px;
    margin-right: 20px;
}

.main-header .search-input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.875rem;
    transition: var(--phs-transition);
}

    .main-header .search-input::placeholder {
        color: rgba(255, 255, 255, 0.6);
    }

[data-theme="dark"] .main-header .search-input::placeholder {
    color: white !important;
}

.main-header .search-input:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}


/* Search Results Dropdown - FIXED */

.search-results-dropdown {
    position: fixed;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: none;
    overflow: hidden;
    z-index: var(--phs-z-search-dropdown);
    min-width: 400px;
    max-width: 600px;
}

[data-theme="dark"] .search-results-dropdown {
    background: #2d3748;
    border-color: #4a5568;
    color: var(--phs-border-subtle);
}

.search-dropdown-content {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
}

.search-dropdown-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #666;
}

[data-theme="dark"] .search-dropdown-loading {
    color: #a0aec0;
}

/* Search Sections */

.search-section {
    padding: 8px 0;
}

.search-section-header {
    padding: 12px 16px;
    font-size: var(--phs-type-label);
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: #f7f7f7;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

[data-theme="dark"] .search-section-header {
    color: #a0aec0;
    background-color: #1a202c;
    border-bottom-color: #4a5568;
}

/* Clear button in header */

.search-section-header .btn-link {
    padding: 2px 6px !important;
    margin: -2px 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

    .search-section-header .btn-link:hover {
        opacity: 1;
    }

/* Search Result Items */

.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border: none;
    width: 100%;
    text-align: left;
    position: relative;
    min-height: 50px;
}

    .search-result-item:hover,
    .search-result-item.active {
        background-color: #f5f5f5;
    }

/* Hover/active must be a dark lift, not an ink token: --phs-ink-body flips to
   near-white in dark mode, which painted light rows under light text. */
[data-theme="dark"] .search-result-item:hover,
[data-theme="dark"] .search-result-item.active {
    background-color: #3a4759;
}

.search-result-item .search-icon {
    font-size: 1rem;
    color: #666;
    margin-right: 12px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

[data-theme="dark"] .search-result-item .search-icon {
    color: #a0aec0;
}

.search-result-item.recent-search .search-icon {
    color: var(--phs-ink-muted);
}

.search-result-content {
    flex: 1;
    overflow: hidden;
    padding-right: 30px;
}

.search-result-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
}

[data-theme="dark"] .search-result-title {
    color: var(--phs-border-subtle);
}

/* Count badge */

.search-result-title .badge {
    margin-left: 8px;
    font-size: var(--phs-type-label);
    padding: 2px 6px;
    flex-shrink: 0;
}

.search-result-subtitle {
    font-size: var(--phs-type-label);
    color: #666;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-theme="dark"] .search-result-subtitle {
    color: #a0aec0;
}

/* Delete button */

.search-result-item > .btn-link {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 8px !important;
    opacity: 0;
    transition: opacity 0.2s;
}

.search-result-item:hover > .btn-link {
    opacity: 0.6;
}

.search-result-item > .btn-link:hover {
    opacity: 1;
}

/* View All Link */

.search-view-all {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #3b82f6;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-top: 1px solid #e0e0e0;
    transition: background-color 0.2s ease;
}




[data-theme="dark"] .search-view-all {
    border-top-color: #4a5568;
    color: #60a5fa;
}

.search-view-all:hover {
    background-color: #f5f5f5;
}

[data-theme="dark"] .search-view-all:hover {
    background-color: #3a4759;
}

/* No Results */

.search-no-results {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .search-no-results {
    color: #a0aec0;
}

.search-no-results i {
    font-size: 2rem;
    margin-bottom: 12px;
}


/* Mobile Responsiveness */

@media (max-width: 768px) {

    .search-container {
        width: 100%;
        margin-right: 0;
        margin-bottom: 15px;
    }

    .search-results-dropdown {
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        min-width: unset;
    }

    .search-result-content {
        padding-right: 40px;
    }
}

/* Ensure dropdown doesn't get cut off */

@media (max-width: 480px) {

    .search-results-dropdown {
        max-width: calc(100vw - 20px);
    }
}

/* Keyboard focus (paired with outline:none + box-shadow on :focus above) */
.search-input:focus-visible {
    outline: 2px solid var(--phs-accent-link);
    outline-offset: 2px;
    box-shadow: var(--phs-focus-ring);
}

/* Clear (x) button - sits in the input's right padding zone. The magnifying
   glass is a flex item on the left, so there is no collision on the right. */
.main-header .search-container .search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 50%;
    color: #5b6472;
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
    z-index: 2;
}

.main-header .search-container .search-clear:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.08);
    color: #1a1a1a;
}

.main-header .search-container .search-clear:focus-visible {
    outline: 2px solid var(--phs-accent-link, #0d6efd);
    outline-offset: 2px;
    opacity: 1;
}

/* [hidden] must beat the display:inline-flex above, so keep this rule after it. */
.main-header .search-container .search-clear[hidden] {
    display: none;
}

[data-theme="dark"] .main-header .search-container .search-clear {
    color: #92929f;
}

[data-theme="dark"] .main-header .search-container .search-clear:hover {
    background-color: rgba(255, 255, 255, 0.14);
    color: #e4e6ef;
}
 
