/* Buscador de alimento */
.alimento-search-wrap {
    position: relative;
}

.alimento-search {
    width: 100%;
    padding: 0.6rem 2.5rem 0.6rem 0.9rem;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--font-primary);
    font-size: 0.88rem;
    background: var(--bg-soft);
    color: var(--text-color);
    transition: border-color var(--transition);
}

.alimento-search:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #fff;
}

.search-icon-abs {
    position: absolute;
    right: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.alimento-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 200;
    background: #fff;
    border: 1.5px solid var(--primary-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    display: none;
}

.alimento-dropdown.visible {
    display: block;
}

.alimento-option {
    padding: 0.5rem 0.9rem;
    font-family: var(--font-primary);
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr repeat(4, auto);
    gap: 0.5rem;
    align-items: center;
}

.alimento-option:last-child {
    border-bottom: none;
}

.alimento-option:hover {
    background: #eff6ff;
}

.alimento-option .col-nut {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: right;
    white-space: nowrap;
}

/* Tabla de ingredientes añadidos */
.ingredientes-lista {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    font-family: var(--font-primary);
    margin-top: 0.8rem;
}

.ingredientes-lista th {
    background: var(--bg-soft);
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    padding: 0.5rem 0.6rem;
    text-align: right;
    border-bottom: 2px solid var(--border-color);
}

.ingredientes-lista th:first-child {
    text-align: left;
}

.ingredientes-lista th:last-child {
    text-align: center;
}

.ingredientes-lista td {
    padding: 0.42rem 0.6rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    font-variant-numeric: tabular-nums;
}

.ingredientes-lista td:first-child {
    text-align: left;
    font-weight: 600;
}

.ingredientes-lista td:last-child {
    text-align: center;
}

.ingredientes-lista tfoot td {
    font-weight: 700;
    color: var(--primary-color);
    background: #eff6ff;
    padding: 0.55rem 0.6rem;
}

.btn-del {
    background: none;
    border: none;
    cursor: pointer;
    color: #dc2626;
    font-size: 0.85rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: background var(--transition);
}

.btn-del:hover {
    background: #fee2e2;
}

.tabla-wrap {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* Macros tarjetas */
.macro-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    margin-top: 0.8rem;
}

.macro-card {
    border-radius: 10px;
    padding: 0.9rem 0.7rem;
    text-align: center;
}

.macro-card.kcal {
    background: linear-gradient(135deg, #fef3c7, #fffbeb);
    border: 1.5px solid #fcd34d;
}

.macro-card.prot {
    background: linear-gradient(135deg, #dbeafe, #eff6ff);
    border: 1.5px solid #93c5fd;
}

.macro-card.carb {
    background: linear-gradient(135deg, #d1fae5, #ecfdf5);
    border: 1.5px solid #6ee7b7;
}

.macro-card.fat {
    background: linear-gradient(135deg, #fce7f3, #fdf2f8);
    border: 1.5px solid #f9a8d4;
}

.macro-card .macro-lbl {
    font-family: var(--font-primary);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.macro-card .macro-val {
    font-family: var(--font-primary);
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
}

.macro-card.kcal .macro-val {
    color: #d97706;
}

.macro-card.prot .macro-val {
    color: #2563eb;
}

.macro-card.carb .macro-val {
    color: #059669;
}

.macro-card.fat .macro-val {
    color: #db2777;
}

.macro-card .macro-sub {
    font-family: var(--font-primary);
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* Barra de macros */
.macro-barra {
    display: flex;
    height: 16px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    margin: 0.7rem 0 0.3rem;
}

.mb-prot {
    background: #2563eb;
}

.mb-carb {
    background: #059669;
}

.mb-fat {
    background: #db2477;
}

/* Recetas de ejemplo */
.recetas-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.8rem;
}

.receta-chip {
    padding: 0.28rem 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-soft);
    font-family: var(--font-primary);
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.receta-chip:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Estado vacío */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    font-family: var(--font-primary);
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 0.6rem;
    display: block;
    opacity: 0.3;
}

/* Botón añadir ingrediente */
.add-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-top: 0.8rem;
}

.add-row .field-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 140px;
}

@media (max-width:500px) {
    .macro-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Leyenda del gráfico de ingredientes */
.receta-chart-legend {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem 0.75rem;
    margin-top: 0.8rem;
}