* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, sans-serif;
    min-height: 100vh;
    
    /* Grid layout: Mobile first - sin grid inicialmente */
    display: flex;
    flex-direction: column;
}

.pinterest-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: white;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 16px;
    gap: 8px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Helvetica, "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", メイリオ, Meiryo, "ＭＳ Ｐゴシック", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.logo-container {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 4px;
    padding: 8px;
    border-radius: 24px;
}

.logo-container:hover {
    background-color: #f0f0f0;
}

.logo {
    height: 32px;
    width: auto;
}

.logo-text {
    color: #e60023;
    font-weight: 700;
    font-size: 20px;
    letter-spacing: -1px;
    margin-left: 4px;
}

.nav-links {
    display: flex;
    align-items: center;
    margin-left: 8px;
}

.nav-link {
    padding: 12px 16px;
    text-decoration: none;
    color: #111;
    font-weight: 600;
    border-radius: 24px;
    font-size: 16px;
    white-space: nowrap;
}

.nav-link.active {
    background-color: #111;
    color: white;
}

.nav-link:hover:not(.active) {
    background-color: #f0f0f0;
}

.header-center {
    flex: 1;
    padding: 0 8px;
}

.search-bar {
    display: flex;
    align-items: center;
    background: #e9e9e9;
    border-radius: 24px;
    padding: 0 16px;
    height: 48px;
    width: 100%;
}

.search-bar:hover, .search-bar:focus-within {
    background-color: #e1e1e1;
}

.search-icon {
    fill: #767676;
    margin-right: 8px;
}

.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 16px;
    color: #111;
    height: 100%;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.right-nav-links {
    display: flex;
    align-items: center;
}

.auth-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

.btn-login {
    background-color: #e60023;
    color: white;
    border: none;
    border-radius: 24px;
    padding: 10px 12px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-login:hover {
    background-color: #ad081b;
}

.btn-signup {
    background-color: #e9e9e9;
    color: black;
    border: none;
    border-radius: 24px;
    padding: 10px 12px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-signup:hover {
    background-color: #d0d0d0;
}



.page-layout {
    /* Mobile first: stack vertical sin grid */
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    /* Mobile first: sidebar oculto */
    display: none;
    background: #fff;
    padding: 16px;
    overflow-y: auto;
}

.sidebar h3 {
    margin: 0 0 16px 0;
    color: #111;
    font-size: 18px;
    font-weight: 600;
}

.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-list li {
    margin-bottom: 8px;
}

.category-link {
    display: block;
    padding: 10px 12px;
    text-decoration: none;
    color: #111;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
}

.category-link:hover {
    background: #e9e9e9;
}

.category-link.active {
    background: #e60023;
    color: white;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #f7f7f7;
    border-bottom: 1px solid #e0e0e0;
}

.filter-bar label {
    font-weight: 600;
    color: #111;
    font-size: 14px;
}

#categoryFilter {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #cdcdcd;
    font-size: 14px;
    cursor: pointer;
    background: white;
    min-width: 180px;
}

#categoryFilter:hover {
    border-color: #111;
}

.container {
    /* Mobile first: 1 columna */
    column-count: 1;
    column-gap: 12px;
    padding: 12px 8px;
}

/* Estilos base para image-container */
.image-container {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    cursor: pointer;
    /* Masonry layout fix */
    display: inline-block;
    width: 100%;
    margin-bottom: 12px;
    break-inside: avoid;
}

.image-container img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 16px;
}

.image-container:hover {
    box-shadow: 0 8px 16px rgba(94, 23, 104, 0.25);
    transform: translateY(-4px);
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 40%, rgba(0, 0, 0, 0.8) 100%);
    color: rgb(255, 255, 255);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Cuando se pasa el ratón por encima aparece el overlay */
.image-container:hover .overlay {
    opacity: 1;
}

.overlay-icons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    margin-top: 8px;
    order: 2;
}

.overlay .text {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    width: 100%;
    text-align: left;
    order: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    cursor: pointer;
    transition: transform 0.2s;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px;
    border-radius: 50%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border: none; /* Reset for button */
    outline: none; /* Reset for button */
}

.icon img, .like-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.icon:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.3);
}

.icon.filled {
    filter: none;
}

.image-container.liked {
    order: -1;
    border: 2px solid #e60023;
    box-shadow: 0 4px 12px rgba(230, 0, 35, 0.2);
}

.image-container.clicked {
    background: #fff5f7;
    border: 2px solid #ad8c91;
    box-shadow: 0 4px 12px rgba(173, 140, 145, 0.3);
}

.text {
    margin: 0;
    font-size: 14px;
}

.footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 16px;
    margin-top: auto;
    /* Mobile first: altura flexible */
    min-height: 50px;
}

.footer p {
    margin: 0;
    font-size: 14px;
}

.image-container.hidden {
    display: none !important;
}

/* ============================================
   MEDIA QUERIES - MOBILE FIRST
   ============================================ */

/* Tablets: entre 600px y 800px */
@media (width >= 600px) {
    /* Header más grande */
    .pinterest-header {
        height: 70px;
        padding: 12px 24px;
    }
    
    .logo {
        height: 28px;
        max-width: 160px;
    }
    
    .nav-links {
        display: flex; /* Mostrar nav links */
    }
    
    .btn-login {
        display: inline-block; /* Mostrar botón login */
    }
    
    .header-center {
        max-width: 500px;
    }
    
    /* Mostrar sidebar colapsado o parcial */
    .sidebar {
        display: block;
        width: 180px;
        border-right: 1px solid #e0e0e0;
    }
    
    .page-layout {
        flex-direction: row;
    }
    
    /* 2 columnas para tarjetas */
    .container {
        padding: 16px;
        column-count: 2;
        column-gap: 16px;
    }
    
    .image-container {
        margin-bottom: 16px;
        max-width: 100%;
    }
    
    .footer {
        height: 60px;
        padding: 20px;
    }
}

/* Desktop: más de 800px */
@media (width >= 800px) {
    /* Flex layout para desktop */
    body {
        /* Mantenemos flex column del mobile */
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }
    
    .pinterest-header {
        height: 80px;
        padding: 16px 40px;
    }
    
    .logo {
        height: 32px;
        max-width: 200px;
    }
    
    .header-center {
        max-width: 600px;
        margin: 0 20px;
    }
    

    
    .btn-login,
    .btn-signup {
        padding: 12px 16px;
        font-size: 16px;
    }
    
    .page-layout {
        /* Cambiamos a fila para sidebar + main */
        flex-direction: row;
        display: flex;
        flex: 1;
        overflow: hidden;
    }
    
    .sidebar {
        display: block;
        width: 240px;
        padding: 24px 16px;
        flex-shrink: 0;
        border-right: 1px solid #e0e0e0;
        overflow-y: auto;
    }
    
    .main-content {
        flex: 1;
        overflow-y: auto;
    }
    
    .footer {
        height: 60px;
    }
    
    /* 3-4 columnas para tarjetas en desktop */
    .container {
        padding: 20px;
        column-count: 3;
        column-gap: 20px;
    }
    
    .image-container {
        margin-bottom: 20px;
        max-width: 100%;
    }
}

/* Desktop grande: más de 1200px - 4 columnas */
@media (width >= 1200px) {
    .container {
        column-count: 4;
    }
}