/* =========================================
   МОДУЛЬ ПОИСКА SHNYAGI.NET
   В стиле мессенджера
   ========================================= */

:root {
    --search-bg: #FFFFFF;
    --search-sidebar-bg: #F8F9FA;
    --search-border: #E9ECEF;
    --search-text: #212529;
    --search-text-secondary: #6C757D;
    --search-text-muted: #ADB5BD;
    --search-accent: #4A90A4;
    --search-accent-light: rgba(74, 144, 164, 0.1);
    --search-hover: rgba(0, 0, 0, 0.03);
    --search-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --search-input-bg: #FFFFFF;
    --search-scrollbar: #CED4DA;
    --search-scrollbar-hover: #ADB5BD;
}

[data-theme="dark"] {
    --search-bg: #1E2124;
    --search-sidebar-bg: #2D3436;
    --search-border: #3D4449;
    --search-text: #E9ECEF;
    --search-text-secondary: #ADB5BD;
    --search-text-muted: #6C757D;
    --search-accent: #5A9FB5;
    --search-accent-light: rgba(90, 159, 181, 0.15);
    --search-hover: rgba(255, 255, 255, 0.03);
    --search-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --search-input-bg: #2D3436;
    --search-scrollbar: #4A5459;
    --search-scrollbar-hover: #6C757D;
}

/* ===== ПЛАВАЮЩАЯ КНОПКА ПОИСКА ===== */
.search-float-btn {
    position: fixed;
	left: 20px;
    bottom: 96px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--search-accent, #4A90A4);
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    z-index: 9997;
    transition: transform 0.2s, box-shadow 0.2s;
}

.search-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Подсказка при наведении (как у мессенджера) */
.search-float-btn::before {
    content: attr(title);
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-25%);
    background: var(--bg-container, #fff);
    color: var(--text-main, #2D3436);
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    z-index: 1002;
    pointer-events: none;
}

.search-float-btn:hover::before {
    opacity: 1;
    visibility: visible;
    top: -43px;
}

/* Стрелочка подсказки */
.search-float-btn::after {
    content: '';
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--border-color);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1002;
    pointer-events: none;
}

.search-float-btn:hover::after {
    opacity: 1;
    visibility: visible;
    top: -12px;
}

[data-theme="dark"] .search-float-btn::after {
    border-top-color: var(--border-color);
}

@media (max-width: 768px) {
    .search-float-btn {
        left: 15px;
        bottom: 80px;
        width: 50px;
        height: 50px;
    }
    
    .search-float-btn::before,
    .search-float-btn::after {
        display: none;
    }
}

/* ===== МОДАЛЬНОЕ ОКНО ПОИСКА ===== */
.app-search {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.app-search.hidden {
    display: none !important;
}

.search-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
}

.search-container {
    position: relative;
    width: 90%;
    max-width: 550px;
    margin-top: 8vh;
    background: var(--search-bg);
    border-radius: 16px;
    box-shadow: var(--search-shadow);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--search-border);
    animation: searchSlideIn 0.2s ease;
}

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

.search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--search-border);
}

.search-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--search-text);
}

.search-btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--search-text-secondary);
    transition: all 0.2s;
}

.search-btn-icon:hover {
    background: var(--search-hover);
    color: var(--search-accent);
}

.search-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    /*background: var(--search-input-bg);
    border: 1px solid var(--search-border);*/
    border-radius: 10px;
    color: var(--search-text-secondary);
}

.search-input-wrapper svg {
    flex-shrink: 0;
    color: var(--search-text-muted);
}

#search-input {
    flex: 1;
    max-width: 100%;
    /*border: none;*/
    background: transparent;
    outline: none;
    font-size: 15px;
    color: var(--search-text);
}

#search-input::placeholder {
    color: var(--search-text-muted);
}

.search-results {
    margin-top: 16px;
    max-height: 45vh;
    overflow-y: auto;
}

.search-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: var(--search-text-muted);
}

.search-placeholder svg {
    opacity: 0.4;
    margin-bottom: 16px;
}

.search-placeholder p {
    margin: 0;
    font-size: 14px;
}

/* Карточка результата */
.search-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--search-border);
}

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

.search-item-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--search-text);
    text-decoration: none;
    display: block;
    margin-bottom: 6px;
    line-height: 1.4;
}

.search-item-title:hover {
    color: var(--search-accent);
}

.search-item-meta {
    font-size: 12px;
    color: var(--search-text-muted);
    margin-bottom: 8px;
    display: flex;
    gap: 14px;
}

.search-item-text {
    font-size: 13px;
    color: var(--search-text-secondary);
    line-height: 1.5;
}

.search-show-all {
    padding: 12px 0 4px;
    text-align: center;
    border-top: 1px solid var(--search-border);
}

.search-show-all-link {
    color: var(--search-accent);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

.search-show-all-link:hover {
    text-decoration: underline;
}

.search-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--search-border);
    text-align: center;
}

.search-advanced-link {
    color: var(--search-accent);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

.search-advanced-link:hover {
    text-decoration: underline;
}

/* Скроллбар */
.search-results::-webkit-scrollbar {
    width: 5px;
}

.search-results::-webkit-scrollbar-track {
    background: transparent;
}

.search-results::-webkit-scrollbar-thumb {
    background: var(--search-scrollbar);
    border-radius: 5px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: var(--search-scrollbar-hover);
}

/* Лоадер */
.search-loader-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--search-border);
    border-top-color: var(--search-accent);
    border-radius: 50%;
    animation: search-spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes search-spin {
    to { transform: rotate(360deg); }
}

/* Адаптив */
@media (max-width: 768px) {
    .app-search {
        align-items: flex-end;
    }
    
    .search-container {
        width: 100%;
        max-width: 100%;
        margin-top: 0;
        border-radius: 16px 16px 0 0;
        max-height: 85vh;
    }
}

.search-loader-placeholder {
    text-align: center;
    padding: 20px;
}

.search-loader-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--search-border);
    border-top-color: var(--search-accent);
    border-radius: 50%;
    animation: search-spin 0.8s linear infinite;
}

@keyframes search-spin {
    to { transform: rotate(360deg); }
}