/* Items Grid — компактные карточки, 3 в ряд */

.items-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

@media (max-width: 1024px) {
    .items-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .items-grid {
        grid-template-columns: 1fr;
    }
}

.item-card {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.item-card-link {
    display: block;
    cursor: default;
}

.item-card-link:hover {
    cursor: pointer;
}

.item-card-cover {
    width: 100%;
    overflow: hidden;
    position: relative;
    background: linear-gradient(135deg, #e0e0e0 0%, #f0f0f0 100%);
}

.item-card-cover img {
    width: 100%;
    height: auto;
    display: block;
}

/* Текст поверх изображения */
.item-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.8rem 0.4rem 0.3rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.2) 60%, transparent 100%);
    color: #fff;
}

.item-card-overlay h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.item-card-overlay .item-card-date {
    font-size: 0.6rem;
    opacity: 0.8;
}

.item-card-placeholder {
    width: 100%;
    padding: 1rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    font-size: 1.3rem;
}

.item-card-body {
    padding: 0.4rem 0.5rem 0.5rem;
}

.item-card-body p {
    margin: 0 0 0.3rem;
    color: #555;
    font-size: 0.7rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-card-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.3rem;
    border-top: 1px solid #f5f5f5;
}

.item-card-footer .action-button {
    color: #aaa;
    font-size: 0.75rem;
}

.item-card-footer .action-button:hover {
    color: #4a90d9;
}

/* Страница просмотра Item */
.item-detail {
    margin-top: 1.5rem;
}

.item-detail::after {
    content: '';
    display: table;
    clear: both;
}

.item-detail-text,
.item-toc {
    margin-left: 420px;
}

.item-detail-text {
    margin-left: 0;
}

.item-detail-cover {
    float: left;
    width: 400px;
    max-width: 100%;
    margin: 0 2rem 1rem 0;
}

.item-detail-cover img {
    width: 100%;
    height: auto;
    border-radius: 10px;
}

@media (max-width: 1024px) {
    .item-detail-cover {
        float: left;
        width: 100%;
        max-width: 50%;
        margin: 0 1.5rem 1rem 0;
    }
    .item-toc {
        margin-left: 0;
    }
}

@media (max-width: 600px) {
    .item-detail-cover {
        float: none;
        width: 100%;
        max-width: 100%;
        margin: 0 0 1rem 0;
    }
    .item-toc {
        margin-left: 0;
    }
}

.item-detail-body {
    flex: 1;
    min-width: 300px;
}

.item-detail-body h1 {
    margin: 0 0 0.5rem;
    font-size: 1.8rem;
}

.item-detail-date {
    color: #999;
    font-size: 0.85rem;
    margin: 2rem 0 1rem;
    clear: both;
}

.item-detail-description {
    color: #555;
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

.item-buttons {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* Markdown-текст — обтекает обложку */
.item-detail-text {
    color: #333;
    font-size: 1rem;
    line-height: 1.8;
}

/* Оглавление под спойлером */
.item-toc {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
}

.item-toc ul {
    list-style: none;
    padding-left: 0;
    margin: 0.5rem 0 0;
}

.item-toc ul ul {
    padding-left: 1.5em;
    margin-top: 0.3em;
}

.item-toc ul ul ul {
    padding-left: 1.5em;
}

.item-toc ul ul ul ul {
    padding-left: 1.5em;
}

.item-toc li {
    margin-bottom: 0.3em;
}

.item-toc a {
    color: #7c8fb8;
    text-decoration: none;
}

.item-toc a:hover {
    text-decoration: underline;
    color: #6b7a9f;
}

.item-detail-text h1,
.item-detail-text h2,
.item-detail-text h3,
.item-detail-text h4,
.item-detail-text h5,
.item-detail-text h6 {
    margin: 1.5em 0 0.6em;
    font-weight: 700;
    line-height: 1.3;
}

.item-detail-text h1 { font-size: 1.8rem; color: #1a202c; }
.item-detail-text h2 { font-size: 1.5rem; color: #1a202c; margin-left: 0; padding-left: 0; text-align: left; }
.item-detail-text h3 { font-size: 1.3rem; color: #2d3748; }
.item-detail-text h4 { font-size: 1.15rem; color: #2d3748; }
.item-detail-text h5 { font-size: 1rem; color: #4a5568; }
.item-detail-text h6 { font-size: 0.9rem; color: #666; }

.item-detail-text p {
    margin: 0 0 1em;
}

.item-detail-text ul,
.item-detail-text ol {
    margin: 0 0 1em;
    padding-left: 1.5em;
}

.item-detail-text li {
    margin-bottom: 0.4em;
}

.item-detail-text blockquote {
    margin: 0 0 1em;
    padding: 0.5em 1em;
    border-left: 4px solid #7c8fb8;
    background: #f7fafc;
    color: #555;
    border-radius: 0 6px 6px 0;
}

.item-detail-text blockquote p {
    margin: 0;
}

.item-detail-text code {
    background: #edf2f7;
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Courier New', monospace;
    color: #c53030;
}

.item-detail-text pre {
    margin: 0 0 1em;
    padding: 1em;
    background: #1a202c;
    border-radius: 8px;
    overflow-x: auto;
}

.item-detail-text pre code {
    background: none;
    padding: 0;
    color: #e2e8f0;
    font-size: 0.9em;
}

.item-detail-text a {
    color: #7c8fb8;
    text-decoration: underline;
}

.item-detail-text a:hover {
    color: #6b7a9f;
}

.item-detail-text img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 0 0 1em;
}

.item-detail-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 1em;
}

.item-detail-text th,
.item-detail-text td {
    border: 1px solid #e2e8f0;
    padding: 0.6em 0.8em;
    text-align: left;
}

.item-detail-text th {
    background: #f7fafc;
    font-weight: 700;
}

.item-detail-text hr {
    border: none;
    border-top: 2px solid #e2e8f0;
    margin: 1.5em 0;
}

/* ========================================
   Комментарии
   ======================================== */

.comments-section {
    clear: both;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid #e2e8f0;
}

.comments-section h2 {
    font-size: 1.3rem;
    color: #1a202c;
    margin-bottom: 1rem;
    text-align: left;
    text-shadow: none;
}

.comments-section h3 {
    font-size: 1.1rem;
    color: #2d3748;
    margin: 1.5rem 0 1rem;
}

.comment {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem 1.2rem;
    margin-bottom: 0.75rem;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.comment-header strong {
    color: #1a202c;
}

.comment-date {
    color: #999;
    font-size: 0.8rem;
}

.comment-text {
    color: #333;
    font-size: 0.95rem;
    line-height: 1.6;
}

.comments-empty {
    color: #999;
    font-size: 0.9rem;
    margin: 1rem 0;
}

.comment-form {
    padding: 1.5rem;
    margin-top: 0.5rem;
}

.comment-form-spoiler {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
}

.comment-form-spoiler summary {
    font-weight: 700;
    font-size: 1rem;
    color: #1a202c;
    cursor: pointer;
    user-select: none;
}

.comment-form-spoiler[open] {
    padding-bottom: 1rem;
}

.messages {
    margin-bottom: 1rem;
}

.message-box {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.message-box.success {
    background: #f0fff4;
    color: #38a169;
    border: 1px solid #c6f6d5;
}

/* ========================================
   Модерация комментариев
   ======================================== */

.comments-moderation-list {
    margin-top: 1.5rem;
}

.mod-comment {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1.2rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.mod-comment-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.mod-comment-header strong {
    color: #1a202c;
}

.mod-comment-email {
    color: #718096;
    font-size: 0.85rem;
}

.mod-comment-item {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.mod-comment-item a {
    color: #7c8fb8;
    text-decoration: none;
}

.mod-comment-item a:hover {
    text-decoration: underline;
}

.mod-comment-text {
    color: #333;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: #f7fafc;
    border-radius: 8px;
}

.mod-comment-actions {
    display: flex;
    gap: 0.5rem;
}

.mod-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.mod-btn-approve {
    background: #38a169;
    color: #fff;
}

.mod-btn-approve:hover {
    background: #2f855a;
}

.mod-btn-delete {
    background: #e53e3e;
    color: #fff;
}

.mod-btn-delete:hover {
    background: #c53030;
}

/* Адаптивность */
@media (max-width: 600px) {
    .item-detail-cover {
        float: none;
        width: 100%;
        margin: 0 0 1rem 0;
    }
    .mod-comment-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }
}
