/**
 * Collection Styles
 *
 * Стили для системы подборок игр.
 * Поддержка тёмной темы через [data-theme=dark].
 *
 * @package APKVision
 * @since 1.0.0
 */

/* =========================================================
   ARCHIVE PAGE - Сетка подборок
   ========================================================= */
.collection-archive-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
    margin: 0;
    width: 100%;
}

.collection-archive-item {
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px 0 rgb(0 0 0 / 6%);
    border-radius: 10px;
    background: #fff;
    min-height: 320px;
    position: relative;
    text-decoration: none;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    overflow: hidden;
    width: 100%;
}

.collection-archive-item:hover {
    box-shadow: 0 8px 20px 0 rgb(0 0 0 / 14%);
    transform: translateY(-3px);
    text-decoration: none;
}

.collection-archive-image {
    width: 100%;
    height: clamp(180px, 35vw, 240px);
    background: #f0f0f0;
    overflow: hidden;
}

.collection-archive-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.collection-archive-image .nothumbs {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #e8e8e8;
    color: #aaa;
    font-size: 48px;
}

.collection-archive-body {
    padding: 14px 16px 16px;
}

.collection-archive-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.collection-archive-excerpt {
    font-size: 13px;
    color: #666;
    line-height: 1.45;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.collection-archive-count {
    font-size: 12px;
    color: #888;
}

@media (max-width: 1024px) {
    .collection-archive-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

@media (max-width: 900px) {
    .collection-archive-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .collection-archive-grid {
        grid-template-columns: 1fr;
    }
    .collection-archive-image {
        height: clamp(180px, 55vw, 260px);
    }
}

.collection-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

/* =========================================================
   SINGLE PAGE - Заголовок и контент
   ========================================================= */
.collection-single {
    background: #fff;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 20px;
}

.collection-header {
    margin-bottom: 20px;
}

.collection-title {
    margin-bottom: 15px;
}

.collection-featured-image {
    max-width: 600px;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
}

.collection-featured-image img {
    width: 100%;
    height: auto;
}

.collection-content {
    margin-bottom: 30px;
    line-height: 1.6;
}

.collection-section-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4caf50;
}

.collection-subsection-title {
    font-size: 17px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
}

/* =========================================================
   GAMES LIST - Список игр
   ========================================================= */
.collection-games-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 30px;
}

.collection-game-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f9f9f9;
    border-radius: 8px;
    padding: 12px 15px;
    transition: background 0.2s ease;
}

.collection-game-item:hover {
    background: #f0f0f0;
}

.collection-game-link {
    display: flex;
    align-items: center;
    flex: 1;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.collection-game-link:hover {
    text-decoration: none;
}

.collection-game-image {
    width: 50px;
    height: 50px;
    min-width: 50px;
    border-radius: 10px;
    overflow: hidden;
    margin-right: 15px;
    background: #e8e8e8;
}

.collection-game-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.collection-game-image .nothumbs {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #aaa;
    font-size: 20px;
}

.collection-game-info {
    flex: 1;
    min-width: 0;
}

.collection-game-title {
    font-size: 15px;
    font-weight: 500;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =========================================================
   VOTING - Кнопки голосования
   ========================================================= */
.collection-vote-box {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 15px;
}

.collection-vote-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.collection-vote-btn:hover:not(.disabled) {
    border-color: #bbb;
    background: #f5f5f5;
}

.collection-vote-btn.collection-vote-up:hover:not(.disabled) {
    border-color: #4caf50;
    background: #e8f5e9;
}

.collection-vote-btn.collection-vote-down:hover:not(.disabled) {
    border-color: #f44336;
    background: #ffebee;
}

.collection-vote-btn.voted {
    opacity: 0.7;
}

.collection-vote-btn.disabled,
.collection-vote-btn.voted-already {
    cursor: not-allowed;
    opacity: 0.5;
}

.collection-vote-btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

.vote-icon {
    font-size: 16px;
    line-height: 1;
}

.vote-count {
    font-weight: 600;
    color: #555;
}

/* =========================================================
   SUGGESTIONS SECTION - Блок предложений
   ========================================================= */
.collection-suggestions-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.collection-toggle-suggestions {
    display: inline-block;
    padding: 12px 24px;
    background: #4caf50;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.collection-toggle-suggestions:hover {
    background: #43a047;
}

.suggestions-count {
    opacity: 0.9;
}

.collection-suggestions-wrapper {
    margin-top: 20px;
    padding: 20px;
    background: #fafafa;
    border-radius: 8px;
}

.collection-no-suggestions {
    color: #666;
    font-style: italic;
    margin-bottom: 20px;
}

.collection-suggestions-grid {
    margin-bottom: 30px;
}

.collection-suggestion-item {
    background: #fff;
}

/* =========================================================
   SUGGEST FORM - Форма предложения игры
   ========================================================= */
.collection-suggest-form-wrapper {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px dashed #ddd;
}

.collection-suggest-description {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
}

.collection-suggest-form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-start;
}

.collection-search-container {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.collection-search-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    transition: border-color 0.2s ease;
}

.collection-search-input:focus {
    outline: none;
    border-color: #4caf50;
}

.collection-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.search-result-item:hover {
    background: #f5f5f5;
}

.search-result-thumb {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 8px;
    overflow: hidden;
    margin-right: 12px;
    background: #e8e8e8;
}

.search-result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-result-thumb .no-thumb {
    display: block;
    width: 100%;
    height: 100%;
    background: #e8e8e8;
}

.search-result-title {
    font-size: 14px;
    color: #333;
}

.search-loading,
.search-no-results,
.search-error {
    padding: 15px;
    text-align: center;
    color: #666;
}

.search-error {
    color: #f44336;
}

.collection-selected-game {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #e8f5e9;
    border-radius: 6px;
    font-size: 14px;
}

.selected-game-label {
    color: #666;
    margin-right: 8px;
}

.selected-game-title {
    font-weight: 500;
    color: #333;
    margin-right: 10px;
}

.selected-game-clear {
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

.selected-game-clear:hover {
    color: #f44336;
}

.collection-suggest-btn {
    padding: 12px 24px;
    background: #4caf50;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.collection-suggest-btn:hover:not(:disabled) {
    background: #43a047;
}

.collection-suggest-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.collection-suggest-message {
    width: 100%;
    padding: 12px 15px;
    border-radius: 6px;
    font-size: 14px;
    margin-top: 10px;
}

.collection-suggest-message.success {
    background: #e8f5e9;
    color: #2e7d32;
}

.collection-suggest-message.error {
    background: #ffebee;
    color: #c62828;
}

/* =========================================================
   DARK THEME SUPPORT
   ========================================================= */
[data-theme=dark] .collection-archive-item,
[data-theme=dark] .collection-single {
    background-color: #1b1d1f;
}

[data-theme=dark] .collection-archive-title,
[data-theme=dark] .collection-title,
[data-theme=dark] .collection-section-title,
[data-theme=dark] .collection-subsection-title,
[data-theme=dark] .collection-game-title {
    color: #efefef;
}

[data-theme=dark] .collection-archive-excerpt,
[data-theme=dark] .collection-archive-count,
[data-theme=dark] .collection-content,
[data-theme=dark] .collection-suggest-description {
    color: #9f9f9f;
}

[data-theme=dark] .collection-archive-image .nothumbs,
[data-theme=dark] .collection-game-image .nothumbs {
    background: #2d2d2d;
    color: #666;
}

[data-theme=dark] .collection-game-item {
    background: #252729;
}

[data-theme=dark] .collection-game-item:hover {
    background: #2d2f31;
}

[data-theme=dark] .collection-vote-btn {
    background: #2d2d2d;
    border-color: #404040;
    color: #ddd;
}

[data-theme=dark] .collection-vote-btn:hover:not(.disabled) {
    background: #3d3d3d;
    border-color: #505050;
}

[data-theme=dark] .collection-vote-btn.collection-vote-up:hover:not(.disabled) {
    background: #1b3d1f;
    border-color: #4caf50;
}

[data-theme=dark] .collection-vote-btn.collection-vote-down:hover:not(.disabled) {
    background: #3d1b1b;
    border-color: #f44336;
}

[data-theme=dark] .vote-count {
    color: #bbb;
}

[data-theme=dark] .collection-suggestions-section {
    border-top-color: #333;
}

[data-theme=dark] .collection-suggestions-wrapper {
    background: #252729;
}

[data-theme=dark] .collection-suggestion-item {
    background: #1b1d1f;
}

[data-theme=dark] .collection-suggest-form-wrapper {
    border-top-color: #404040;
}

[data-theme=dark] .collection-search-input {
    background: #2d2d2d;
    border-color: #404040;
    color: #ddd;
}

[data-theme=dark] .collection-search-input:focus {
    border-color: #4caf50;
}

[data-theme=dark] .collection-search-results {
    background: #2d2d2d;
    border-color: #404040;
}

[data-theme=dark] .search-result-item:hover {
    background: #3d3d3d;
}

[data-theme=dark] .search-result-title {
    color: #ddd;
}

[data-theme=dark] .search-loading,
[data-theme=dark] .search-no-results {
    color: #999;
}

[data-theme=dark] .collection-selected-game {
    background: #1b3d1f;
}

[data-theme=dark] .selected-game-label {
    color: #999;
}

[data-theme=dark] .selected-game-title {
    color: #ddd;
}

[data-theme=dark] .collection-no-suggestions {
    color: #888;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media only screen and (max-width: 1199px) {
    .collection-archive-item {
        width: calc(25% - 18px);
    }
}

@media only screen and (max-width: 991px) {
    .collection-archive-item {
        width: calc(33.333% - 18px);
        min-height: 230px;
    }
    
    .collection-archive-image {
        width: 120px;
        height: 120px;
        min-height: 120px;
    }
}

@media only screen and (max-width: 767px) {
    .collection-archive-grid {
        margin: 0 -5px;
    }
    
    .collection-archive-item {
        width: calc(50% - 10px);
        margin: 5px;
        min-height: 200px;
        padding: 12px 0;
    }
    
    .collection-archive-image {
        width: 100px;
        height: 100px;
        min-height: 100px;
    }
    
    .collection-archive-title {
        font-size: 14px;
    }
    
    .collection-single {
        padding: 15px;
    }
    
    .collection-game-item {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .collection-game-link {
        width: 100%;
    }
    
    .collection-vote-box {
        margin-left: 65px;
    }
    
    .collection-suggest-form {
        flex-direction: column;
    }
    
    .collection-search-container {
        width: 100%;
    }
    
    .collection-suggest-btn {
        width: 100%;
    }
}

@media only screen and (max-width: 480px) {
    .collection-archive-item {
        width: 100%;
        min-height: auto;
        display: flex;
        align-items: center;
        padding: 12px 15px;
    }
    
    .collection-archive-image {
        width: 60px;
        height: 60px;
        min-height: 60px;
        margin: 0 15px 0 0;
        border-radius: 12px;
    }
    
    .collection-archive-title,
    .collection-archive-excerpt,
    .collection-archive-count {
        text-align: left;
        padding: 0;
    }
    
    .collection-vote-box {
        margin-left: 0;
        justify-content: flex-start;
    }
    
    .collection-vote-btn {
        padding: 5px 10px;
        font-size: 13px;
    }
}

/* =========================================================
   LOAD MORE BUTTON
   ========================================================= */
.collection-load-more-wrapper {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
}

.collection-load-more-btn {
    display: inline-block;
    padding: 12px 30px;
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.collection-load-more-btn:hover:not(.loading) {
    background: #eee;
    border-color: #ccc;
}

.collection-load-more-btn.loading {
    opacity: 0.7;
    cursor: wait;
    pointer-events: none;
}

.collection-load-more-btn.loading::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border: 2px solid #999;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin-loader 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes spin-loader {
    to { transform: rotate(360deg); }
}

/* Анимация появления новых элементов */
.collection-game-item.fade-in {
    animation: fadeInUp 0.4s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.load-more-count {
    color: #888;
    font-weight: 400;
    margin-left: 5px;
}

/* =========================================================
   COLLECTION COUNT & PROMOTION NOTE
   ========================================================= */
.collection-count {
    font-weight: 400;
    color: #888;
    font-size: 16px;
}

.collection-promotion-note {
    color: #4caf50;
    font-size: 13px;
    margin-bottom: 15px;
    padding: 8px 12px;
    background: #e8f5e9;
    border-radius: 4px;
    display: inline-block;
}

.suggestions-remaining {
    color: #888;
    font-size: 13px;
}

.collection-suggest-limit-reached {
    color: #f44336;
    font-style: italic;
    padding: 15px;
    background: #ffebee;
    border-radius: 6px;
}

/* =========================================================
   TOAST NOTIFICATIONS
   ========================================================= */
.collection-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.collection-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.collection-toast.success {
    background: #4caf50;
    color: #fff;
}

.collection-toast.error {
    background: #f44336;
    color: #fff;
}

/* =========================================================
   DARK THEME - NEW ELEMENTS
   ========================================================= */
[data-theme=dark] .collection-load-more-btn {
    background: #2d2d2d;
    border-color: #404040;
    color: #ddd;
}

[data-theme=dark] .collection-load-more-btn:hover:not(.loading) {
    background: #3d3d3d;
    border-color: #505050;
}

[data-theme=dark] .collection-load-more-btn.loading::before {
    border-color: #666;
    border-top-color: transparent;
}

[data-theme=dark] .collection-archive-item {
    background: #1f1f1f;
    box-shadow: 0 2px 8px 0 rgb(0 0 0 / 35%);
}

[data-theme=dark] .collection-archive-item:hover {
    box-shadow: 0 8px 20px 0 rgb(0 0 0 / 45%);
}

[data-theme=dark] .collection-archive-image {
    background: #2a2a2a;
}

[data-theme=dark] .collection-archive-title {
    color: #ddd;
}

[data-theme=dark] .collection-archive-excerpt {
    color: #aaa;
}

[data-theme=dark] .collection-archive-count {
    color: #888;
}

[data-theme=dark] .load-more-count {
    color: #888;
}

[data-theme=dark] .collection-count {
    color: #888;
}

[data-theme=dark] .collection-promotion-note {
    background: #1b3d1f;
    color: #81c784;
}

[data-theme=dark] .suggestions-remaining {
    color: #888;
}

[data-theme=dark] .collection-suggest-limit-reached {
    background: #3d1b1b;
    color: #ef9a9a;
}

/* =========================================================
   VOTE ANIMATION
   ========================================================= */
.vote-count-updated {
    animation: voteCountPulse 0.5s ease;
    color: #4caf50 !important;
    font-weight: 700;
}

.collection-vote-up .vote-count-updated {
    color: #4caf50 !important;
}

.collection-vote-down .vote-count-updated {
    color: #f44336 !important;
}

.vote-success {
    animation: voteButtonPulse 0.4s ease;
}

.collection-vote-up.vote-success {
    background: #e8f5e9 !important;
    border-color: #4caf50 !important;
}

.collection-vote-down.vote-success {
    background: #ffebee !important;
    border-color: #f44336 !important;
}

@keyframes voteCountPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.4);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes voteButtonPulse {
    0% {
        transform: scale(1);
    }
    30% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.vote-count {
    display: inline-block;
    transition: color 0.3s ease;
}

/* Dark theme vote animation */
[data-theme=dark] .collection-vote-up.vote-success {
    background: #1b3d1f !important;
    border-color: #4caf50 !important;
}

[data-theme=dark] .collection-vote-down.vote-success {
    background: #3d1b1b !important;
    border-color: #f44336 !important;
}

.single-collection #comments {
    margin: 0 !important;
}