@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&display=swap');

/*
Theme Name: Taringa! v7 Clone
Theme URI: https://tu-sitio.com
Author: Desarrollador Senior WordPress
Description: Custom Theme estilo Taringa! v7 con Gamificación, AJAX nativo y motor Anti-Spam.
Version: 1.2
License: Apache-2.0
*/

/* ============================================
   RESET Y BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    background-color: #f2f3f5;
    font-family: 'Fredoka One', cursive, sans-serif;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

a, .text-taringa-blue {
    color: #0047ba !important;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #003087 !important;
    text-decoration: underline;
}

footer {
    margin-top: auto;
    padding: 20px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
}

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

/* ============================================
   MODO OSCURO (Dark Mode)
   ============================================ */
:root {
    --dark-bg: #0f172a;
    --dark-bg-secondary: #1e293b;
    --dark-bg-tertiary: #334155;
    --dark-text: #f1f5f9;
    --dark-text-secondary: #cbd5e1;
    --dark-border: #334155;
}

html.dark-mode body {
    background-color: var(--dark-bg) !important;
    color: var(--dark-text) !important;
}

html.dark-mode .bg-white {
    background-color: var(--dark-bg-secondary) !important;
}

html.dark-mode .text-gray-900,
html.dark-mode .text-gray-800 {
    color: var(--dark-text) !important;
}

html.dark-mode .text-gray-700 {
    color: var(--dark-text-secondary) !important;
}

html.dark-mode .border,
html.dark-mode .border-gray-200,
html.dark-mode .border-gray-100,
html.dark-mode .border-gray-300 {
    border-color: var(--dark-border) !important;
}

html.dark-mode header,
html.dark-mode footer {
    background-color: var(--dark-bg-secondary) !important;
    border-color: var(--dark-border) !important;
}

html.dark-mode input[type="text"],
html.dark-mode textarea {
    background-color: var(--dark-bg-tertiary) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
}

html.dark-mode .bg-gray-50,
html.dark-mode .bg-gray-100 {
    background-color: var(--dark-bg-tertiary) !important;
}

html.dark-mode a, 
html.dark-mode .taringa-blue, 
html.dark-mode .text-taringa-blue,
html.dark-mode article h2 a {
    color: #facc15 !important;
}

html.dark-mode a:hover {
    color: #eab308 !important;
}


html.dark-mode .shadow-sm {
    box-shadow: 0 1px 3px rgba(0,0,0,0.5) !important;
}

html.dark-mode button:hover,
html.dark-mode button:focus {
    background-color: var(--dark-bg-tertiary) !important;
}

/* ============================================
   UTILIDADES
   ============================================ */
.t-shadow {
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}

.taringa-blue { color: #0047ba; }
.bg-taringa-blue { background-color: #0047ba; }

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================
   RESPONSIVE - Breakpoints
   ============================================ */

/* Móvil pequeño (< 480px) */
@media (max-width: 479px) {
    .max-w-7xl {
        max-width: 100%;
        padding-left: 12px;
        padding-right: 12px;
    }
    
    header {
        padding: 0 12px !important;
    }
    
    header .flex {
        gap: 8px !important;
    }
    
    header a[href*="crear-post"] {
        padding: 6px 10px !important;
        font-size: 11px !important;
    }
    
    header input[type="text"] {
        width: 120px !important;
    }
    
    .text-2xl {
        font-size: 1.25rem !important;
    }
}

/* Móvil (< 640px) */
@media (max-width: 639px) {
    .max-w-7xl {
        flex-direction: column;
        padding-left: 12px;
        padding-right: 12px;
    }
    
    /* Ocultar sidebars en móvil */
    aside.w-56,
    aside.w-64,
    aside.w-72 {
        display: none !important;
    }
    
    /* Feed central a ancho completo */
    section.flex-grow {
        max-width: 100% !important;
        width: 100%;
    }
    
    /* Posts en móvil */
    article {
        flex-direction: column !important;
    }
    
    article .w-12 {
        width: 100% !important;
        flex-direction: row !important;
        border-right: none !important;
        border-bottom: 1px solid #f3f4f6;
        padding: 8px 12px !important;
        justify-content: flex-start;
        gap: 12px;
    }
    
    article .w-12 .t-vote-count {
        margin: 0 !important;
    }
    
    article .w-12 svg {
        width: 20px !important;
        height: 20px !important;
    }
    
    /* Header responsive */
    header {
        padding: 0 12px !important;
        height: auto !important;
        min-height: 56px;
        flex-wrap: wrap;
        gap: 8px;
        padding-top: 8px !important;
        padding-bottom: 8px !important;
    }
    
    header .flex.items-center.gap-6:first-child {
        flex: 1;
        min-width: 0;
    }
    
    header form.relative {
        display: none !important;
    }
    
    header .hidden.md\\:block {
        display: none !important;
    }
    
    /* Footer responsive */
    footer {
        padding: 20px 12px !important;
    }
    
    footer .flex {
        flex-direction: column;
        text-align: center;
        gap: 12px !important;
    }
    
    footer .flex.gap-8 {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Tablet (< 768px) */
@media (max-width: 767px) {
    .max-w-7xl {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    /* Ajustar filtros */
    .bg-white.rounded-lg.p-2.flex.items-center.justify-between {
        overflow-x: auto;
    }
    
    .bg-white.rounded-lg.p-2.flex.items-center.justify-between .flex {
        flex-wrap: nowrap;
        white-space: nowrap;
    }
    
    /* Posts más compactos */
    article .p-4 {
        padding: 12px !important;
    }
    
    article h2.text-lg {
        font-size: 1rem;
    }
    
    article .text-sm {
        font-size: 0.875rem;
    }
    
    /* Ocultar elementos no esenciales */
    .hidden.sm\\:block {
        display: none !important;
    }
    
    /* Sidebar derecho */
    aside.w-64 {
        display: none !important;
    }
}

/* Tablet grande / Laptop pequeño (< 1024px) */
@media (max-width: 1023px) {
    .max-w-7xl {
        padding-left: 20px;
        padding-right: 20px;
    }
    
    aside.w-56 {
        width: 48px !important;
    }
    
    aside.w-56 nav a span:not(.svg) {
        display: none;
    }
    
    aside.w-56 nav a {
        justify-content: center;
        padding: 8px !important;
    }
    
    aside.w-64 {
        width: 200px !important;
    }
    
    section.max-w-xl {
        max-width: 100% !important;
    }
}

/* Laptop (< 1280px) */
@media (max-width: 1279px) {
    aside.w-72 {
        display: none !important;
    }
}

/* Desktop (> 1280px) */
@media (min-width: 1280px) {
    .max-w-7xl {
        max-width: 1280px;
    }
}

/* ============================================
   LIGHTBOX INTEGRADO
   ============================================ */

/* Overlay del lightbox */
.taringa-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.taringa-lightbox.active {
    display: flex;
    opacity: 1;
}

.taringa-lightbox img {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* Botón cerrar */
.taringa-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.taringa-lightbox-close:hover {
    background: rgba(255,255,255,0.2);
}

.taringa-lightbox-close::before,
.taringa-lightbox-close::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background: white;
}

.taringa-lightbox-close::before {
    transform: rotate(45deg);
}

.taringa-lightbox-close::after {
    transform: rotate(-45deg);
}

/* Navegación del lightbox */
.taringa-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.taringa-lightbox-nav:hover {
    background: rgba(255,255,255,0.2);
}

.taringa-lightbox-nav.prev {
    left: 20px;
}

.taringa-lightbox-nav.next {
    right: 20px;
}

.taringa-lightbox-nav svg {
    width: 24px;
    height: 24px;
    fill: white;
}

/* Indicador de posición */
.taringa-lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 14px;
    font-weight: 600;
    background: rgba(0,0,0,0.5);
    padding: 8px 16px;
    border-radius: 20px;
}

/* ============================================
   CORRECCIÓN DE IMÁGENES - Sin salto de línea
   ============================================ */

/* Imágenes en el contenido del post */
.post-content img,
.entry-content img,
.article-content img {
    display: inline !important;
    vertical-align: middle;
    margin: 0 !important;
    max-width: 100%;
    height: auto;
    line-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
}

/* Eliminar saltos de línea entre imágenes */
.post-content p > img,
.entry-content p > img,
.post-content p > a > img,
.entry-content p > a > img {
    display: inline-block !important;
    vertical-align: middle !important;
}

/* Contenedor de imágenes */
.post-content .wp-caption,
.entry-content .wp-caption,
.article-content .wp-caption {
    display: inline-block;
    max-width: 100%;
}

/* Figure y figcaption */
.post-content figure,
.entry-content figure {
    display: inline;
    margin: 0;
}

.post-content figure img,
.entry-content figure img {
    display: inline;
}

.post-content figcaption,
.entry-content figcaption {
    display: block;
    font-size: 0.85em;
    color: #666;
    text-align: center;
    margin-top: 4px;
}

/* Imágenes destacadas del post */
article .w-full.h-40 {
    width: 100%;
    height: auto;
    min-height: 200px;
    max-height: 400px;
}

article .w-full.h-40 img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================
   ESTILOS ADICIONALES
   ============================================ */

/* Botón crear post */
header a[href*="crear-post"] {
    transition: all 0.2s ease;
}

header a[href*="crear-post"]:hover {
    transform: scale(1.02);
}

/* Votación */
.t-vote {
    transition: color 0.15s ease, background-color 0.15s ease;
    font-size: 1.35rem;
    font-weight: 900;
    line-height: 1;
    min-width: 2rem;
    min-height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
}

.t-vote:focus-visible {
    outline: 2px solid #0047ba;
    outline-offset: 2px;
}

.t-vote-plus:hover,
.t-vote-minus:hover {
    background: rgba(0, 0, 0, 0.04);
}

.t-vote.opacity-20 {
    cursor: not-allowed;
}

/* Links del post */
article h2 a {
    text-decoration: none;
}

article h2 a:hover {
    text-decoration: underline;
}

/* Comentarios */
#comments {
    margin-top: 24px;
}

#comments .comment {
    margin-bottom: 16px;
}

/* Formulario de comentarios */
#commentform textarea {
    min-height: 100px;
    resize: vertical;
}

/* Widgets del sidebar */
.widget {
    margin-bottom: 16px;
}

/* Paginación */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination a,
.pagination span {
    padding: 8px 12px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    text-decoration: none;
    color: #374151;
}

.pagination a:hover {
    background: #f3f4f6;
}

.pagination .current {
    background: #0047ba;
    color: white;
    border-color: #0047ba;
}

/* ============================================
   MINIATURAS FORZADAS + CARRUSEL
   ============================================ */
.post-thumbnail-forced {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    display: block;
}

.t-carousel {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px;
    width: 100%;
    align-items: start;
}

.t-carousel-item {
    width: 100% !important;
    min-width: 0 !important;
}

.t-carousel-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    height: auto;
    min-height: 96px;
    object-fit: cover;
    border: 0 !important;
    border-radius: 0;
    display: block;
}

@media (max-width: 767px) {
    .t-carousel {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 6px;
    }

    .t-carousel-thumb {
        min-height: 76px;
    }
}
