:root {
    --primary-color: #007bff;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --dark-color: #343a40;
    --light-color: #f8f9fa;
    --border-color: #dee2e6;
    --shadow-light: rgba(0,0,0,0.1);
    --shadow-medium: rgba(0,0,0,0.15);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.btn-modern {
    border: none;
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.btn-modern::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn-modern:hover::before {
    left: 100%;
}

.btn-modern:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0,0,0,0.15);
}

.btn-primary-modern {
    background: var(--gradient-primary);
    color: white;
}

.btn-success-modern {
    background: var(--gradient-success);
    color: white;
}

.search-section {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
    border: 1px solid rgba(255,255,255,0.2);

    /* БЫЛО sticky — убираем по умолчанию */
    position: static;
    top: auto;

    z-index: 100;
    transition: all 0.3s ease-in-out;
    overflow: hidden;
}

.search-section.collapsed {
    max-height: 60px;
    background: white;
    border-radius: 16px;
    padding: 10px 20px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
    border: 1px solid rgba(255,255,255,0.2);
}

.search-section.collapsed .search-container,
.search-section.collapsed .search-controls button:not(#expand-search),
.search-section.collapsed .search-stats {
    display: none;
}

.search-section.collapsed .search-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0;
}

.search-section.collapsed #expand-search {
    display: inline-flex !important;
    margin: 0 auto;
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--border-color);
    padding: 0.5rem 1rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    gap: 0.5rem;
}

.search-section.collapsed #expand-search:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

/* Положение свёрнутой панели при sticky режиме */
.search-section.collapsed.sticky {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: auto;
    min-width: 250px;
}

.search-section.sticky {
    /* Липкость включаем только этим классом */
    position: sticky;
    top: 20px;

    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    transform: scale(0.98);
}

.search-container {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 1rem 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: rgba(248, 249, 250, 0.8);
    backdrop-filter: blur(10px);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.1);
    background: white;
}

.search-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.search-btn {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.search-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.search-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #666;
}

.document-card {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    position: relative;
}

.document-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 2rem;
    text-align: center;
    position: relative;
}

.gerb-container {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.gerb-container img {
    width: 50px;
    height: auto;
}

.document-content {
    padding: 2rem;
    line-height: 1.8;
    font-size: 1rem;
    color: #2c3e50;
}

/* Стили для подсветки */
mark.global-highlight,
mark:not([class]) {
    background: linear-gradient(120deg, #a8e6cf 0%, #88d8a3 100%);
    color: #2c3e50;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-weight: 600;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

mark.search-highlight {
    background: linear-gradient(120deg, #ffd93d 0%, #ff9800 100%);
    color: #2c3e50;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-weight: 600;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

mark.active {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
    transform: scale(1.05);
}

.match-counter {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.floating-search-info {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 123, 255, 0.95);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 1000;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transform: translateY(-100px);
    transition: transform 0.3s ease;
}

.floating-search-info.visible {
    transform: translateY(0);
}

/* Адаптивность */
@media (max-width: 768px) {
    .header-section {
        padding: 1.5rem;
        border-radius: 15px;
    }

    .header-section h1 {
        font-size: 1.5rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .search-section {
        padding: 0.25rem;
    }

    .search-controls {
        display: flex;
        gap: 0.25rem;
    }
    .search-btn {
        flex: 1;
        padding: 0.3rem;
    }
    .search-btn svg {
        margin-right: 0; /* убираем текст */
    }
    .search-btn span {
        display: none; /* скрываем подписи */
    }

    .document-content {
        padding: 1.5rem;
        font-size: 0.95rem;
    }

    .floating-search-info {
        position: relative;
        top: auto;
        right: auto;
        margin-bottom: 1rem;
        transform: none;
    }

    .search-stats {
        display: flex;
        flex-direction: column;
        align-items: flex-start; /* чтобы текст шёл слева */
        gap: 0.3rem; /* небольшой отступ между строками */
    }
}

/* Анимации */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.6s ease-out;
}

/* Кастомный скроллбар */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(45deg, #667eea, #764ba2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(45deg, #5a6fd8, #6a4190);
}

/* === GLOBAL SEARCH NOTICE (FIXED) === */
#global-search-notice {
    position: fixed !important;
    right: 24px !important;
    bottom: 24px !important;
    width: 340px;
    max-width: calc(100vw - 32px);
    background: #ffffff;
    border-radius: 16px;
    padding: 16px 18px;
    z-index: 9999;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
    animation: noticeSlideUp 0.4s ease-out;
}

#global-search-notice .notice-body {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

#global-search-notice .notice-icon {
    font-size: 22px;
    line-height: 1;
    margin-top: 2px;
}

#global-search-notice .notice-text {
    flex: 1;
}

#global-search-notice .notice-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

#global-search-notice .notice-desc {
    font-size: 0.85rem;
    color: #6c757d;
    line-height: 1.4;
}

#global-search-notice .notice-close {
    margin-left: auto;
    margin-top: 2px;
}

/* Мобилка */
@media (max-width: 768px) {
    #global-search-notice {
        left: 12px !important;
        right: 12px !important;
        bottom: 12px !important;
        width: auto;
        border-radius: 14px;
    }
}

