@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap');

:root {
    --primary: #8baf6b;
    --secondary: #96e001;
    --background: #f5f5f5;
    --card-bg: #fff;
    --text-main: #222;
    --text-secondary: #666;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --accent: #ff9800;
    --border-radius: 18px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background: var(--primary);
    color: var(--text-main);
    font-family: 'Nunito', sans-serif;
    margin: 0;
    min-height: 100vh;
}

body.hacemos-body {
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #1a5276 0%, #27ae60 100%);
}

body.no-scroll {
    overflow: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

body.hacemos-body main {
    flex: 1 0 auto;
    color: white;
    text-align: center;
}

body.hacemos-body footer {
    color: white;
}

header {
    background: linear-gradient(135deg, #1a5276 0%, #2c3e50 100%);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 1rem 0;
    position: relative;
    border-bottom: 3px solid #3498db;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 2rem;
}

/* LOGO MEJORADO */
.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-mejorado {
    height: 50px;
    width: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.logo-mejorado:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.logo-mejorado img {
    height: 100%;
    width: 100%;
    object-fit: contain;
}

.logo-text {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: -0.5px;
}

.logo-subtitle {
    color: #ecf0f1;
    font-size: 0.9rem;
    font-weight: 300;
    margin-top: -2px;
}

/* Para los nuevos elementos */
.logo-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s;
}

.logo-link:hover {
    transform: translateY(-2px);
}

.logo-link:focus {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 8px;
}

/* Texto oculto para screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Mejor contraste para accesibilidad */
.logo-text {
    color: white;
    font-weight: 700;
    font-size: 1.6rem;
}

.logo-subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    font-style: italic;
    font-weight: 300;
}



/* NAVEGACIÓN MEJORADA */
.nav-mejorada {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    color: #ecf0f1;
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
}

.nav-link:hover {
    color: white;
    background: rgba(52, 152, 219, 0.2);
    transform: translateY(-2px);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    width: 0;
    height: 2px;
    background: #3498db;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::after {
    width: 80%;
}

.nav-link.active {
    color: #3498db;
    background: rgba(52, 152, 219, 0.1);
}

/* BOTÓN DESTACADO */
.btn-destacado,
.btn-mobile-fixed {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 209, 87, 0.3);
    border: none;
    cursor: pointer;
}

.btn-destacado:hover,
.btn-mobile-fixed:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 209, 87, 0.3);
}

/* MENÚ MÓVIL MEJORADO */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* INDICADOR DE PÁGINA ACTIVA */
.nav-indicator {
    position: absolute;
    bottom: -13px;
    left: 0;
    width: 100%;
    height: 3px;
    background: #3498db;
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.nav-link.active .nav-indicator {
    transform: scaleX(1);
}

/* Estilos para el input de buscador de productos */
#buscadorProductos {
    width: 100%;
    max-width: 400px;
    margin: 0;
    display: block;
    font-size: 1.2rem;
    padding: 0.5rem 1.2rem;
    border-radius: 0.5rem;
    border: 1px solid #ccc;
}


/* SECCIÓN DE INTRODUCCIÓN SEO */
.seo-intro {
    text-align: center;
    margin: 4rem auto;
    padding: 1.5rem 2rem;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    position: relative;
    overflow: hidden;
}

.seo-intro::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, var(--primary), var(--secondary), var(--accent));
}

.seo-intro h1 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-main);
    position: relative;
    display: inline-block;
}

.seo-intro h1::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 4px;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    border-radius: 2px;
}

.seo-intro p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 800px;
    margin: 1.5rem auto 0;
    line-height: 1.7;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 2.5rem;
    margin: 2rem auto;
    max-width: 1400px;
    padding: 2rem;
}

.product-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 2.2rem 2.2rem 1.2rem 2.2rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    animation: fadeIn 0.7s;
    position: relative;
    transition: transform 0.3s, box-shadow 0.3s;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 99%;
    height: 5px;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.product-header {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    font-weight: 700;
    font-size: .9rem;
    color: var(--text-main);
    margin-bottom: 10px;
}

.product-card:nth-child(2) {
    animation-delay: 0.1s;
}

.product-card:nth-child(3) {
    animation-delay: 0.2s;
}

.icon-historico {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.8rem;
}

.precios {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.precio-supermercado {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background-color: #f9f9f9;
    border-radius: 12px;
    transition: all 0.3s;
    border-left: 4px solid transparent;
    gap: 1.2rem;
    font-size: 1.5rem;
    margin-bottom: 0.7rem;
}

.precio-supermercado:hover {
    background-color: #f0f0f0;
    transform: scale(1.02);
}

.precio-supermercado.mejor-precio {
    border-left: 4px solid var(--accent);
    background-color: #fff8e1;
}

.icon-supermercado-wrapper {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

.icon-supermercado-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.precio-supermercado p {
    flex-grow: 1;
    font-size: 1.5rem;
    font-weight: 500;
    margin: 0;
}

.verde {
    color: #16a34a;
    font-weight: 600;
}

.rojo {
    color: #dc2626;
}

.enlace-super {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.3s;
    font-size: 1.2rem;
}

.enlace-super:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.stats-summary {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed #ddd;
    gap: 2.2rem;
    font-size: 1.3rem;
    color: var(--text-secondary);
}

.stat {
    text-align: center;
    flex: 1;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.price-history-btn {
    width: 100%;
    padding: 12px;
    margin-top: 20px;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
}

.price-history-btn:hover {
    background: linear-gradient(to right, var(--secondary), var(--primary));
    transform: scale(1.02);
}

/* Buscador con lupa */
.buscador-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 2rem auto 2rem auto;
    max-width: 400px;
    position: absolute;
    right: 90px;
    top: -10px;
}

.lupa-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 50%;
    width: 54px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.7rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: background 0.2s, transform 0.2s;
}


.lupa-btn:hover {
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    transform: scale(1.08);
}

.buscador-input {
    width: 0;
    min-width: 0;
    max-width: 320px;
    font-size: 1.6rem;
    padding: 0.7rem 0;
    border-radius: 0.5rem;
    border: 1px solid #ccc;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
    outline: none;
    opacity: 0;
    transition: width 0.35s cubic-bezier(.4, 0, .2, 1), opacity 0.25s, padding 0.35s;
    margin-left: 0;
    margin-right: 0;
}

.buscador-input.active {
    width: 100%;
    min-width: 180px;
    opacity: 1;
    padding: 0.7rem 1.2rem;
    margin-left: 0.5rem;
    margin-right: 0.5rem;
}

.buscador-input:focus {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    border-color: var(--primary);
}

footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}


#listaCompraOptima {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    padding: 2.5rem;
    border: 1px solid #e9ecef;
    animation: modalSlideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: fixed;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    max-width: 90vw;
    max-height: 80vh;
    overflow: auto;
}

#listaCompraOptima h2 {
    color: #2c3e50;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: center;
    background: linear-gradient(135deg, #2c3e50, #3498db);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid #3498db;
}

#cerrarListaCompraOptima {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
    position: absolute;
    top: 10px;
    right: 20px;
}

#cerrarListaCompraOptima:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
    background: linear-gradient(135deg, #c0392b, #a93226);
}

/* ESTILOS PARA ESCRITORIO */
#listaCompraOptima .tabla-escritorio {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

#listaCompraOptima .tabla-escritorio th {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
}

#listaCompraOptima .tabla-escritorio th span {
    font-weight: 400;
    font-size: 0.6rem;
    color: #bdc3c7;
    margin-left: 6px;
    text-transform: lowercase;
}

#listaCompraOptima .tabla-escritorio td {
    padding: 1rem;
    border-bottom: 1px solid #f1f3f4;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

#listaCompraOptima .tabla-escritorio td:nth-child(2),
#listaCompraOptima .tabla-escritorio td:nth-child(6) {
    font-weight: 700;
    color: #3498db;
    text-transform: capitalize;
}

#listaCompraOptima .tabla-escritorio td:nth-child(3),
#listaCompraOptima .tabla-escritorio td:nth-child(10) {
    font-weight: 700;
    color: #27ae60;
    text-transform: capitalize;
}

#listaCompraOptima .tabla-escritorio tr:last-child td {
    border-bottom: none;
}

#listaCompraOptima .tabla-escritorio tr:hover td {
    background-color: #f8f9fa;
    transform: translateX(4px);
}

/* ESTILOS PARA MÓVIL - TARJETAS */
#listaCompraOptima .lista-movil {
    display: none;
}

#listaCompraOptima .producto-card {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.8rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-left: 3px solid #3498db;
    transition: all 0.2s ease;
}

#listaCompraOptima .producto-card:active {
    transform: scale(0.98);
}

#listaCompraOptima .producto-card .producto-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.8rem;
    gap: 0.5rem;
}

#listaCompraOptima .producto-card .producto-nombre {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.3;
    flex: 1;
}

#listaCompraOptima .producto-card .supermercado {
    background: #3498db;
    color: white;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
}

#listaCompraOptima .producto-card .info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

#listaCompraOptima .producto-card .info-item {
    display: flex;
    flex-direction: column;
}

#listaCompraOptima .producto-card .info-label {
    font-size: 0.65rem;
    color: #7f8c8d;
    font-weight: 500;
    text-transform: uppercase;
    margin-bottom: 0.1rem;
    letter-spacing: 0.3px;
}

#listaCompraOptima .producto-card .info-value {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
}

#listaCompraOptima .producto-card .precio-bajo {
    color: #27ae60;
}

#listaCompraOptima .producto-card .precio-alto {
    color: #e74c3c;
    font-size: 0.75rem;
}

#listaCompraOptima .producto-card .ahorro {
    color: #27ae60;
    background: #f0fff4;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.75rem;
}

#listaCompraOptima .producto-card .peso {
    color: #7f8c8d;
    font-size: 0.75rem;
}

#listaCompraOptima .producto-card .enlace-container {
    text-align: center;
    margin-top: 0.3rem;
}

#listaCompraOptima a {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    background-color: #ebf5fb;
    transition: all 0.2s ease;
    display: inline-block;
    font-size: 0.75rem;
}

#listaCompraOptima a:active {
    background-color: #3498db;
    color: white;
    transform: scale(0.95);
}

#listaCompraOptima .totales {
    margin-top: 1.2rem;
    padding-top: 0.8rem;
    border-top: 1px solid #e9ecef;
}

#listaCompraOptima .total-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.5rem;
    margin-bottom: 0.4rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
}

#listaCompraOptima .total-optimo {
    background: linear-gradient(135deg, #f0fff4, #e8f5e8);
    color: #27ae60;
    border: 1px solid #27ae60;
}

#listaCompraOptima .total-ahorro {
    background: linear-gradient(135deg, #fff5f5, #ffe8e8);
    color: #e74c3c;
    border: 1px solid #e74c3c;
}

#listaCompraOptima .total-valor {
    font-size: 1rem;
    font-weight: 700;
}

/* SISTEMA SEMÁFORO - Integrado con tu diseño */
.semaforo-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.semaforo-verde {
    background: #27ae60;
    color: white;
}

.semaforo-amarillo {
    background: #f39c12;
    color: white;
}

.semaforo-rojo {
    background: #e74c3c;
    color: white;
}

.semaforo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}


/* CONTENIDO DEMOSTRATIVO */

.demo-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-top: 8rem;
    margin-bottom: 1rem;
}

.demo-description {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.feature-card {
    transition: transform 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.feature-card:hover {
    transform: translateY(-5px);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #3498db;
}

.feature-title {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.feature-description {
    line-height: 1.5;
}



/* Estilos específicos para la página de gestión */

.gestionBody .listaProductos {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin: 20px 0;
}

.gestionBody .producto-header {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1fr 1fr 1fr auto;
    gap: 1px;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    font-weight: 600;
    font-size: 14px;
    padding: 16px 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gestionBody .producto-fila {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1fr 1fr 1fr auto;
    gap: 1px;
    background-color: white;
    border-bottom: 1px solid #e9ecef;
    padding: 12px;
    align-items: center;
    transition: all 0.3s ease;
    position: relative;
}

.gestionBody .producto-fila:hover {
    background-color: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gestionBody .producto-fila span:first-child {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.gestionBody .producto-fila span:nth-child(2) {
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

.gestionBody .precio {
    font-weight: 600;
    color: #e74c3c;
    font-size: 14px;
    text-align: center;
    padding: 4px 8px;
    border-radius: 4px;
    background-color: #fff5f5;
}

.gestionBody .precio:not(:empty) {
    animation: fadeIn 0.5s ease-in;
}

.gestionBody .acciones {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.gestionBody .btn-edit,
.gestionBody .btn-delete {
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gestionBody .btn-edit {
    background-color: #3498db;
    color: white;
}

.gestionBody .btn-edit:hover {
    background-color: #2980b9;
    transform: scale(1.05);
}

.gestionBody .btn-delete {
    background-color: #e74c3c;
    color: white;
}

.gestionBody .btn-delete:hover {
    background-color: #c0392b;
    transform: scale(1.05);
}

.gestionBody .btn-edit i,
.gestionBody .btn-delete i {
    font-size: 14px;
}

/* Estados para precios indefinidos */
.gestionBody .precio:empty::before {
    content: "---";
    color: #bdc3c7;
    font-weight: normal;
}

.gestionBody .producto-fila span:nth-child(2):contains("undefined") {
    color: #bdc3c7;
}

/* Efectos de carga para datos pendientes */
.gestionBody .producto-fila:has(.precio:empty) {
    background-color: #fafafa;
}

.gestionBody .producto-fila:has(.precio:empty)::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading 1.5s infinite;
}


/* Selector específico para cuando el texto contiene "undefined" */
.gestionBody .producto-fila span:nth-child(2) {
    position: relative;
}

.gestionBody .producto-fila span:nth-child(2):not(:empty) {
    color: #6c757d;
}

.gestionBody .producto-fila span:nth-child(2):empty::before {
    content: "Precio por unidad";
    color: #bdc3c7;
    font-style: italic;
}

.gestionBody #modalAddSuper,
.gestionBody #modalEditProduct {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 0;
    width: 90%;
    max-width: 450px;
    animation: modalSlideIn 0.3s ease-out;
}

.gestionBody #modalAddSuper::before,
.gestionBody #modalEditProduct::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

.gestionBody #formAddSuper,
.gestionBody #formEditProduct {
    padding: 30px;
    position: relative;
}

.gestionBody #closeModalAddSuper,
.gestionBody #closeModalEditProduct {
    position: absolute;
    top: 15px;
    right: 20px;
    background: #e74c3c;
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
    z-index: 10;
}

.gestionBody #closeModalAddSuper:hover,
.gestionBody #closeModalEditProduct:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.gestionBody #formAddSuper h4,
.gestionBody #formEditProduct h4 {
    margin: 0 0 25px 0;
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    padding-bottom: 15px;
    border-bottom: 2px solid #3498db;
}

.gestionBody #formAddSuper div,
.gestionBody #formEditProduct div {
    margin-bottom: 20px;
    position: relative;
}

.gestionBody #formAddSuper label,
.gestionBody #formEditProduct label {
    display: block;
    margin-bottom: 8px;
    color: #2c3e50;
    font-weight: 600;
    font-size: 14px;
}

.gestionBody #formAddSuper input,
.gestionBody #formEditProduct input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    box-sizing: border-box;
    background-color: #f8f9fa;
}

.gestionBody #formAddSuper input:focus,
.gestionBody #formEditProduct input:focus {
    outline: none;
    border-color: #3498db;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    transform: translateY(-1px);
}

.gestionBody #formAddSuper input::placeholder,
.gestionBody #formEditProduct input::placeholder {
    color: #adb5bd;
    font-size: 13px;
}

.gestionBody #formAddSuper input[type="number"],
.gestionBody #formEditProduct input[type="number"] {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.gestionBody #formAddSuper button.add,
.gestionBody #formEditProduct button.save {
    width: 100%;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gestionBody #formAddSuper button.add:hover,
.gestionBody #formEditProduct button.save:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(39, 174, 96, 0.3);
    background: linear-gradient(135deg, #229954, #27ae60);
}

.gestionBody #formAddSuper button.add:active,
.gestionBody #formEditProduct button.save:active {
    transform: translateY(0);
}

.gestionBody #formAddSuper button.add:disabled,
.gestionBody #formEditProduct button.save:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Estilos para campos requeridos */
.gestionBody #formAddSuper input:required+label::after,
.gestionBody #formAddSuper label:has(+ input:required)::after {
    content: " *";
    color: #e74c3c;
}

/* Estilos para validación */
.gestionBody #formAddSuper input:invalid:not(:focus):not(:placeholder-shown) {
    border-color: #e74c3c;
    background-color: #fff5f5;
}

.gestionBody #formAddSuper input:valid:not(:focus):not(:placeholder-shown) {
    border-color: #27ae60;
    background-color: #f0fff4;
}

/* Efecto de overlay cuando el modal está visible */
.gestionBody #modalAddSuper[style*="display: block"]~* {
    filter: blur(2px);
    transition: filter 0.3s ease;
}

/* Estilos para tooltips o información adicional */
.gestionBody #formAddSuper div:has(input[placeholder*="opcional"]) label::after {
    content: " (opcional)";
    color: #7f8c8d;
    font-weight: normal;
    font-size: 12px;
    font-style: italic;
}

/* Modo edición para lista de la compra */
.product-card.modo-edicion {
    border: 2.5px solid #007bff !important;
    background: #eaf4ff !important;
    box-shadow: 0 4px 16px rgba(0, 123, 255, 0.10);
    transition: border 0.2s, background 0.2s;
}

/* Checkbox visible y alineado en modo edición */
.product-header .seleccion-producto {
    margin-left: 0.5rem;
    transform: scale(1.3);
    accent-color: #007bff;
    vertical-align: middle;
    cursor: pointer;
}

@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1.5rem;
    }

    .buscador-wrapper {
        top: 30px;
        left: 10px;
    }

    .menu-toggle {
        display: block;
    }

    .nav-mejorada {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: linear-gradient(135deg, #2c3e50, #34495e);
        flex-direction: column;
        padding: 1rem 0;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
        z-index: 1000;
    }

    .nav-mejorada.active {
        display: flex;
    }

    .nav-link {
        width: 90%;
        text-align: center;
        padding: 1rem;
        margin: 0.2rem 0;
    }

    /* OCULTAR BOTÓN DESTACADO EN NAVEGACIÓN MÓVIL */
    .nav-mejorada .btn-destacado {
        display: none;
    }

    /* MOSTRAR BOTÓN FIJO EN MÓVIL */
    .btn-mobile-fixed {
        display: block;
        top: 60px;
        position: fixed;
        z-index: 1000;
        right: 10px;
    }

    .logo-text {
        font-size: 1.3rem;
    }

    .precio-supermercado {
        text-align: center;
        gap: 10px;
    }

    .stats-summary {
        gap: 1rem;
    }

    .product-header {
        font-size: 1.5rem;
    }

    #listaCompraOptima {
        padding: 1.5rem;
        top: 0%;
        width: 99%;
    }

    #listaCompraOptima h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
        padding-right: 80px;
    }

    /* Oculta tabla de escritorio y muestra cards en móvil */
    #listaCompraOptima .tabla-escritorio {
        display: none;
    }

    #listaCompraOptima .lista-movil {
        display: block;
    }

    #cerrarListaCompraOptima {
        padding: 10px 16px;
        font-size: 12px;
        top: 0px;
        right: 5px;
    }

    #listaCompraOptima p {
        font-size: 1rem;
        padding: 0.8rem;
    }

    #listaCompraOptima .producto-card {
        padding: 1.2rem;
    }

    #listaCompraOptima .producto-card .producto-header,
    #listaCompraOptima .enlace-container {
        text-align: center;
    }

    #listaCompraOptima .producto-card .info-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        margin-bottom: 0.8rem;
    }

    .gestionBody .listaProductos {
        border-radius: 8px;
        margin: 10px;
    }

    .gestionBody .producto-header {
        display: none;
    }

    .gestionBody .producto-fila {
        display: flex;
        flex-direction: column;
        padding: 16px;
        margin-bottom: 8px;
        border-radius: 8px;
        border: 1px solid #e9ecef;
    }

    .gestionBody .producto-fila span {
        margin-bottom: 8px;
        text-align: center;
    }

    .gestionBody .acciones {
        margin-top: 12px;
        justify-content: center;
    }

    .gestionBody .precio {
        display: inline-block;
        margin: 2px 4px;
    }
}

/* MEDIA QUERY PARA MÓVILES MUY PEQUEÑOS */
@media (max-width: 480px) {

    body {
        padding: 0;
    }

    .container {
        padding: 0.3rem;
    }

    header {
        padding: 0.1rem 0.6rem;
        margin-bottom: 0.8rem;
        border-radius: 0;
    }

    header p {
        display: none;
    }

    h1 {
        font-size: 1.2rem;
    }

    .buscador-wrapper {
        position: fixed;
        z-index: 5;

    }

    .seo-intro h1 {
        font-size: 1rem;
        padding-top: 3rem;
    }

    .seo-intro p {
        font-size: 0.8rem;
        margin: 0;
    }

    .subtitle {
        font-size: 0.8rem;
    }

    .product-card {
        padding: 1rem;
    }

    .product-header {
        font-size: .8rem;
    }

    .icon-historico {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .precio-supermercado {
        padding: 0.6rem;
    }

    .precio-info {
        gap: 0.6rem;
    }

    .icon-supermercado-wrapper {
        width: 30px;
        height: 30px;
    }

    .precio-supermercado p {
        font-size: 1rem;
    }

    .enlace-super {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }

    .stats-summary {
        font-size: 0.8rem;
    }

    .stat-value {
        font-size: 1rem;
    }

    .price-history-btn {
        padding: 0.6rem;
        font-size: 0.85rem;
    }

    #listaCompraOptima {
        padding: 1rem;
        border-radius: 16px;
    }

    #listaCompraOptima h2 {
        font-size: 1.3rem;
        padding-right: 70px;
    }

    #listaCompraOptima .producto-card {
        padding: 1rem;
    }

    #listaCompraOptima .producto-card .producto-header {
        align-items: flex-start;
        gap: 0.5rem;
    }

    #listaCompraOptima .producto-card .supermercado {
        align-self: flex-start;
    }

    .gestionBody #modalAddSuper {
        width: 95%;
        top: 5%;
        max-width: none;
    }

    .gestionBody #formAddSuper {
        padding: 20px;
    }

    .gestionBody #formAddSuper h4 {
        font-size: 1.3rem;
        margin-bottom: 20px;
    }

    .gestionBody #formAddSuper input {
        padding: 10px 14px;
    }

    .gestionBody #formAddSuper button.add {
        padding: 12px 18px;
        font-size: 15px;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes loading {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes inputFocus {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.02);
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-30px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

@keyframes tableRowAppear {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}