/* --- Глобальные контейнеры и общая структура --- */
.content-wrapper {
    justify-content: center;
    max-width: 1200px; 
    margin: 40px auto 24px;
    flex-wrap: wrap;
    width: 100%;
    padding: 0 20px; 
    box-sizing: border-box;
    /* display: flex; - УДАЛЕНО */
}

.section {
    padding-top: 20px;
    text-align: left;
    position: relative;
    width: 100%;
}

/* --- Заголовок и Сортировка --- */
.section-header {
    margin-bottom: 22px;
    padding: 0;
}

.header-and-sort {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.section-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0;
}

.sort-controls-desktop {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-label {
    font-weight: 500;
    color: #555;
    white-space: nowrap;
}

.sort-selector {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    background-color: #fff;
    transition: border-color 0.2s;
    -webkit-appearance: none; 
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23333333%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13.2-5.4H18.6c-5%200-9.3%201.8-12.8%205.4A17.6%2017.6%200%200%200%200%2082.6c0%204.6%201.8%208.7%205.4%2012.8l130.6%20130.6c3.4%203.6%207.8%205.4%2012.8%205.4s9.4-1.8%2012.8-5.4L287%2095.4c3.4-4.1%205.4-8.2%205.4-12.8%200-4.6-1.8-9.1-5.4-13.2z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
    padding-right: 30px; 
}

.sort-selector:hover {
    border-color: #007bff;
}

/* --- Контейнер для сайдбара и контента --- */
.library-content {
    display: flex;
    gap: 30px;
    width: 100%;
    padding: 0;
}

.sidebar {
    flex: 0 0 250px;
    padding: 0;
}

.main-content {
    flex-grow: 1;
    min-width: 0; 
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 15px;
}

/* --- Стили для карточек (Новая структура) --- */

.template-list-vertical {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.template-card-horizontal {
    display: flex;
    align-items: center;
    padding: 12px;
 
    border-radius: 10px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.05);
    background-color: #fff;
    transition: box-shadow 0.2s;
    min-height: 80px;
}

.template-card-horizontal:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.template-card-link-img {
    flex-shrink: 0;
    width: 320px; 
    height: 140px; 
    margin-right: 15px;
    overflow: hidden;
    border-radius: 6px;
}

.template-card-link-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.template-card-info {
    flex-grow: 1; 
    display: flex;
    align-items: center; 
    justify-content: space-between; 
    min-height: 66px;
}

.template-card-details-wrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    /* margin-right: 15px; - убрано */
}

.template-card-title-link {
    font-size: 1.15rem;
    font-weight: 600;
    color: #333;
    text-decoration: none;
    transition: color 0.2s;

    -webkit-line-clamp: 2; 
  
    overflow: hidden;
    margin-bottom: 5px;
}

.template-card-title-link:hover {
    color: #007bff;
}

.template-card-meta {
    /* На десктопе здесь только автор */
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: #6c757d;
	    
   font-size: 0.8rem;
   gap: 8px;
   padding: 10px; /* Отступ перед статистикой */

}

.meta-author .meta-value {
    font-weight: 500;
    color: #333;
    margin-left: 4px;
}

/* КОНТЕЙНЕР ДЕЙСТВИЙ И СТАТИСТИКИ (Правая часть карточки) */
.template-card-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    margin-left: 15px;
}


/* Группа статистики */
.template-stats-group {
    display: flex;
    gap: 10px;
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 5px; /* Отступ от кнопки */
}

.template-stats-group span {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.template-stats-group i {
    margin-right: 4px;
    font-size: 0.9rem;
}

.meta-likes i { color: #dc3545; }
.meta-copies i { color: #17a2b8; }


/* --- Стили для сайдбара (общие) --- */
.sidebar-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-links li a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: #333;
    border-radius: 5px;
    transition: background-color 0.2s;
}

.sidebar-links li a.active {
    background-color: #007bff;
    color: #fff;
}

.sidebar-links li a:hover:not(.active) {
    background-color: #f0f0f0;
}


/* --- Стили для ПАГИНАЦИИ --- */
.pagination {
    display: flex;
    justify-content: center;
    list-style: none;
    padding: 0;
    margin-top: 30px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.pagination .page-item {
    margin: 0 3px;
}

.pagination .page-link {
    display: block;
    padding: 8px 14px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    text-decoration: none;
    color: #007bff;
    background-color: #fff;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.pagination .page-link:hover {
    background-color: #e9ecef;
    border-color: #dee2e6;
}

.pagination .page-item.active .page-link {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
    pointer-events: none; 
}

.pagination .page-item.disabled .page-link {
    color: #6c757d;
    pointer-events: none;
    background-color: transparent;
    border: 1px solid transparent;
}

.favorites-btn-inline {
    /* Общие стили для кнопки-контейнера */
    display: inline-flex;
    flex-direction: column;
    align-items: center; /* Центрирование содержимого */
    justify-content: center;
    
    /* Стили фона и границы */
    background-color: #ffffff; /* Белый фон */
    border: 1px solid #e0e0e0; /* Светлая тонкая граница */
    border-radius: 12px; /* Закруглённые углы */
    padding: 8px 15px; /* Внутренние отступы */
    cursor: pointer; /* Курсор-указатель */
    transition: background-color 0.2s; /* Плавное изменение цвета при наведении */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); /* Легкая тень для объема */
    
    /* Сброс стандартных стилей кнопки */
    font-family: inherit;
}

.favorites-btn-inline .hi-text {
    /* Стиль для верхнего (большого, чёрного) текста */
    font-size: 1.25rem; /* Более крупный размер */
    font-weight: 700; /* Жирный шрифт */
    color: #333333; /* Тёмно-серый или чёрный цвет */
    line-height: 1.2; /* Межстрочный интервал */
    margin-bottom: 2px; /* Небольшой отступ от нижнего текста */
}

.favorites-btn-inline .price-text {
    /* Стиль для нижнего (меньшего, серого) текста */
    font-size: 0.9rem; /* Меньший размер */
    font-weight: 400; /* Обычный шрифт */
    color: #777777; /* Серый цвет */
    line-height: 1; /* Уменьшаем межстрочный интервал */
}


/* --- Стили для МОДАЛЬНЫХ ОКОН --- */
.modal {
    display: none; 
    position: fixed; 
    z-index: 2000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.6); 
    justify-content: center; 
    align-items: center; 
}

.modal-content {
    background-color: #fff;
    margin: auto; 
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    max-width: 90%; 
    width: 400px; 
    box-sizing: border-box;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 15px;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: #333;
    text-decoration: none;
    cursor: pointer;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 15px;
}

.modal-text {
    margin-bottom: 20px;
    color: #555;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end; 
    gap: 10px;
    margin-top: 20px;
}

.modal-btn {
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s;
}

.modal-btn-secondary {
    background-color: #f8f9fa;
    color: #333;
    border: 1px solid #ccc;
}

.modal-btn-secondary:hover {
    background-color: #e9ecef;
}

.modal-btn-register {
    background-color: #007bff;
    color: #fff;
    border: none;
}

.modal-btn-register:hover {
    background-color: #0056b3;
}


/* --- АДАПТИВНОСТЬ (МОБИЛЬНЫЕ УСТРОЙСТВА) --- */


@media (max-width: 991px) {
	
	main {
		padding: 20px 10px;
		
	}
	
	.hi-text {
		display: none;
	}
	
	.favorites-btn-inline {
		margin-left: auto;
	}
	
	.section {
    padding-top: 0px;
}
	
    .content-wrapper {
        padding: 0 15px; 
    }
    
    .header-and-sort {
        align-items: center;
        width: 100%;
    }

    .section-header h1 {
        font-size: 1.8rem;
    }

    .library-content {
        flex-direction: column;
        gap: 0;
    }

    
    /* Оптимизация карточек на узких экранах */
    .template-card-horizontal {
        padding: 10px;
        flex-wrap: wrap;
    }
    
    .template-card-link-img {
        width: 100%;
        height: 130px; 
    }
    
    .template-card-info {
        min-height: auto;
        align-items: flex-start;
        flex-direction: column; 
        flex-grow: 1;
        width: calc(100% - 90px); /* Оставшееся место рядом с картинкой */
        order: 2;
    }
    
    .template-card-details-wrapper {
        flex-basis: 100%;
        margin-right: 0;
		font-size: 1rem;
        order: 1; 
		padding-top: 5px;
    }

    .template-card-title-link {
        font-size: 1em;
        -webkit-line-clamp: 2;
        margin-bottom: 2px;
    }
    
    .template-card-meta {
        font-size: 0.8rem;
        gap: 8px;
        padding: 10px; /* Отступ перед статистикой */
    }
    
    .template-card-actions {
        flex-direction: row; /* На мобильном они рядом */
        justify-content: space-between;
        align-items: center;
        width: 100%; /* Занимают всю ширину снизу */
        margin-left: 0;
        order: 3;
        margin-top: 10px;
    }
    
    .template-stats-group {
        order: 1;
        margin-top: 0;
        gap: 15px; /* Увеличим отступы, чтобы было не так тесно */
        font-size: 0.9rem;
    }
}


