/* Стили для страницы списка тегов (/tags/index.php) */
/* Префикс ti- (Tags Index) для изоляции стилей */

.ti-page, 
.ti-page *, 
.ti-page *::before, 
.ti-page *::after {
    box-sizing: border-box;
}

.ti-page {
    margin: 0 auto;
}

/* Шапка страницы тегов */
.ti-page-header {
    background: #fff;
    border: 1px solid #eef1f5;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.ti-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    color: #475569;
}

.ti-header-icon {
    color: #3498db;
    font-size: 1.1rem;
}

.ti-header-count {
    color: #3498db;
    font-weight: 700;
}

@media (max-width: 600px) {
    .ti-page-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* Фильтры и поиск */
.ti-filters {
    background: #fff;
    border: 1px solid #eef1f5;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
    width: 100%;
    max-width: 100%;
    overflow: hidden; /* Гарантированный срез всего, что выходит за края */
}

.ti-filters-form {
    display: flex;
    justify-content: center;
    width: 100%;
}

.ti-filters-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
}

.ti-search-wrapper {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.ti-search-input {
    width: 100%;
    padding: 10px 40px 10px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.ti-search-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    outline: none;
}

.ti-search-button {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}

.ti-sort-wrapper {
    display: flex;
    gap: 8px;
}

.ti-sort-select {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fff;
    cursor: pointer;
    color: #475569;
    max-width: 100%;
}

.ti-sort-select:focus {
    border-color: #3498db;
    outline: none;
}

.ti-apply-btn {
    background: #3498db;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    max-width: 100%;
}

.ti-apply-btn:hover {
    background: #2980b9;
}

.ti-reset-btn {
    background: #f1f5f9;
    color: #475569;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.ti-reset-btn:hover {
    background: #e2e8f0;
}

/* Сетка тегов */
.ti-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

/* Карточка тега */
.ti-card {
    background: #ffffff;
    border: 1px solid #eef1f5;
    border-radius: 10px;
    padding: 12px 16px;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.ti-card:hover {
    border-color: #3498db;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.08);
}

.ti-card-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ti-link {
    text-decoration: none;
    color: inherit;
}

.ti-name-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ti-hash {
    color: #3498db;
    font-weight: 700;
    font-size: 1.1rem;
    opacity: 0.5;
}

.ti-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ti-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
}

.ti-count-badge {
    background: #f1f5f9;
    color: #64748b;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ti-actions {
    display: flex;
}

.ti-view-btn {
    font-size: 0.8rem;
    color: #94a3b8;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}

.ti-view-btn:hover {
    color: #3498db;
}

/* Пагинация */
.ti-pagination-wrapper {
    margin-top: 40px;
    display: flex;
    justify-content: center;
}

/* Пустое состояние */
.ti-empty-state {
    text-align: center;
    padding: 80px 20px;
    background: #fff;
    border: 1px dashed #e2e8f0;
    border-radius: 16px;
}

.ti-empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.4;
}

.ti-empty-state h3 {
    font-size: 1.5rem;
    color: #1e293b;
    margin-bottom: 12px;
}

.ti-empty-state p {
    color: #64748b;
    margin-bottom: 24px;
}

/* Адаптивность */
@media (max-width: 768px) {

    .ti-header h1 {
        font-size: 1.6rem;
    }

    .ti-filters-form {
        display: block; /* Убираем flex на мобильных для стабильности ширины */
        width: 100%;
    }

    .ti-filters-group {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        margin: 0;
    }

    .ti-search-wrapper,
    .ti-sort-wrapper,
    .ti-apply-btn,
    .ti-reset-btn {
        width: 100%;
    }

    .ti-sort-wrapper {
        display: flex;
        gap: 8px;
    }

    .ti-sort-wrapper .ti-sort-select {
        flex: 1; /* Делим пространство 50/50 */
        min-width: 0;
    }

    .ti-search-wrapper {
        min-width: 0;
        flex: none; /* Убираем flex-grow на мобильных */
    }

    .ti-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }

    .ti-card {
        padding: 10px 14px;
    }
}

@media (max-width: 480px) {
    .ti-header h1 {
        font-size: 1.5rem;
    }

    .ti-sort-wrapper .ti-sort-select {
        width: 100%;
    }
}

@media (max-width: 320px) {

    .ti-sort-wrapper {
        flex-direction: column; /* Стакаем селекты на очень узких экранах */
    }
	}
