body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    overflow: hidden; 
}

.app-container {
    display: grid;
    grid-template-columns: 240px 1fr; 
    grid-template-rows: 1fr auto; 
    grid-template-areas:
        "menu main"
        "menu footer"; 
    height: 100vh;
}

.menu-column {
    grid-area: menu; 
    background-color: #e9ecef;
    padding: 20px;
    overflow-y: auto; 
    border-right: 1px solid #dee2e6;
    display: flex; 
    flex-direction: column; 
}

.menu-column h2 {
    margin-top: 0;
    color: #007bff;
    font-size: 1.5em;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
    flex-shrink: 0; 
}

.menu-column nav {
    flex-grow: 1; 
    overflow-y: auto; 
}

.menu-column nav ul { list-style: none; padding: 0; }

.menu-column nav li button {
    display: block;
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 10px;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 5px;
    text-align: left;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s, color 0.2s;
}
.menu-column nav li button:hover {
    background-color: #007bff;
    color: white;
    border-color: #0056b3;
}


.content-column {
    grid-area: main; 
    overflow-y: auto; 
    background-color: #fff;
    display: flex; 
    flex-direction: column; 
}

.footer-column {
    grid-area: footer; 
    background-color: #f1f3f5;
    padding: 20px;
    border-top: 1px solid #dee2e6;
    overflow-y: auto;
    max-height: 200px; 
}

.footer-column h2 {
    margin-top: 0;
    font-size: 1.2em;
    color: #495057;
    border-bottom: 1px solid #ced4da;
    padding-bottom: 8px;
    margin-bottom: 10px;
}

#latestPostsList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#latestPostsList li {
    padding: 6px 0;
    font-size: 0.9em;
    border-bottom: 1px dotted #e0e0e0;
}
#latestPostsList li:last-child {
    border-bottom: none;
}
#latestPostsList li a {
    text-decoration: none;
    color: #007bff;
}
#latestPostsList li a:hover {
    text-decoration: underline;
}
#latestPostsList li .status-draft {
    font-style: italic;
    color: #6c757d;
    font-size: 0.8em;
    margin-left: 5px;
}


.view-section {
    display: none; 
    padding: 25px; 
    flex-grow: 1; 
    overflow-y: auto; 
}
.view-section.editor-layout {
    padding: 0; 
    display: grid; /* Asegurar que el editor-layout use grid cuando está activo */
}


.view-section h1:first-child { 
    margin-top: 0;
}

.view-section h1 {
    color: #343a40;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}


/* --- Grid de Posts --- */
#postsGridContainer {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    padding-top: 10px;
}

.post-grid-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background-color: #f9f9f9;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.post-grid-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.post-grid-item img.grid-item-image {
    width: 100%;
    height: 160px;
    object-fit: cover; 
    border-bottom: 1px solid #e0e0e0;
}

.post-grid-item .grid-item-info {
    padding: 12px;
    flex-grow: 1; 
    display: flex;
    flex-direction: column;
    justify-content: space-between; 
}

.post-grid-item .grid-item-info h4 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.1em;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.post-grid-item .grid-item-info .description {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.6em; 
}


.post-grid-item .grid-item-actions {
    margin-top: auto; 
    padding-top: 8px; 
}

.post-grid-item .grid-item-actions button {
    font-size: 0.8em;
    padding: 5px 8px;
    margin-right: 5px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
}
.post-grid-item .grid-item-actions .edit-btn {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #212529;
}
.post-grid-item .grid-item-actions .edit-btn:hover {
    background-color: #e0a800;
}


/* --- Editor Layout (2 columnas internas) --- */
.editor-layout { /* Ya se aplica display: grid desde .view-section.editor-layout */
    grid-template-columns: 1fr 1fr; 
    height: 100%; 
    gap: 0px; 
    overflow: hidden; 
}

.editor-form-column, .editor-preview-column {
    padding: 25px;
    overflow-y: auto; 
}

.editor-form-column { border-right: 1px solid #dee2e6; }

#postForm label {
    display: block;
    margin-top: 15px;
    margin-bottom: 5px;
    font-weight: 600;
}

#postForm input[type="text"],
#postForm input[type="url"],
#postForm textarea,
#postForm select {
    width: 100%; 
    padding: 10px;
    margin-top: 5px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    box-sizing: border-box; 
}

#postForm textarea {
    min-height: 120px;
    resize: vertical;
}
#content { min-height: 250px; } 

.editor-preview-column h3 {
    margin-top: 0; 
    color: #343a40;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.word-counter {
    font-size: 0.9em;
    color: #6c757d;
    margin-bottom: 10px;
    text-align: right;
}

#markdownPreview.markdown-body {
    border: 1px solid #eee;
    padding: 15px;
    background-color: #f8f9fa;
    min-height: 200px; 
    border-radius: 4px;
    overflow-y: auto;
}

.editor-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

#postForm button {
    padding: 10px 18px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s;
}

#postForm button[type="submit"] {
    background-color: #28a745;
    color: white;
}
#postForm button[type="submit"]:hover { background-color: #218838; }

#deletePostBtn {
    background-color: #dc3545;
    color: white;
    margin-left: 10px;
}
#deletePostBtn:hover { background-color: #c82333; }

.back-button {
    padding: 8px 15px;
    margin-bottom: 20px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}
.back-button:hover { background-color: #5a6268; }

/* --- Post View --- */
#postDisplay {
    padding-top: 10px;
}
#postViewImage {
    max-width: 100%;
    height: auto;
    margin-bottom: 20px;
    border-radius: 5px;
    border: 1px solid #eee;
    display: none; 
}
#postViewImage[src]:not([src=""]) {
    display: block; 
}

#postViewContent.markdown-body { 
    margin-top: 20px;
    line-height: 1.7;
    background-color: transparent; 
    border: none;
    padding: 0;
}
#postViewContent.markdown-body img { max-width: 100%; border-radius: 4px;}

.meta {
    color: #6c757d;
    font-size: 0.9em;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #eee;
}

/* Estilos base para Markdown (similares a GitHub) */
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}
.markdown-body h1:first-child, .markdown-body h2:first-child { margin-top: 0; }
.markdown-body h1 { font-size: 2em; padding-bottom: .3em; border-bottom: 1px solid #eaecef;}
.markdown-body h2 { font-size: 1.5em; padding-bottom: .3em; border-bottom: 1px solid #eaecef;}
.markdown-body h3 { font-size: 1.25em; }
.markdown-body p { margin-top: 0; margin-bottom: 16px; }
.markdown-body ul, .markdown-body ol { padding-left: 2em; margin-bottom: 16px; }
.markdown-body code { padding: .2em .4em; margin: 0; font-size: 85%; background-color: rgba(27,31,35,.05); border-radius: 3px; }
.markdown-body pre { word-wrap: normal; padding: 16px; overflow: auto; font-size: 85%; line-height: 1.45; background-color: #f6f8fa; border-radius: 3px; }
.markdown-body pre code { display: inline; max-width: auto; padding: 0; margin: 0; overflow: visible; line-height: inherit; word-wrap: normal; background-color: transparent; border: 0; font-size: 100%; }
.markdown-body blockquote { margin: 0 0 16px 0; padding: 0 1em; color: #6a737d; border-left: .25em solid #dfe2e5; }
.markdown-body img { max-width: 100%; box-sizing: content-box; background-color: #fff; }
.markdown-body table { display: block; width: 100%; overflow: auto; }
.markdown-body table th { font-weight: 600; }
.markdown-body table th, .markdown-body table td { padding: 6px 13px; border: 1px solid #dfe2e5; }
.markdown-body table tr { background-color: #fff; border-top: 1px solid #c6cbd1; }
.markdown-body table tr:nth-child(2n) { background-color: #f6f8fa; }