:root {
    --primary-color: #E31E24;
    /* Inhostel Red */
    --primary-hover: #C2191E;
    /* Darker Red */
    --secondary-color: #333333;
    /* Dark Grey */
    --bg-color: #f4f6f9;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-muted: #666666;
    --border-color: #e1e4e8;
    --sidebar-width: 250px;
    --success: #28a745;
    --danger: #dc3545;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: #fff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease, padding 0.3s ease, opacity 0.3s ease, visibility 0.3s;
    z-index: 100;
    min-width: 0;
    height: 100%;
}

.app-container.sidebar-collapsed .sidebar {
    width: 0;
    padding: 1.5rem 0;
    transform: translateX(-100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    border-right: none;
}

.brand {
    margin-bottom: 2rem;
    text-align: center;
}

.sidebar-logo {
    max-width: 100%;
    height: auto;
    max-height: 160px;
    /* Tamaño duplicado (antes 80px) */
    /* Limit height */
    display: block;
    margin: 0 auto;
}

.categories-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    margin-right: -1rem;
    padding-right: 1rem;
    min-height: 0;
    /* Important for flex scrolling */
}

.categories-nav h3 {
    position: sticky;
    top: 0;
    background: #fff;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    z-index: 10;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.categories-nav ul {
    list-style: none;
}

.cat-btn {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-radius: var(--radius);
    color: var(--text-color);
    transition: all 0.2s;
    font-size: 0.95rem;
}

.cat-btn:hover {
    background-color: #f0f4f8;
    color: var(--primary-color);
}

.cat-btn.active {
    background-color: #e6f0fa;
    color: var(--primary-color);
    font-weight: 600;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-color);
}

.top-bar {
    background-color: #fff;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#btn-toggle-sidebar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f8f9fa;
    color: var(--text-color);
}

#btn-toggle-sidebar:hover {
    background: #e9ecef;
    color: var(--primary-color);
}

.posts-grid {
    padding: 2rem;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* Cards */
.post-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    height: 350px;
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.card-image {
    height: 180px;
    background-color: #eee;
    overflow: hidden;
}

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

.card-body {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card-title {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    display: -webkit-box;
    overflow: hidden;
}

.card-excerpt {
    font-size: 0.9rem;
    color: var(--text-muted);
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    display: -webkit-box;
    overflow: hidden;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.2s;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

#btn-save.btn-primary {
    background-color: #28a745;
    /* Green */
}

#btn-save.btn-primary:hover {
    background-color: #218838;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #e4e7eb;
    color: var(--text-color);
}

.btn-secondary:hover {
    background-color: #dbe0e6;
}

.btn-danger {
    background-color: #dc3545;
    /* Red */
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
}

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

/* White background when login is active */
body.login-active {
    background-color: #fff !important;
}

body.login-active .app-container {
    display: none;
}

#login-modal {
    background-color: #fff;
}

.modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-content {
    background-color: #fff;
    width: 600px;
    max-width: 90%;
    max-height: 90vh;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

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

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

input[type="text"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

.image-upload-preview {
    width: 100%;
    height: 200px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    background-color: #f8f9fa;
    transition: border-color 0.2s;
}

.image-upload-preview:hover {
    border-color: var(--primary-color);
}

.image-upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Or cover, depending on preference */
    display: block;
}

.image-upload-preview img.hidden {
    display: none;
}

.placeholder-text {
    color: var(--text-muted);
    pointer-events: none;
}

.hidden-input {
    display: none;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* Utils */
.loading-spinner,
.loading-text {
    width: 100%;
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* Editor Styles */
.editor-container {
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    overflow: hidden;
}

.editor-toolbar {
    background: #f8f8f8;
    border-bottom: 1px solid #ddd;
    padding: 8px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.tool-btn {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    color: #444;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: #e0e0e0;
}

.tool-btn.active {
    background: #cbd5e1;
    border-color: #94a3b8;
}

.separator {
    color: #ccc;
    margin: 0 5px;
}

.editor-content {
    min-height: 200px;
    padding: 15px;
    outline: none;
    line-height: 1.6;
    color: #333;
}

.editor-content:focus {
    background: #fafbfc;
}

/* Checkbox Multi-select */
.checkbox-group-container {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px;
    max-height: 150px;
    overflow-y: auto;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 1rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    cursor: pointer;
}

.checkbox-item input {
    width: auto !important;
    margin: 0 !important;
}

/* Responsive */
@media (max-width: 900px) {
    :root {
        --sidebar-width: 200px;
    }

    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        width: 280px;
        /* Slightly wider for touch */
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
        transform: translateX(0);
        /* Ensure it's visible by default if class is not present */
    }

    .app-container.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
        width: 280px;
        /* Keep width fixed on mobile during transition */
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 90;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s;
    }

    .app-container:not(.sidebar-collapsed) .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }

    .top-bar {
        padding: 0.75rem 1rem;
    }

    #page-title {
        font-size: 1.1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 150px;
    }

    .btn-primary span {
        display: none;
    }

    .btn-primary i {
        margin: 0;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions-left,
    .modal-actions-right {
        width: 100%;
        justify-content: center;
    }

    .modal-actions-left .btn,
    .modal-actions-right .btn {
        flex: 1;
        justify-content: center;
    }
}