/* ====================================
   HOJA DE ESTILOS PARA EL BLOG
   ==================================== */

/* Variables CSS para coherencia total */
:root {
    /* Paleta de colores refinada */
    --primary-color: #6B705C;
    --primary-hover: #5A5F4C;
    --secondary-color: #A5A58D;
    --accent-color: #B7B7A4;
    
    /* Colores semánticos */
    --color-success: #6B705C;
    --color-warning: #CB997E;
    
    /* Colores de texto */
    --text-primary: #2D3436;
    --text-secondary: #636E72;
    --text-muted: #74B9FF;
    --text-light: #B2BEC3;
    
    /* Colores de fondo */
    --background-main: #FEFEFE;
    --background-card: #FFFFFF;
    --background-light: #F8F9FA;
    --background-code: #F1F3F4;
    --background-pre: #263238;
    --background-quote: #F8F9FA;
    
    /* Bordes y sombras minimalistas */
    --border-color: #E9ECEF;
    --border-radius: 6px;
    --border-radius-small: 3px;
    --border-radius-large: 8px;
    --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.08);
    
    /* Transiciones suaves */
    --transition: all 0.2s ease;
}

/* ====================================
   ESTILOS BASE
   ==================================== */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; 
    line-height: 1.3; /* Reducido de 1.6 a 70% */
    color: var(--text-primary); 
    margin: 0;
    padding: 0;
    background: var(--background-main);
    font-weight: 400;
}

/* ====================================
   HEADER Y NAVEGACIÓN - REDUCIDO
   ==================================== */

.blog-header {
    background: var(--background-card);
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.blog-nav {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
}

.logo {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.logo:hover {
    opacity: 0.8;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.9rem;
}

.nav-links a:hover {
    background: var(--background-light);
    color: var(--primary-color);
}

/* ====================================
   LAYOUT CON SIDEBAR
   ==================================== */

.layout-container {
    max-width: 1200px;
    margin: 32px auto;
    padding: 0 24px;
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 40px;
    align-items: start;
}

.content-area {
    min-width: 0; /* Para evitar overflow */
}

/* ====================================
   SIDEBAR - SIN STICKY
   ==================================== */

.sidebar {
    /* Removido: position: sticky; y top: 100px; */
    /* Ahora el sidebar fluye normalmente con el contenido */
}

.sidebar-widget {
    background: var(--background-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-large);
    padding: 24px;
    box-shadow: var(--shadow-subtle);
    margin-bottom: 24px;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: var(--text-primary);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
}

.categorias-sidebar {
    display: flex;
    flex-direction: column;
    gap: 6px; /* Reducido de 8px a 6px (25% menos) */
}

.categoria-sidebar-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px; /* Reducido de 10px a 8px (20% menos) */
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-secondary);
    transition: var(--transition);
    border: 1px solid transparent;
    font-size: 0.9rem;
    line-height: 1.04; /* Reducido 20% de 1.3 */
}

.categoria-sidebar-link:hover {
    background: var(--background-light);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.categoria-sidebar-link.active {
    background: var(--primary-color);
    color: white;
    font-weight: 500;
}

.categoria-sidebar-link .count {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    line-height: 1.04; /* Reducido 20% de 1.3 */
}

.categoria-sidebar-link.active .count {
    color: rgba(255, 255, 255, 0.8);
}

/* ====================================
   CONTENEDOR PRINCIPAL
   ==================================== */

.container {
    background: var(--background-card);
    border-radius: var(--border-radius-large);
    padding: 40px;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
}

/* ====================================
   SECCIONES DE CATEGORÍAS
   ==================================== */

.categoria-seccion {
    margin-bottom: 40px;
}

.categoria-seccion:last-child {
    margin-bottom: 0;
}

.categoria-titulo {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0 0 24px 0;
    text-align: center;
}

/* ====================================
   GRID DE POSTS CON IMÁGENES 16:9
   ==================================== */

.posts-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr;
    margin-top: 24px;
}

.post-card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-large);
    overflow: hidden;
    transition: var(--transition);
    background: var(--background-card);
    box-shadow: var(--shadow-subtle);
    height: 72px; /* Cambiado de 101px a 72px */
}

.post-card:hover {
    box-shadow: var(--shadow-light);
    border-color: var(--text-muted);
    transform: translateY(-2px);
}

.post-card-content {
    display: flex;
    align-items: stretch;
    height: 100%;
}

.post-card-image {
    flex-shrink: 0;
    width: 128px; /* Ajustado proporcionalmente */
    height: 72px; /* Cambiado de 101px a 72px */
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background-light);
}

.post-card-image a {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.post-card-image img {
    width: 128px; /* Ajustado proporcionalmente */
    height: 72px; /* Cambiado de 101px a 72px */
    object-fit: cover;
    display: block;
    border-radius: 0; /* Sin esquinas redondeadas en la imagen, solo en el contenedor */
    transition: var(--transition);
}

.post-card-image:hover img {
    transform: scale(1.05);
}

.post-card-text {
    flex: 1;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 72px; /* Cambiado de 101px a 72px */
    overflow: hidden;
}

.post-card .post-title {
    margin: 0 0 6px 0;
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 600;
    line-height: 0.91; /* Reducido de 1.3 a 70% */
}

.post-card .post-title a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

.post-card .post-title a:hover {
    color: var(--primary-color);
}

.post-card .post-meta {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.post-card .post-excerpt {
    color: var(--text-secondary);
    line-height: 0.98; /* Reducido de 1.4 a 70% */
    font-size: 0.85rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ====================================
   POST INDIVIDUAL
   ==================================== */

.post-container {
    background: var(--background-card);
    border-radius: var(--border-radius-large);
    padding: 40px;
    box-shadow: var(--shadow-light);
    margin-bottom: 32px;
    border: 1px solid var(--border-color);
}

.post-header { 
    margin-bottom: 32px; 
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.post-title { 
    font-size: 2.5rem; 
    margin-bottom: 16px; 
    color: var(--text-primary);
    line-height: 0.84; /* Reducido de 1.2 a 70% */
    font-weight: 700;
}

.post-meta { 
    color: var(--text-muted); 
    font-size: 0.9rem; 
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.post-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.post-image {
    width: 100%;
    height: 280px;
    object-fit: cover;
    border-radius: var(--border-radius-large);
    margin-bottom: 32px;
    box-shadow: var(--shadow-subtle);
}

.post-content { 
    font-size: 1.1rem; 
    line-height: 1.3; /* Reducido de 1.7 a 70% */
    color: var(--text-secondary);
}

/* ====================================
   TIPOGRAFÍA LIMPIA
   ==================================== */

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    font-weight: 600;
    line-height: 1; /* Reducido a 70% */
    margin-top: 1em; /* Reducido 30% de 2em */
    margin-bottom: 0.5em; /* Reducido 10% de 0.75em */
    color: var(--text-primary);
}

.post-content h1 { font-size: 2.2rem; }
.post-content h2 { font-size: 1.8rem; }
.post-content h3 { font-size: 1.5rem; }
.post-content h4 { font-size: 1.2rem; }

.post-content p {
    margin-bottom: 1.3em; /* Párrafos Reducido 10% de 1.5em */
}

/* ====================================
   LISTAS
   ==================================== */

.post-content ul,
.post-content ol {
    margin: 1.5em 0;
    padding-left: 1.5em;
}

.post-content li {
    margin-bottom: 0.5em;
    line-height: 1.1; /* Reducido 70 % */
}

/* ====================================
   TABLAS SIMPLES
   ==================================== */

.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2em 0;
    background: var(--background-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.post-content th,
.post-content td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.post-content th {
    background: var(--background-light);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* ====================================
   IMÁGENES
   ==================================== */

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    margin: 2em 0;
}

/* ====================================
   CITAS Y CÓDIGO SIMPLIFICADOS
   ==================================== */

.post-content blockquote {
    border-left: 3px solid var(--primary-color);
    padding: 16px 20px;
    margin: 2em 0;
    background: var(--background-quote);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    font-style: italic;
    color: var(--text-secondary);
}

.post-content code {
    background: var(--background-code);
    padding: 2px 6px;
    border-radius: var(--border-radius-small);
    font-family: "SF Mono", "Monaco", "Menlo", monospace;
    font-size: 0.9em;
    color: var(--text-primary);
}

.post-content pre {
    background: var(--background-pre);
    color: #E8E8EA;
    padding: 20px;
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin: 2em 0;
}

.post-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* ====================================
   ENLACES
   ==================================== */

.post-content a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.post-content a:hover {
    text-decoration: underline;
}

/* ====================================
   PIE DEL POST
   ==================================== */

.post-footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.post-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 20px;
}

.volver-link {
    display: inline-block;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.9rem;
}

.volver-link:hover {
    background: var(--primary-hover);
}

.categoria-link {
    display: inline-block;
    padding: 10px 16px;
    background: var(--accent-color);
    color: white;
    text-decoration: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: var(--transition);
    font-size: 0.9rem;
}

.categoria-link:hover {
    background: var(--primary-color);
    text-decoration: none;
    color: white;
}

/* ====================================
   FOOTER DEL SITIO - REDUCIDO
   ==================================== */

.blog-footer {
    background: var(--text-primary);
    color: white;
    margin-top: 40px;
    padding: 24px 0 16px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    padding: 0 24px;
}

.footer-section h4 {
    margin-bottom: 16px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.footer-section p {
    color: var(--text-light);
    line-height: 1.05; /* Reducido de 1.5 a 70% */
    font-size: 0.9rem;
    margin: 0;
}

.social-links {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.social-links a {
    font-size: 1rem;
    padding: 8px;
    border-radius: var(--border-radius-small);
    background: rgba(255, 255, 255, 0.1);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    text-decoration: none;
    color: white;
}

.social-links a:hover {
    background: var(--primary-color);
}

.footer-bottom {
    text-align: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-size: 0.85rem;
}

/* ====================================
   BADGES DE CATEGORÍAS (PARA POSTS)
   ==================================== */

.categoria-badge {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 3px 8px;
    border-radius: var(--border-radius-small);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    transition: var(--transition);
}

.categoria-badge:hover {
    background: var(--primary-hover);
    text-decoration: none;
    color: white;
}

.categoria-badge a {
    color: white !important;
    text-decoration: none;
}

.categoria-badge:hover a {
    color: white !important;
    text-decoration: none;
}

.post-meta .categoria-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
}

.post-meta .categoria-badge a {
    color: white !important;
    text-decoration: none;
}

/* ====================================
   RESPONSIVE DESIGN
   ==================================== */

@media (max-width: 992px) {
    .layout-container {
        grid-template-columns: 1fr;
        gap: 32px;
    }
    
    .sidebar {
        /* Ya no necesitamos position: static; porque lo removimos arriba */
        /* Removido: order: -1; para que aparezca después del contenido */
    }
    
    .sidebar-widget {
        margin-bottom: 16px;
    }
    
    .categorias-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px; /* Mantenemos la reducción del 25% */
    }
    
    .categoria-sidebar-link {
        flex: 0 0 auto;
        min-width: 120px;
    }
}

@media (max-width: 768px) {
    .blog-nav {
        padding: 0 16px;
    }
    
    .nav-links a {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    .layout-container {
        padding: 0 16px;
        margin: 20px auto;
        gap: 24px;
    }
    
    .post-container { 
        padding: 24px; 
    }
    
    .post-title { 
        font-size: 2rem;
    }
    
    .post-image {
        height: 200px;
        margin-bottom: 24px;
    }
    
    .post-content {
        font-size: 1rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 20px;
    }
    
    .container {
        padding: 24px;
    }
    
    .post-card-content {
        flex-direction: column;
        height: auto;
    }
    
    .post-card {
        height: auto;
        min-height: 100px;
    }
    
    .post-card-image {
        width: 100%;
        height: 72px; /* Mantener proporción en móvil */
    }
    
    .post-card-image img {
        width: 100%;
        height: 72px;
    }
    
    .post-card-text {
        height: auto;
        min-height: auto;
        padding: 12px;
    }
    
    .categorias-sidebar {
        flex-direction: column;
        gap: 6px; /* Mantenemos la reducción */
    }
    
    .categoria-sidebar-link {
        min-width: auto;
    }
    
    .categoria-titulo {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .blog-header {
        padding: 8px 0;
    }
    
    .blog-nav {
        flex-direction: column;
        gap: 12px;
        padding: 8px 16px;
    }
    
    .post-title {
        font-size: 1.75rem;
    }
    
    .post-container {
        padding: 20px;
    }
    
    .container {
        padding: 20px;
    }
    
    .post-actions {
        flex-direction: column;
        text-align: center;
    }
    
    .volver-link, .categoria-link {
        width: 100%;
        text-align: center;
    }
    
    .blog-footer {
        padding: 20px 0 12px;
    }
    
    .sidebar-widget {
        padding: 16px;
    }
    
    .post-card-image {
        height: 72px; /* Mantener altura consistente en móviles pequeños */
    }
    
    .post-card-image img {
        height: 72px;
    }
    
    .categoria-titulo {
        font-size: 1.25rem;
        margin-bottom: 20px;
    }
    
    .post-card {
        min-height: 90px;
    }
}

/* ====================================
   UTILIDADES
   ==================================== */

.text-center { text-align: center; }
.mb-3 { margin-bottom: 24px; }
.mt-4 { margin-top: 32px; }

/* ====================================
   VIDEOS DE YOUTUBE RESPONSIVOS
   ==================================== */

/* Hacer responsivos todos los iframes de YouTube */
.post-content iframe[src*="youtube"] {
    max-width: 100%;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: var(--border-radius);
    margin: 2em 0;
    border: 0;
}