/* =========================================================
   public/assets/css/search-results.css
   Search Results — Komod
   Фокус: Visual First Card, доверие, чистый UX
   ========================================================= */

/* --- Контейнер страницы --- */
.search-results-container {
    padding: 40px 0;
    background-color: #F9FAFB;
}

/* =========================================================
   0. Z-INDEX / STACKING CONTEXT FIX
   ========================================================= */
.search-page-box {
    position: relative;
    z-index: 5000;
}

.search-page-form {
    position: relative;
    z-index: 5001;
}

.masters-grid {
    position: relative;
    z-index: 1;
}

/* =========================================================
   1. ШАПКА ПОИСКА
   ========================================================= */

.search-header {
    margin-bottom: 18px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 20px;
    flex-wrap: wrap;
}

.search-header__left {
    width: 100%;
    text-align: center;
}

.search-title {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-text-heading);
}

/* Скрываем лишние элементы */
.search-count,
.search-ranking-hint,
.search-chip,
.search-dot {
    display: none !important;
}

/* =========================================================
   2. SEARCH BOX (Google-like)
   ========================================================= */

.search-page-box {
    margin: 18px 0 26px;
}

.search-page-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.search-page-input {
    max-width: 920px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 12px 14px;
    box-shadow: 0 18px 45px rgba(0,0,0,0.08);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.search-page-input:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 22px 55px rgba(79,70,229,0.14);
    transform: translateY(-1px);
}

.search-page-input > i {
    display: none !important;
}

.search-page-input input[type="search"],
.search-page-input input[type="text"] {
    flex: 1;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 1.05rem;
    color: var(--color-text-heading);
    background: transparent;
    padding: 12px 10px 12px 16px;
    min-width: 0;
}

.search-page-input input::-webkit-search-cancel-button,
.search-page-input input::-webkit-search-decoration,
.search-page-input input::-webkit-search-results-button,
.search-page-input input::-webkit-search-results-decoration {
    display: none;
    -webkit-appearance: none;
}

.search-page-input input::placeholder {
    color: var(--color-text-muted);
}

.search-page-input .btn {
    padding: 12px 16px;
    border-radius: 16px;
    font-weight: 800;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1;
    min-width: 48px;
    min-height: 44px;
}

.search-page-input .btn i {
    font-size: 1.1rem;
}

.search-page-input .btn.btn-outline {
    border: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-text-muted);
}

.search-page-input .btn.btn-outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.search-page-input .btn.btn-primary {
    border: 1px solid transparent;
}

.search-page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.search-page-actions .btn {
    border-radius: 12px;
}

.search-page-actions .btn.is-active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.35);
}

.search-page-actions .btn.is-active i {
    color: #fff;
}

.search-page-actions .btn.is-active:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.komod-typeahead {
    z-index: 2147483647 !important;
}

.komod-typeahead,
.komod-typeahead * {
    backface-visibility: hidden;
}

/* =========================================================
   3. ПАНЕЛЬ НАСТРОЕК (ADMIN)
   ========================================================= */

.search-settings-panel {
    max-width: 920px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 16px;
}

.search-settings-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    align-items: end;
}

.search-settings-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

.search-field { min-width: 0; }
.search-label {
    display: block; font-size: 0.9rem; color: var(--color-text-muted);
    margin-bottom: 6px; font-weight: 800;
}
.search-check {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--color-text-muted); font-weight: 700;
}

.search-results-container .input {
    border-radius: 10px; border: 1px solid var(--color-border);
    padding: 10px 12px; font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s; background: #fff;
}
.search-results-container .input:focus {
    outline: none; border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}

/* =========================================================
   4. EMPTY STATE & DEBUG
   ========================================================= */

.search-empty-card {
    padding: 28px; text-align: center; background: #fff;
    border-radius: 20px; border: 1px solid var(--color-border);
}
.search-empty-title {
    margin: 0 0 8px; font-weight: 800; color: var(--color-text-heading);
}
.search-empty-text {
    margin: 0; color: var(--color-text-muted); line-height: 1.7;
}

.search-debug {
    margin-top: 16px; border-top: 1px solid var(--color-border);
    padding-top: 12px; text-align: left;
}
.search-debug summary {
    cursor: pointer; color: var(--color-text-muted); font-weight: 800;
}
.search-debug pre {
    margin: 12px 0 0; padding: 12px; border-radius: 12px;
    border: 1px solid var(--color-border); background: #fafafa;
    overflow: auto; font-size: 0.85rem; line-height: 1.5;
}

/* =========================================================
   5. СЕТКА МАСТЕРОВ
   ========================================================= */

.masters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 30px;
    align-items: stretch;
}

/* =========================================================
   6. КАРТОЧКА МАСТЕРА (Instagram Style)
   Исправленная версия: Имя под аватаром, не наезжает на фото
   ========================================================= */

.master-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s;
    position: relative;
    height: 100%;
}

.master-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 40px -5px rgba(0,0,0,0.1);
    border-color: var(--color-primary-light);
}

/* --- 1. Визуальная часть (Обложка) --- */
.card-visual {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16/10;
    background: #F3F4F6;
    overflow: hidden;
    text-decoration: none;
}

.card-cover-img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}
.master-card:hover .card-cover-img { transform: scale(1.05); }

.card-cover-placeholder {
    width: 100%; height: 100%;
    background: linear-gradient(135deg, #EEF2FF 0%, #C7D2FE 100%);
    opacity: 0.8;
}

.card-badges-top {
    position: absolute; top: 12px; left: 12px; z-index: 2;
    display: flex; gap: 6px;
}
.badge-top {
    background: var(--color-accent); color: #fff;
    font-size: 0.7rem; font-weight: 800; text-transform: uppercase;
    padding: 4px 10px; border-radius: 99px; letter-spacing: 0.05em;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.card-ds-badge {
    position: absolute; top: 12px; right: 12px; z-index: 2;
    background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(4px);
    padding: 4px 10px; border-radius: 12px;
    display: flex; align-items: center; gap: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); border: 1px solid rgba(255,255,255,0.5);
}
.card-ds-badge i { color: var(--color-primary); font-size: 1rem; }
.card-ds-badge strong { color: var(--color-text-heading); font-weight: 800; font-size: 0.95rem; }

/* --- 2. Тело карточки --- */
.card-body {
    padding: 0 20px 20px; /* Отступы внутри белого блока */
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    position: relative;
    background: #fff; /* Явный белый фон */
}

/* Ряд Идентичности (Аватар + Имя) */
.card-identity-row {
    display: flex;
    gap: 14px;
    /* Убрали выравнивание flex-end, чтобы имя не прижималось к низу ряда, если он высокий */
    align-items: flex-start; 
    margin-bottom: 8px;
    position: relative;
    /* Важно: НЕ поднимаем весь ряд (top: -24px удалено) */
}

/* Аватар (поднимается вверх на фото) */
.card-avatar-overlap {
    width: 64px; 
    height: 64px;
    border-radius: 50%;
    border: 4px solid #fff;
    background: #fff;
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    flex-shrink: 0;
    overflow: visible;
    display: block;
    
    /* Магия: поднимаем ТОЛЬКО аватар вверх, наезжая на обложку */
    margin-top: -32px; 
    z-index: 10;
}

.card-avatar-overlap img {
    width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
}
.avatar-fallback {
    width: 100%; height: 100%; border-radius: 50%; background: #EEF2FF;
    display: flex; align-items: center; justify-content: center;
    color: var(--color-primary); font-size: 1.5rem;
}

.verified-icon {
    position: absolute; bottom: 0; right: -2px;
    background: #fff; color: #10B981; border-radius: 50%;
    width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
    font-size: 1rem; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Инфо блок (Имя + Рейтинг) - остается на белом фоне */
.card-main-info {
    flex: 1;
    min-width: 0;
    padding-top: 4px; /* Небольшой отступ сверху для визуального баланса */
}

.card-name {
    margin: 0 0 6px;
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.3;
    
    /* Разрешаем перенос на 2 строки */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
}

.card-name a { text-decoration: none; color: var(--color-text-heading); }
.card-name a:hover { color: var(--color-primary); }

.card-rating {
    display: flex; align-items: center; gap: 6px; font-size: 0.9rem;
}
.text-accent { color: var(--color-accent); }
.rating-val { font-weight: 700; color: var(--color-text-heading); }
.rating-count { color: var(--color-text-muted); font-size: 0.85rem; }

/* Мета-данные */
.card-meta-row {
    display: flex; gap: 16px; margin-top: 16px; margin-bottom: 0px;
    color: var(--color-text-muted); font-size: 0.9rem;
}
.meta-item {
    display: flex; align-items: center; gap: 6px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.meta-item i { color: var(--color-primary); font-size: 1rem; opacity: 0.8; }

/* Призыв (CTA) */
.card-cta {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #4B5563;
    background: #F9FAFB;
    padding: 10px 12px;
    border-radius: 10px;
    margin: 16px 0;
    font-style: italic;
    border-left: 3px solid #EEF2FF;
    
    /* Гарантируем высоту ~3 строк */
    min-height: 4.5em; 
    
    /* Обрезаем лишнее (защита от переполнения) */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-cta-empty {
    background: transparent; border: none; padding: 0; min-height: 0; margin-bottom: 0;
}

/* Footer */
.card-footer {
    margin-top: auto;
    display: flex; align-items: center; justify-content: space-between;
    padding-top: 0; border-top: 1px solid #F3F4F6;
}
.card-price { display: flex; align-items: baseline; gap: 7px; }
.price-label { font-size: 0.85rem; color: var(--color-text-muted); }
.price-val { font-size: 0.8rem; font-weight: 600; color: var(--color-text-heading); }

.btn-view {
    padding: 8px 20px; font-size: 0.95rem; border-radius: 10px; text-decoration: none;
}

/* =========================================================
   7. PAGINATION & RESPONSIVE
   ========================================================= */

.pagination {
    margin-top: 50px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
}
.page-item {
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    background: #fff; border: 1px solid var(--color-border); border-radius: 12px;
    font-weight: 700; color: var(--color-text-main); transition: all 0.2s ease; text-decoration: none;
}
.page-item:hover:not(.active) {
    border-color: var(--color-primary); color: var(--color-primary); box-shadow: var(--shadow-sm);
}
.page-item.active {
    background: var(--color-primary); color: #fff; border-color: var(--color-primary);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.35);
}
.page-item--dots { pointer-events: none; opacity: 0.6; }

@media (max-width: 1100px) {
    .search-settings-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
    .search-title { font-size: 1.7rem; }
    .search-page-input { border-radius: 999px; padding: 12px 12px; gap: 10px; }
    .search-page-actions { justify-content: flex-start; }
}
@media (max-width: 600px) {
    .search-results-container { padding: 24px 0; }
    .masters-grid { grid-template-columns: 1fr; gap: 22px; }
    .card-visual { aspect-ratio: 16/9; }
    .card-body { padding: 20px; }
    .page-item { width: 40px; height: 40px; }
    .search-settings-grid { grid-template-columns: 1fr; }
    .search-page-input .btn { padding: 12px 14px; border-radius: 16px; min-width: 46px; min-height: 44px; }
    .search-page-input .btn i { font-size: 1.1rem; }
}