/* Post/Feed Styles */

.post {
    border-bottom: var(--border);
    margin-bottom: 0.25rem;
    /* padding-bottom: 0.5rem; */
}

.posts-container {
    margin-bottom: 10rem;
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0rem;
    position: relative;
    gap: 1rem;
}

.post-actions-menu {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Edit Form Styles - 기존 post-body 구조 그대로 사용 */

.edit-form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 1rem;
    /* border-top: var(--border); */
}

/* Edit Image Upload Styles - create post와 동일 */
.edit-image-upload {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.edit-image-upload-area {
    background-color: var(--color-dark);
    border: 1px dashed var(--color-dark-gray);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    color: var(--color-dark-gray);
    height: 20rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.edit-image-upload-area:hover {
    border-color: var(--neon-yellow);
    color: var(--neon-yellow);
    background-color: rgba(255, 255, 0, 0.1);
}

.edit-image-upload-area:hover .overlay {
    background-color: rgba(0, 0, 0, 0.7);
}

.edit-image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.edit-image-preview img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius);
    border: var(--border);
    cursor: pointer;
}

.edit-image-preview img:hover {
    transform: scale(1.05);
    border-color: var(--neon-yellow);
}

.post-date {
    color: var(--color-dark-gray);
    font-style: italic;
}

.post-author{
border-radius: var(--radius);
padding: 0rem 0.5rem;
background-color: var(--color-light-gray);
color: var(--neon-yellow);
/* border: var(--border); */
}

/* Post Body Layout */
.post-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 768px) {
    .post-body {
        align-items: start;
        flex-direction: column-reverse;
    }
}

.post-content {
    background-color: var(--color-gray);
    padding: 0.5rem 1rem;
    /* margin: 0rem 0.5rem; */
    width: 100%;
    height: fit-content;
    max-height: var(--max-height);
    overflow-y: auto;
    display: inline-block;
    word-wrap: break-word; /* Break long words if needed */
    border-radius: var(--radius);
}

/* textarea가 post-content 클래스를 가질 때 */
.post-content.edit-content {
    background-color: var(--color-gray);
    padding: 0.5rem;
    border-radius: var(--radius);
    color: var(--color-light);
    font-family: inherit;
    resize: vertical;
    border: var(--border);
    outline: none;
    width: 100%;
    height: 20rem;
    line-height: 1.4;
    display: block;
}

.post-content.edit-content:focus {
    border-color: var(--neon-yellow);
    box-shadow: 0 0 0 2px rgba(255, 255, 0, 0.2);
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

.post-images {
    gap: 0;
    width: 100%;
}

.post-images img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Image Gallery Grid */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    width: 100%;
}

.image-gallery img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    cursor: pointer;
}

.image-gallery img:hover {
    transform: scale(1.02);
}

/* Single image in gallery */
.image-gallery img:only-child {
    grid-column: 1 / -1;
    height: auto;
    max-height: 400px;
}

/* Three images - first takes full width */
.image-gallery img:first-child:nth-last-child(3) {
    grid-column: 1 / -1;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .image-gallery {
        grid-template-columns: 1fr;
    }
    
    .image-gallery img {
        height: auto;
        max-height: 300px;
    }
}

.post-actions {
    display: flex;
    gap: 1rem;
    /* border-top: var(--border); */
    margin: 0.25rem 0 0.25rem 0;
}

.like-btn, .comment-btn {
    color: black;
    cursor: pointer;
    font-family: "attribute-mono", sans-serif;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: var(--radius);
}

.like-btn, .comment-btn {
    padding: 0.25rem 0.5rem;
}

.like-btn:hover, .comment-btn:hover {
    background-color: var(--color-gray);
}

.like-btn.liked {
    color: var(--color-red);
}

.like-btn.liked:hover {
    background-color: var(--color-gray);
}

.like-icon, .like-count {
}

/* Comments Styles */
.comments-section {
}

.comment-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding-bottom: 0.5rem;
}



.comment-input {
    background-color: var(--color-gray);
    color: var(--color-dark-gray);
    padding: 0rem 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    font-family: "attribute-mono", sans-serif;
    resize: none;
    height: auto;
    min-height: 1.5rem;
    line-height: 1.5;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    /* border: var(--border); */
    border-radius: var(--radius);
    padding: 1rem;
    max-width: 90%;
    max-height: 90%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: var(--border);
    padding-bottom: 0.5rem;
}

.modal-header h2 {
    margin: 0;
    color: var(--neon-yellow);
}

.close {
    color: var(--color-dark-gray);
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: var(--neon-yellow);
}

.modal-body {
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--neon-yellow);
    font-weight: bold;
}

.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: var(--border);
    border-radius: var(--radius);
    background-color: var(--color-gray);
    color: var(--color-light);
    font-family: inherit;
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Code Block Styles */
.code-block {
    width: 100%;
    max-height: var(--max-height);
    background-color: var(--color-gray);
    border: var(--border);
    border-radius: var(--radius);
    /* margin: 0.5rem 0; */
    overflow-y: auto;
    overflow-x: hidden;
}

/* Edit Code Section */
.edit-code-section {
    width: 100%;
}

.edit-code-content {
    width: 100%;
    height: 90%;
    border-radius: var(--radius);
    box-sizing: border-box;
}

.code-header {
    position: sticky;
    top: 0;
    background-color: var(--color-light-gray);
    padding: 0.5rem;
    border-bottom: var(--border);
    z-index: 10;
}

.code-language {
    color: var(--neon-yellow);
    font-weight: bold;
}

.code-block pre {
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
    background-color: var(--color-dark);
}

.code-block code {
    color: var(--color-light);
    font-family: 'Courier New', monospace;
    line-height: 1.4;
}

/* Page Header */
.page-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem 0;
    border-bottom: var(--border);
}

.page-header h1 {
    color: var(--neon-yellow);
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--color-dark-gray);
    margin: 0;
}

/* Post Stats */
.post-stats {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0;
    border-top: var(--border);
    margin-top: 0.5rem;
    color: var(--color-dark-gray);
}

.post-stats span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Print Styles for Posts */
@media print {
    /* Hide header, navigation, and analytics */
    .header,
    .header__nav-links,
    .footer,
    .sidebar,
    .analytics-section,
    .user-analytics,
    .analytics-container,
    .post-actions,
    .comments-section,
    .comment-form,
    .like-btn,
    .comment-btn,
    .post-actions-menu,
    .edit-form-actions,
    button[onclick*="edit"],
    button[onclick*="delete"],
    .edit-btn,
    .delete-btn,
    button[onclick*="add"],
    .add-btn,
    .plus-btn,
    button:contains("+"),
    button[title*="Add"],
    button[title*="Create"],
    button[aria-label*="Add"],
    button[aria-label*="Create"] {
        display: none !important;
    }
    
    /* Page setup for printing */
    @page {
        size: A4;
        margin: 1in;
    }
    
    /* Ensure each post takes a full page */
    .post {
        page-break-after: always;
        page-break-inside: avoid;
        margin: 0;
        padding: 0;
        border: none;
        background: white;
        color: black;
    }
    
    /* Post content styling for print */
    .post-header {
        border-bottom: 2px solid black;
        padding-bottom: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .post-author {
        font-weight: bold;
        font-size: 1.1em;
        color: black;
        background: none;
        padding: 0;
    }
    
    .post-date {
        color: #666;
        font-size: 0.9em;
    }
    
    .post-content {
        background: none;
        padding: 0;
        margin: 1rem 0;
        font-size: 1.1em;
        line-height: 1.6;
        color: black;
    }
    
    /* Images in posts */
    .post-images img {
        max-width: 100%;
        height: auto;
        page-break-inside: avoid;
    }
    
    /* Code blocks */
    .code-block {
        background: #f5f5f5;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    
    .code-block pre {
        background: #f5f5f5;
        color: black;
    }
    
    /* Remove any background colors and ensure text is black */
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }
    
    /* 2-column layout for post content and images */
    
    .post-content {
        grid-column: 1;
    }
    
    .post-images {
        grid-column: 2;
        margin-top: 0;
    }
    
    /* Image styling for print */
    .post-images img {
        max-width: 100%;
        height: auto;
        page-break-inside: avoid;
        border: 1px solid #ccc;
        border-radius: 4px;
    }
    
    /* Multiple images in a grid */
    .post-images {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* If there are multiple images, arrange them nicely */
    .post-images:has(img:nth-child(2)) {
        grid-template-columns: 1fr 1fr;
    }
    
    .post-images:has(img:nth-child(3)) {
        grid-template-columns: 1fr 1fr;
    }
    
    .post-images:has(img:nth-child(4)) {
        grid-template-columns: 1fr 1fr;
    }
}