/* ========================================
   SEARCH DROPDOWN (LIVE SEARCH)
   ======================================== */

/* Container & Base Styles */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.05);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 8px;
    display: none;
    animation: fadeIn 0.2s ease-out;
}


/* Result Items */
.search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
    animation: slideIn 0.2s ease-out;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-item.selected {
    background: #f0f2f5;
    border-left: 3px solid #007bff;
}

/* Type Badge */
.search-result-type {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 20px;
    background: #e9ecef;
    color: #495057;
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

/* Title & Description */
.search-result-title {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 4px;
    line-height: 1.4;
}

.search-result-description {
    font-size: 13px;
    color: #6c757d;
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

/* No Results Message */
.search-no-results {
    padding: 20px;
    text-align: center;
    color: #6c757d;
}

.search-no-results-icon {
    display: block;
    font-size: 32px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.search-no-results-text {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 5px;
    color: #495057;
}

.search-no-results-hint {
    font-size: 12px;
    color: #adb5bd;
}

/* Close Button (Mobile) */
.search-results-close {
    position: sticky;
    top: 0;
    background: #fff;
    padding: 12px 16px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s;
}

.search-results-close:hover {
    background: #f8f9fa;
}

.search-results-close span {
    margin-right: 8px;
    font-size: 16px;
}

.search-close-hint {
    margin-top: 12px;
    font-size: 11px;
    color: #adb5bd;
    text-align: center;
}

/* Empty State */
.search-results:empty {
    display: none;
}

/* Error State */
.search-error {
    animation: shake 0.5s ease-in-out;
}

/* ========================================
   SEARCH RESULTS PAGE (UNIFIED)
   ======================================== */

.search-page {
    width: 100%;
    margin: 0 auto;
}

/* Unified Header Styles */
.search-header {
    background: white;
    padding: 30px;
    border-radius: 5px;
    margin-bottom: 50px;
    box-shadow: 5px 5px 10px rgba(0, 0, 0, 1);
}


.search-header h1,
.search-results-header h1 {
    font-size: 28px;
    color: #1a1a2e;
    margin-bottom: 10px;
}

.search-results-header .search-query,
.search-term {
    color: #0066cc;
    font-weight: 600;
}

.search-count,
.search-results-count {
    color: #666;
    font-size: 14px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

/* Unified Results Container */
.results-list,
.results-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 40px;
}

/* Unified Result Card */
.result-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.8);
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
}

.result-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

/* Unified Type Badge */
.result-type {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 20px;
    background: wheat;
    color: #0066cc;
    margin-bottom: 12px;
    letter-spacing: 0.3px;
}

/* Unified Title */
.result-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
}

.result-title a {
    color: #1a1a2e;
    text-decoration: none;
    transition: color 0.2s ease;
}

.result-title a:hover,
.result-card:hover .result-title {
    color: #0066cc;
}

/* Unified Description */
.result-description {
    font-size: 14px;
    color: #6c757d;
    line-height: 1.6;
    margin-bottom: 16px;
}

/* Unified Link */
.result-link {
    display: inline-block;
    font-size: 14px;
    color: #F0B461;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.result-link:hover {
    color: #f99100;
    text-decoration: underline;
    transform: translateX(4px);
}

/* Unified No Results */
.no-results {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: 12px;
    margin: 40px 0;
}

.no-results-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.no-results h2 {
    font-size: 24px;
    color: #1a1a2e;
    margin-bottom: 12px;
}

.no-results p {
    color: #6c757d;
    margin-bottom: 24px;
}

.no-results-suggestions {
    text-align: left;
    max-width: 400px;
    margin: 0 auto;
}

.no-results-suggestions h3 {
    font-size: 18px;
    color: #1a1a2e;
    margin-bottom: 12px;
}

.no-results-suggestions ul {
    list-style: none;
    padding: 0;
}

.no-results-suggestions li {
    margin-bottom: 8px;
}

.no-results-suggestions a {
    color: #0066cc;
    text-decoration: none;
}

.no-results-suggestions a:hover {
    text-decoration: underline;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* ========================================
   DARK MODE (UNIFIED)
   ======================================== */

@media (prefers-color-scheme: dark) {

    /* Dropdown & Cards */
    .search-results,
    .result-card,
    .search-header,
    .search-results-header {
        background: #2d2d3a;
    }

    /* Borders */
    .search-result-item,
    .search-results-close,
    .result-card {
        border-bottom-color: #3d3d4a;
        border-color: #3d3d4a;
    }

    /* Hover States */
    .search-result-item:hover {
        background: #3d3d4a;
    }

    .search-result-item.selected {
        background: #4a4a5a;
    }

    .search-results-close:hover {
        background: #3d3d4a;
    }

    /* Badges */
    .search-result-type {
        background: #3d3d4a;
        color: #e0e0e0;
    }

    .result-type {
        background: #3d3d4a;
        color: #60a5fa;
    }

    /* Text Colors */
    .search-result-title,
    .result-title,
    .result-title a,
    .search-header h1,
    .search-results-header h1,
    .no-results h2,
    .no-results-suggestions h3 {
        color: #ffffff;
    }

    .search-result-description,
    .result-description,
    .search-no-results,
    .no-results p,
    .loading {
        color: #b0b0b0;
    }

    .search-count,
    .search-results-count,
    .search-no-results-hint {
        color: #6c757d;
    }

    .search-no-results-text {
        color: #e9ecef;
    }

    /* No Results Background */
    .no-results {
        background: #2d2d3a;
    }

    /* Header Border */
    .search-count,
    .search-results-count {
        border-top-color: #3d3d4a;
    }
}

/* ========================================
   RESPONSIVE DESIGN (UNIFIED)
   ======================================== */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .search-results-page {
        padding: 30px 16px;
    }

    .result-card {
        padding: 20px;
    }

    .result-title {
        font-size: 18px;
    }
}

/* Mobile (up to 768px) */
@media (max-width: 768px) {

    /* Dropdown Overlay */
    .search-results {
        position: fixed;
        top: 10dvh;
        left: 0;
        right: 0;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
        z-index: 10000;
        animation: slideUp 0.3s ease-out;
    }

    /* Result Items */
    .search-result-item {
        padding: 14px 16px;
    }

    .search-result-type {
        font-size: 10px;
    }

    .search-result-title {
        font-size: 15px;
    }

    .search-result-description {
        font-size: 13px;
    }

    /* Close Button */
    .search-results-close {
        padding: 14px 16px;
        font-size: 15px;
        background: #f8f9fa;
        border-bottom: 1px solid #e0e0e0;
    }

    .search-results-close span {
        font-size: 18px;
    }

    /* No Results */
    .search-no-results {
        padding: 40px 20px;
    }

    .search-no-results-icon {
        font-size: 48px;
    }

    /* Results Page */
    .search-results-page {
        padding: 20px 16px;
    }

    .search-header,
    .search-results-header {
        padding: 20px;
    }

    .search-header h1,
    .search-results-header h1 {
        font-size: 24px;
    }

    .result-card {
        padding: 16px;
    }

    .result-title {
        font-size: 18px;
    }

    .result-description {
        font-size: 13px;
    }
}

/* Small Mobile (up to 480px) */
@media (max-width: 480px) {
    .search-results {
        top: 16dvh;
    }

    .search-result-type {
        font-size: 9px;
        padding: 2px 6px;
    }

    .search-result-title {
        font-size: 13px;
    }

    .search-result-description {
        font-size: 11px;
    }

    .search-header h1,
    .search-results-header h1 {
        font-size: 20px;
    }

    .results-list,
    .results-grid {
        gap: 16px;
    }

    .result-card {
        padding: 14px;
    }
}

/* Dark Mode Mobile */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
    .search-results {
        background: #1a1a2e;
    }

    .search-results-close {
        background: #2d2d3a;
        border-bottom-color: #3d3d4a;
        color: #e0e0e0;
    }

    .search-results-close:hover {
        background: #3d3d4a;
    }
}



/* Подсветка найденных слов */
.search-highlight {
    background-color: #ffeb3b;
    color: #1a1a2e;
    font-weight: 500;
    padding: 0 2px;
    border-radius: 3px;
}

/* Dark mode highlight — use site's custom data-theme attribute */
[data-theme="dark"] .search-highlight {
    background-color: rgba(255, 214, 0, .25);
    color: #ffd600;
}

.result-description { font-size: 14px; color: #6c757d; line-height: 1.5; margin-top: 8px; }
.result-title a .search-highlight { color: inherit; }

/* ============================================================
   MODAL LIVE SEARCH — grouped results (sr-* namespace)
   ============================================================ */

/* Loading state */
.sr-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px;
    color: var(--ink-soft);
    font-size: .875rem;
}

@keyframes srSpin { to { transform: rotate(360deg); } }

.sr-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--glass-border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: srSpin .7s linear infinite;
    flex-shrink: 0;
}

/* Group label */
.sr-group {
    padding: 10px 16px 4px;
}

.sr-group__label {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-mute);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Result item */
.sr-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--ink);
    border-radius: 10px;
    margin: 0 6px;
    transition: background .15s ease, color .15s ease;
    cursor: pointer;
}

.sr-item:hover,
.sr-item--active {
    background: var(--glass-bg-strong);
    color: var(--ink);
}

.sr-item--active { background: rgba(10,132,255,.1); }

.sr-item__body { flex: 1; min-width: 0; }

.sr-item__title {
    font-size: .875rem;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.sr-item__snippet {
    font-size: .78rem;
    color: var(--ink-soft);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sr-item__arrow {
    width: 16px;
    height: 16px;
    color: var(--ink-mute);
    flex-shrink: 0;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity .15s ease, transform .15s ease;
}

.sr-item:hover .sr-item__arrow,
.sr-item--active .sr-item__arrow {
    opacity: 1;
    transform: translateX(0);
}

/* "See all N results" footer */
.sr-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    margin: 6px 6px 4px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--blue);
    font-size: .825rem;
    font-weight: 500;
    text-decoration: none;
    gap: 4px;
    transition: background .15s ease, border-color .15s ease;
}

.sr-footer:hover {
    background: rgba(10,132,255,.08);
    border-color: rgba(10,132,255,.3);
}

.sr-footer strong { font-weight: 700; }

/* Empty / no results */
.sr-empty {
    padding: 32px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.sr-empty__icon { font-size: 2rem; opacity: .4; }

.sr-empty__text {
    font-size: .9rem;
    color: var(--ink);
    margin: 0;
}

.sr-empty__hint {
    font-size: .8rem;
    color: var(--ink-mute);
    margin: 0;
}

/* Highlight inside snippet — keeps dark mode working via data-theme */
.sr-item__snippet .search-highlight {
    background: rgba(255, 214, 0, .35);
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

[data-theme="dark"] .sr-item__snippet .search-highlight {
    background: rgba(255, 214, 0, .2);
    color: #ffd600;
}

/* ============================================================
   SEARCH / TAG RESULT PAGE  (sr-page namespace)
   ============================================================ */

.sr-page { max-width: 900px; margin: 0 auto; padding: 0 0 60px; }

/* Hero */
.sr-page__hero {
    padding: 32px 0 28px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 32px;
}

.sr-page__label {
    display: inline-block;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin-bottom: 8px;
}

.sr-page__heading {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 8px;
    word-break: break-word;
}

.sr-page__count {
    font-size: .875rem;
    color: var(--ink-soft);
    margin: 0;
}

/* Empty state */
.sr-page__empty {
    text-align: center;
    padding: 64px 24px;
    color: var(--ink-soft);
}

.sr-page__empty-icon { font-size: 3rem; display: block; margin-bottom: 16px; opacity: .4; }
.sr-page__empty p   { margin: 4px 0; font-size: 1rem; color: var(--ink); }
.sr-page__hint      { font-size: .875rem !important; color: var(--ink-mute) !important; }

/* ── Tag mode: news card grid ── */
.sr-news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.sr-news-card {
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
    color: var(--ink);
    border: 1px solid var(--glass-border);
    transition: transform .2s ease, box-shadow .2s ease;
}

.sr-news-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,.12);
}

.sr-news-card__thumb {
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--glass-bg);
}

.sr-news-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s ease;
}

.sr-news-card:hover .sr-news-card__thumb img { transform: scale(1.04); }

.sr-news-card__body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.sr-news-card__cat {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--blue);
}

.sr-news-card__title {
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--ink);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sr-news-card__excerpt {
    font-size: .8rem;
    color: var(--ink-soft);
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sr-news-card__footer {
    margin-top: auto;
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sr-news-card__date { font-size: .75rem; color: var(--ink-mute); }

.sr-news-card__tags { display: flex; flex-wrap: wrap; gap: 6px; }

.sr-news-card__tag {
    font-size: .7rem;
    padding: 3px 8px;
    border-radius: 20px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--ink-soft);
}

.sr-news-card__tag--active {
    background: rgba(52,211,153,.14);
    border-color: rgba(52,211,153,.5);
    color: #34d399;
    font-weight: 600;
}

/* ── Search mode: result list ── */
.sr-results-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 40px;
}

.sr-result-card {
    display: block;
    padding: 20px 24px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    text-decoration: none;
    color: var(--ink);
    transition: transform .2s ease, box-shadow .2s ease;
}

.sr-result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
}

.sr-result-card__type {
    display: inline-block;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(10,132,255,.1);
    color: var(--blue);
    margin-bottom: 10px;
}

.sr-result-card__title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 8px;
    line-height: 1.4;
}

.sr-result-card__snippet {
    font-size: .875rem;
    color: var(--ink-soft);
    line-height: 1.55;
    margin: 0 0 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sr-result-card__link {
    font-size: .8rem;
    font-weight: 600;
    color: var(--blue);
    transition: letter-spacing .15s ease;
}

.sr-result-card:hover .sr-result-card__link { letter-spacing: .02em; }

/* Responsive */
@media (max-width: 600px) {
    .sr-news-grid { grid-template-columns: 1fr; }
    .sr-result-card { padding: 16px; }
}